Remove the magic number 4 in the CA branch code.
Change-Id: I6fdc81e5a06a2ebdca5245bbf056f5a3d6f36ed4
Signed-off-by: Sakthivel Samidurai <sakthivel.samidurai@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/162
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sashi Penta <sashi.kumar.penta@intel.com>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
// TODO-CA: COAP_OPTION_OBSERVE is defined in CoAP header files which will be abstracted
// from resource model. We have to define a new macro for this in the stack layer.
tmpHdrOpt[0].optionID = COAP_OPTION_OBSERVE;
- // Length is one byte
- tmpHdrOpt[0].optionLength = 1;
+ tmpHdrOpt[0].optionLength = sizeof(uint32_t);
tmpHdrOpt[0].optionData[0] = observeFlag;
for (uint8_t i = 0; i < numOptions; i++)
{
{
responseInfo.info.options[0].protocolID = CA_COAP_ID;
responseInfo.info.options[0].optionID = COAP_OPTION_OBSERVE;
- // TODO-CA Remove the magic number 4
- responseInfo.info.options[0].optionLength = 4;
- memcpy(responseInfo.info.options[0].optionData, &(serverRequest->observationOption), 4);
+ responseInfo.info.options[0].optionLength = sizeof(uint32_t);
+ memcpy(responseInfo.info.options[0].optionData,
+ &(serverRequest->observationOption), sizeof(uint32_t));
// Point to the next header option before copying vender specific header options
optionsPointer += 1;
if(responseInfo->info.numOptions > 0)
{
int start = 0;
- //First option alwas with option ID COAP_OPTION_OBSERVE if it is availbale
+ //First option always with option ID is COAP_OPTION_OBSERVE if it is available.
if(responseInfo->info.options[0].optionID == COAP_OPTION_OBSERVE)
{
memcpy (&(response.sequenceNumber),
- &(responseInfo->info.options[0].optionData), 4);
+ &(responseInfo->info.options[0].optionData), sizeof(uint32_t));
response.numRcvdVendorSpecificHeaderOptions = responseInfo->info.numOptions - 1;
start = 1;
}