Commit 632666ef authored by Omkar Hegde's avatar Omkar Hegde Committed by Erich Keane

CBOR rebase onto master for merge/review

The CA layer has been converted to use binary data, rather
than string data to support CBOR as a transport.  The CSDK has
been changed to use the OCPlatform object model instead of json
strings.  Underneath this, the JSON encoding has been replaced
with CBOR.

Also, some of the previous blockwise transfer functionality has
been removed, since the blockwise-transfer functionality has been
pushed ot the CA stack.

Change-Id: I6423a5180643cea3d311ec7497b246117f7c02b0
Signed-off-by: default avatarErich Keane <erich.keane@intel.com>
Signed-off-by: default avatarOmkar Hegde <omkar.m.hegde@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1613Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
parent a8c4123b
......@@ -96,6 +96,7 @@ extlibs/android/gradle/gradle-2.2.1
extlibs/android/ndk/android-ndk-r10d
extlibs/android/sdk/android-sdk_r24.2
extlibs/boost/boost_1_58_0
extlibs/tinycbor/tinycbor
*.tgz
*.zip
extlibs/arduino/arduino-1.5.8
......
......@@ -40,20 +40,13 @@ license can be found at
The original software is available from
http://sourceforge.net/projects/boost/files/boost
JSON serialization is provided by the cereal package,
which is open source software, written by Philip Hazel, and copyright
by the University of Cambridge, England. The original software is
available from
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
CBOR serialization is provided by the tinycbor package,
which is open source software, written by Thiago Macieira and is
copyright by the Intel Corporation. The original software is available
from
https://github.com/01org/tinycbor/
JSON serialization is provided by the cjson package,
which is open source software, written and copyright by Dave Gamble
with an MIT license. The original software is available from
http://sourceforge.net/projects/cjson/
JSON serialization is provided by the rapidjson package,
which is open source software, written and copyright by Milo Yip
with an MIT license. The original software is available from
http://code.google.com/p/rapidjson/
......@@ -9,8 +9,8 @@ command in this directory)
Build release binaries:
$ scons
(Note: C++ sdk requires cereal. Please follow the instruction in the build
message to install cereal)
(Note: C sdk requires tiny-cbor. Please follow the instruction in the build
message to install tiny-cbor)
Build debug binaries:
$scons RELEASE=false
......@@ -116,13 +116,10 @@ so you don't need to add it in command line each time. The build script will
guide you to do that.)
Tizen:
To build for tizen platform cereal library is needed.
Please download cereal if it is not present in extlibs/cereal folder
and apply the patch as following:
$ git clone https://github.com/USCiLab/cereal.git extlibs/cereal/cereal
$ cd extlibs/cereal/cereal
$ git reset --hard 7121e91e6ab8c3e6a6516d9d9c3e6804e6f65245
$ git apply ../../../resource/patches/cereal_gcc46.patch
To build for tizen platform tiny-cbor library is needed.
Please download tiny-cbor if it is not present in extlibs/tiny-cbor folder
by doing the following:
$ git clone https://github.com/01org/tinycbor.git extlibs/tinycbor/tinycbor
* 3. External libraries
......
......@@ -720,22 +720,6 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresent
rep->setValue(key, value);
}
/*
* Class: org_iotivity_base_OcRepresentation
* Method: getJSONRepresentation
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getJSONRepresentation
(JNIEnv *env, jobject thiz)
{
LOGD("OcRepresentation_getJSONRepresentation");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
if (!rep) return nullptr;
std::string jsonStr = rep->getJSONRepresentation();
return env->NewStringUTF(jsonStr.c_str());
}
/*
* Class: org_iotivity_base_OcRepresentation
* Method: addChild
......@@ -1037,4 +1021,4 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_dispose
{
delete rep;
}
}
\ No newline at end of file
}
......@@ -619,14 +619,6 @@ extern "C" {
JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation3DArray
(JNIEnv *, jobject, jstring, jobjectArray);
/*
* Class: org_iotivity_base_OcRepresentation
* Method: getJSONRepresentation
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getJSONRepresentation
(JNIEnv *, jobject);
/*
* Class: org_iotivity_base_OcRepresentation
* Method: addChild
......@@ -766,4 +758,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif
#endif
\ No newline at end of file
#endif
......@@ -121,6 +121,9 @@ def __install_lib(ienv, lib):
SConscript('tools/UnpackAll.py')
# tinycbor build/fetch
SConscript(os.path.join(env.get('SRC_DIR'), 'extlibs', 'tinycbor', 'SConscript'))
env.AddMethod(__prepare_lib, "PrepareLib")
env.AddMethod(__configure, "Configure")
env.AddMethod(__download, "Download")
......
......@@ -235,7 +235,7 @@ LineResult LineInput::processGet(elements_t& elems, stringstream& ss)
return LR_Timeout;
}
std::string jsonRep = wreq->m_rep.getJSONRepresentation();
std::string jsonRep ;//= wreq->m_rep.getJSONRepresentation();
//ss << jsonRep << endl;
printJSONAsTable(jsonRep);
return LR_OK;
......@@ -356,7 +356,7 @@ void LineInput::obsCB(token_t token, const HeaderOptions& headerOptions, const O
if (!m_observer)
return;
cout << "cb " << eCode << " " << sequenceNumber << '\n';
cout << rep.getJSONRepresentation() << "\n";
//cout << rep.getJSONRepresentation() << "\n";
}
ParseState LineInput::finishElem(char*& e, elements_t& elems)
......
......@@ -164,7 +164,7 @@ void WrapResource::parseJSON(WrapRequest *wreq)
{
string sep = "\":";
string anchor = "\"rep\":{";
string json = wreq->m_rep.getJSONRepresentation();
string json;// = wreq->m_rep.getJSONRepresentation();
string name, type, value, next;
size_t r, e, e1, s, c;
......
......@@ -7,15 +7,6 @@ cd "$(dirname "$0")"
EXTDIR=$(pwd)
# Check for cereal existence
if [ ! -d "cereal" ]; then
git clone https://github.com/USCiLab/cereal.git cereal
pushd cereal
git reset --hard 7121e91e6ab8c3e6a6516d9d9c3e6804e6f65245
git apply ../../resource/patches/cereal_gcc46.patch
popd
fi
# Pick the preferred version of boost to use
BOOST_MAJOR=1
BOOST_MINOR=57
......@@ -44,8 +35,8 @@ function buildBoost {
if [ ! -d "boost" ]; then
cloneBoost
fi
# Determine the
# Determine the
TOOLCHAIN=${ANDROID_NDK}/toolchains/${TOOLSET}-${VERSION}/prebuilt/${HOST_ARCH}/bin
OLDPATH=$PATH
......
######################################################################
# Cereal library build script
#
# Only 'hpp' is used by Iotivity, it's unnecessary to build it
######################################################################
import os
Import('env')
src_dir = env.get('SRC_DIR')
# In the pass, cereal library is in extlibs/cereal, according to external
# library management rule, cereal should be put in extlibs/cereal/cereal.
# jenkins of gerrit server, still follow the old, to avoid jenkins fail
# both places are handled.
old = os.path.join(src_dir, 'extlibs', 'cereal', 'include')
cur = os.path.join(src_dir, 'extlibs', 'cereal', 'cereal', 'include')
# check 'cereal' library, if it doesn't exits, ask user to download it
if not os.path.exists(old) and not os.path.exists(cur):
cereal_env = Environment(ENV = os.environ)
c = cereal_env.Action(['git clone https://github.com/USCiLab/cereal.git cereal',
'cd cereal && git reset --hard 7121e91e6ab8c3e6a6516d9d9c3e6804e6f65245 && git apply ../../../resource/patches/cereal_gcc46.patch',
])
print 'Downloading cereal library ...'
if cereal_env.Execute(c):
print '''
*********************************** Error: ************************************
* Please download cereal and apply the patch as following: *
* $ git clone https://github.com/USCiLab/cereal.git extlibs/cereal/cereal *
* $ cd extlibs/cereal/cereal *
* $ git reset --hard 7121e91e6ab8c3e6a6516d9d9c3e6804e6f65245 *
* $ git apply ../../../resource/patches/cereal_gcc46.patch *
*******************************************************************************
'''
Exit(1)
else:
print 'Download cereal library complete'
env.AppendUnique(CPPPATH = [old, cur])
#******************************************************************
#
# Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
import os
Import('env')
src_dir = env.get('SRC_DIR')
cborDir = os.path.join(src_dir, 'extlibs','tinycbor','tinycbor')
if not os.path.exists(cborDir):
print '''
*********************************** Error: ****************************************
* Please download cbor using the following command: *
* $ git clone https://github.com/01org/tinycbor.git extlibs/tinycbor/tinycbor *
***********************************************************************************
'''
Exit(1)
cbor_src = [
os.path.join(cborDir,'src/cborparser.c'),
os.path.join(cborDir,'src/cborencoder.c')
]
env['cbor_files'] = cbor_src
env.AppendUnique(CPPPATH = [os.path.join(cborDir, 'src')])
......@@ -30,5 +30,3 @@ Import('env')
target_os = env.get('TARGET_OS')
target_arch = env.get('TARGET_ARCH')
src_dir = env.get('SRC_DIR')
env.SConscript('extlibs/cereal/SConscript')
......@@ -20,7 +20,7 @@ mkdir ./tmp/extlibs/
mkdir ./tmp/packaging
cp -R ./build_common $sourcedir/tmp
cp -R ./examples $sourcedir/tmp
cp -R ./extlibs/cereal $sourcedir/tmp/extlibs
cp -R ./extlibs/tinycbor $sourcedir/tmp/extlibs
cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
cp -R ./extlibs/timer $sourcedir/tmp/extlibs
......@@ -35,7 +35,7 @@ cp ./tools/tizen/.gbs.conf ./tmp
cd $sourcedir/tmp
echo `pwd`
rm -rf ./extlibs/cereal/cereal/.git*
rm -rf ./extlibs/tinycbor/tinycbor/.git*
# Initialize Git repository
if [ ! -d .git ]; then
......
......@@ -67,6 +67,26 @@ extern "C"
*/
void *OICMalloc(size_t size);
/**
* Re-allocates a block of memory, pointed to by ptr to the size specified
* in size. The returned value contains a pointer to the new location, with
* all data copied into it. If the new size of the memory-object require movement,
* the previous space is freed. If the new size is larger, the newly allocated
* area has non-deterministic content. If the space cannot be allocated, the value
* ptr is left unchanged.
*
* @param ptr - Pointer to a block of memory previously allocated by OICCalloc,
* OICMalloc, or a previous call to this function. If this value is
* NULL, this function will work identically to a call to OICMalloc.
*
* @param size - Size of the new memory block in bytes, where size > 0
*
* @return
* on success, a pointer to the newly sized memory block
* on failure, a null pointer is returned, and the memory pointed to by *ptr is untouched
*/
void *OICRealloc(void *ptr, size_t size);
/**
* Allocates a block of memory for an array of num elements, each of them
* size bytes long and initializes all its bits to zero.
......@@ -86,7 +106,7 @@ void *OICCalloc(size_t num, size_t size);
* NOTE: This function is intended to be used internally by the TB Stack.
* It is not intended to be used by applications.
*
* @param ptr - Pointer to block of memory previously allocated by OCMalloc.
* @param ptr - Pointer to block of memory previously allocated by OICMalloc.
* If ptr is a null pointer, the function does nothing.
*/
void OICFree(void *ptr);
......
......@@ -98,6 +98,29 @@ void *OICCalloc(size_t num, size_t size)
#endif
}
void *OICRealloc(void* ptr, size_t size)
{
if(size == 0)
{
OICFree(ptr);
return NULL;
}
#ifdef ENABLE_MALLOC_DEBUG
if(ptr == NULL)
{
return OICMalloc(size);
}
void* newptr = NULL;
newptr = realloc(ptr, size);
OIC_LOG_V(INFO, TAG, "realloc: ptr=%p, newptr=%p, size=%u", ptr, newptr, size);
return ptr;
#else
return realloc(ptr, size);
#endif
}
void OICFree(void *ptr)
{
#ifdef ENABLE_MALLOC_DEBUG
......
......@@ -102,6 +102,9 @@ liboctbstack_src = [
'../../extlibs/cjson/cJSON.c',
'../../extlibs/timer/timer.c',
OCTBSTACK_SRC + 'ocstack.c',
OCTBSTACK_SRC + 'ocpayload.c',
OCTBSTACK_SRC + 'ocpayloadparse.c',
OCTBSTACK_SRC + 'ocpayloadconvert.c',
OCTBSTACK_SRC + 'occlientcb.c',
OCTBSTACK_SRC + 'ocresource.c',
OCTBSTACK_SRC + 'ocobserve.c',
......@@ -112,6 +115,8 @@ liboctbstack_src = [
'ocrandom/src/ocrandom.c'
]
liboctbstack_src.extend(env['cbor_files'])
if target_os in ['arduino','darwin','ios'] :
static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
......
......@@ -98,7 +98,7 @@ extern "C"
/**
* @brief Payload information from resource model
*/
typedef char *CAPayload_t;
typedef uint8_t *CAPayload_t;
/**
* @brief URI for the OIC base.CA considers relative URI as the URI.
......@@ -303,6 +303,7 @@ typedef struct
CAHeaderOption_t *options; /** Header Options for the request */
uint8_t numOptions; /**< Number of Header options */
CAPayload_t payload; /**< payload of the request */
size_t payloadSize; /**< size in bytes of the payload */
CAURI_t resourceUri; /**< Resource URI information **/
} CAInfo_t;
......
......@@ -115,7 +115,7 @@ CARequestInfo_t *CACloneRequestInfo(const CARequestInfo_t *rep)
if (NULL != rep->info.payload)
{
// allocate payload field
char *temp = OICStrdup(rep->info.payload);
uint8_t *temp = OICMalloc(rep->info.payloadSize);
if (NULL == temp)
{
OIC_LOG(ERROR, TAG, "CACloneRequestInfo Out of memory");
......@@ -124,6 +124,7 @@ CARequestInfo_t *CACloneRequestInfo(const CARequestInfo_t *rep)
return NULL;
}
memcpy(temp, rep->info.payload, rep->info.payloadSize);
// save the payload
clone->info.payload = temp;
......@@ -242,7 +243,7 @@ CAResponseInfo_t *CACloneResponseInfo(const CAResponseInfo_t *rep)
if (NULL != rep->info.payload)
{
// allocate payload field
char *temp = OICStrdup(rep->info.payload);
uint8_t *temp = (uint8_t *) OICMalloc(rep->info.payloadSize);
if (NULL == temp)
{
OIC_LOG(ERROR, TAG, "CACloneResponseInfo Out of memory");
......@@ -251,6 +252,7 @@ CAResponseInfo_t *CACloneResponseInfo(const CAResponseInfo_t *rep)
return NULL;
}
memcpy(temp, rep->info.payload, rep->info.payloadSize);
// save the payload
clone->info.payload = temp;
......
......@@ -94,7 +94,7 @@ CAResult_t CAGetErrorInfoFromPDU(const coap_pdu_t *pdu, CAErrorInfo_t *errorInfo
* @return generated pdu
*/
coap_pdu_t *CAGeneratePDUImpl(code_t code, coap_list_t *options, const CAInfo_t *info,
const char *payload, size_t payloadSize);
const uint8_t *payload, size_t payloadSize);
/**
* @brief parse the URI and creates the options
......
......@@ -276,7 +276,7 @@ int coap_add_data(coap_pdu_t *pdu, unsigned int len, const unsigned char *data)
return 1;
}
int coap_get_data(coap_pdu_t *pdu, size_t *len, unsigned char **data)
int coap_get_data(const coap_pdu_t *pdu, size_t *len, unsigned char **data)
{
assert(pdu);
assert(len);
......
......@@ -346,6 +346,6 @@ int coap_add_data(coap_pdu_t *pdu, unsigned int len, const unsigned char *data);
* or 1 if *len and *data have correct values. Note that these values are
* destroyed with the pdu.
*/
int coap_get_data(coap_pdu_t *pdu, size_t *len, unsigned char **data);
int coap_get_data(const coap_pdu_t *pdu, size_t *len, unsigned char **data);
#endif /* _PDU_H_ */
......@@ -432,7 +432,7 @@ void SendRequestAll()
CAInfo_t requestData = {CA_MSG_RESET};
requestData.token = token;
requestData.tokenLength = tokenLength;
requestData.payload = "Temp Json Payload";
requestData.payload = (CAPayload_t)"Temp Json Payload";
requestData.type = CA_MSG_NONCONFIRM;
requestData.resourceUri = (char *)OICMalloc(strlen(resourceUri) + 1);
strcpy(requestData.resourceUri, resourceUri);
......@@ -704,7 +704,7 @@ void RequestHandler(const CAEndpoint_t *object, const CARequestInfo_t *requestIn
Serial.print("uri: ");
Serial.println(requestInfo->info.resourceUri);
Serial.print("data: ");
Serial.println(requestInfo->info.payload);
Serial.println((char*)requestInfo->info.payload);
Serial.print("Type: ");
Serial.println(requestInfo->info.type);
......@@ -739,7 +739,7 @@ void ResponseHandler(const CAEndpoint_t *object, const CAResponseInfo_t *respons
Serial.print("uri: ");
Serial.println(responseInfo->info.resourceUri);
Serial.print("data: ");
Serial.println(responseInfo->info.payload);
Serial.println((char*)responseInfo->info.payload);
Serial.print("Type: ");
Serial.println(responseInfo->info.type);
Serial.print("res result=");
......@@ -765,7 +765,7 @@ void ErrorHandler(const CAEndpoint_t *rep, const CAErrorInfo_t* errorInfo)
Serial.print("resourceUri: ");
Serial.println(info->resourceUri);
Serial.print("payload: ");
Serial.println(info->payload);
Serial.println((char*)info->payload);
}
return;
......@@ -838,7 +838,7 @@ void SendResponse(CAEndpoint_t *endpoint, const CAInfo_t* info)
{
responseData.token = (info != NULL) ? info->token : NULL;
responseData.tokenLength = (info != NULL) ? info->tokenLength : 0;
responseData.payload = static_cast<CAPayload_t>("response payload");
responseData.payload = reinterpret_cast<CAPayload_t>(const_cast<char*>("response payload"));
}
CAResponseInfo_t responseInfo = {CA_BAD_REQ, {CA_MSG_RESET}};
responseInfo.result = static_cast<CAResponseResult_t>(respCode);
......
......@@ -368,10 +368,6 @@ static void CAReceivedPacketCallback(const CAEndpoint_t *endpoint, void *data, u
}
}
if (NULL != ReqInfo->info.payload)
{
OIC_LOG_V(DEBUG, TAG, "Request- payload: %s", ReqInfo->info.payload);
}
OIC_LOG_V(DEBUG, TAG, "Request- code: %d", ReqInfo->method);
if (NULL != ReqInfo->info.token)
{
......@@ -379,6 +375,7 @@ static void CAReceivedPacketCallback(const CAEndpoint_t *endpoint, void *data, u
OIC_LOG_BUFFER(DEBUG, TAG, (const uint8_t *) ReqInfo->info.token,
ReqInfo->info.tokenLength);
}
OIC_LOG_V(DEBUG, TAG, "Request- msgID : %d", ReqInfo->info.messageId);
// store the data at queue.
CAData_t *cadata = NULL;
......@@ -429,7 +426,8 @@ static void CAReceivedPacketCallback(const CAEndpoint_t *endpoint, void *data, u
if (NULL != ResInfo->info.payload)
{
OIC_LOG_V(DEBUG, TAG, "Response- payload: %s", ResInfo->info.payload);
OIC_LOG_V(DEBUG, TAG, "Response- payload: %p(%u) from %s", ResInfo->info.payload,
ResInfo->info.payloadSize, endpoint->addr);
}
OIC_LOG_V(DEBUG, TAG, "Response- code: %d", ResInfo->result);
if (NULL != ResInfo->info.token)
......
......@@ -188,8 +188,7 @@ coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info)
coap_delete_list(optlist);
return NULL;
}
size_t lenPayload = info->payload ? strlen(info->payload) : 0;
pdu = CAGeneratePDUImpl((code_t)code, optlist, info, info->payload, lenPayload);
pdu = CAGeneratePDUImpl((code_t)code, optlist, info, info->payload, info->payloadSize);
if (NULL == pdu)
{
OIC_LOG(ERROR, TAG, "pdu NULL");
......@@ -240,7 +239,7 @@ coap_pdu_t *CAParsePDU(const char *data, uint32_t length, uint32_t *outCode)
}
coap_pdu_t *CAGeneratePDUImpl(code_t code, coap_list_t *options, const CAInfo_t *info,
const char *payload, size_t payloadSize)
const uint8_t *payload, size_t payloadSize)
{
OIC_LOG(DEBUG, TAG, "IN");
VERIFY_NON_NULL_RET(info, TAG, "info is NULL", NULL);
......@@ -300,7 +299,6 @@ coap_pdu_t *CAGeneratePDUImpl(code_t code, coap_list_t *options, const CAInfo_t
if (NULL != payload)
{
OIC_LOG_V(DEBUG, TAG, "add data, payload:%s", payload);
coap_add_data(pdu, payloadSize, (const unsigned char *) payload);
}
......@@ -716,11 +714,12 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, uint32_t *outCode, CAInfo_t *
outInfo->tokenLength = pdu->hdr->token_length;
// set payload data
if (NULL != pdu->data)
size_t dataSize;
uint8_t *data;
if (coap_get_data(pdu, &dataSize, &data))
{
uint32_t payloadLength = strlen((char*) pdu->data);
OIC_LOG(DEBUG, TAG, "inside pdu->data");
outInfo->payload = (char *) OICMalloc(payloadLength + 1);
outInfo->payload = (uint8_t *) OICMalloc(dataSize);
if (NULL == outInfo->payload)
{
OIC_LOG(ERROR, TAG, "Out of memory");
......@@ -728,8 +727,8 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, uint32_t *outCode, CAInfo_t *
OICFree(outInfo->token);
return CA_MEMORY_ALLOC_FAILED;
}
memcpy(outInfo->payload, pdu->data, payloadLength);
outInfo->payload[payloadLength] = '\0';
memcpy(outInfo->payload, pdu->data, dataSize);
outInfo->payloadSize = dataSize;
}
uint32_t length = strlen(optionResult);
......
......@@ -265,7 +265,8 @@ TEST(SendRequestTest, DISABLED_TC_16_Positive_01)
CADestroyToken(tempToken);
FAIL() << "requestData.payload allocation failed";
}
snprintf(requestData.payload, length, NORMAL_INFO_DATA, "a/light");
snprintf((char*)requestData.payload, length, NORMAL_INFO_DATA, "a/light");
requestData.payloadSize = length + 1;
requestData.type = CA_MSG_NONCONFIRM;
memset(&requestInfo, 0, sizeof(CARequestInfo_t));
......@@ -308,7 +309,9 @@ TEST(SendResponseTest, DISABLED_TC_19_Positive_01)
memset(&responseData, 0, sizeof(CAInfo_t));
responseData.type = CA_MSG_NONCONFIRM;
responseData.messageId = 1;
responseData.payload = (char *) "response payload";
responseData.payload = (CAPayload_t)malloc(sizeof("response payload"));
memcpy(responseData.payload, "response payload", sizeof("response payload"));