}
}
#endif
- CALogPDUInfo(pdu);
+ }
+ else
+ {
+ OIC_LOG(ERROR,TAG,"Failed to generate multicast PDU");
+ CASendErrorInfo(data->remoteEndpoint, info, CA_SEND_FAILED);
+ return CA_SEND_FAILED;
+ }
+ }
+ else if (NULL != data->responseInfo)
+ {
+ OIC_LOG(DEBUG, TAG, "responseInfo is available..");
- res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
- if (CA_STATUS_OK != res)
+ info = &data->responseInfo->info;
+ pdu = CAGeneratePDU(data->responseInfo->result, info, data->remoteEndpoint);
+
+ if (NULL != pdu)
+ {
+#ifdef WITH_BWT
+ if (CA_ADAPTER_GATT_BTLE != data->remoteEndpoint->adapter)
{
- OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
- CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
- coap_delete_pdu(pdu);
- return res;
+ // Blockwise transfer
+ if (NULL != info)
+ {
+ CAResult_t res = CAAddBlockOption(&pdu, *info,
+ data->remoteEndpoint);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(INFO, TAG, "to write block option has failed");
+ CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
+ coap_delete_pdu(pdu);
+ return res;
+ }
+ }
}
-
- coap_delete_pdu(pdu);
+#endif
}
else
{
}
else
{
- OIC_LOG(ERROR, TAG, "request info is empty");
+ OIC_LOG(ERROR, TAG, "request or response info is empty");
return CA_SEND_FAILED;
}
+
+ CALogPDUInfo(pdu);
+
+ res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
+ CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
+ coap_delete_pdu(pdu);
+ return res;
+ }
+
+ coap_delete_pdu(pdu);
}
- OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
return NULL;
}
- cadata->type = SEND_TYPE_UNICAST;
+ cadata->type = response->isMulticast ? SEND_TYPE_MULTICAST : SEND_TYPE_UNICAST;
cadata->responseInfo = response;
}
else
// Put the JSON prefix and suffix around the payload
if(ehResponse->payload)
{
+ if (ehResponse->payload->type == PAYLOAD_TYPE_PRESENCE)
+ {
+ responseInfo.isMulticast = true;
+ }
+ else
+ {
+ responseInfo.isMulticast = false;
+ }
+
OCStackResult result;
if((result = OCConvertPayload(ehResponse->payload, &responseInfo.info.payload,
&responseInfo.info.payloadSize))
}
else
{
+ responseInfo.isMulticast = false;
responseInfo.info.payload = NULL;
responseInfo.info.payloadSize = 0;
}
// check for multiicast presence
CAEndpoint_t ep = { .adapter = endpoint->adapter,
.flags = endpoint->flags };
- OICStrcpy(ep.addr, sizeof(ep.addr), OC_MULTICAST_IP);
- ep.port = OC_MULTICAST_PORT;
uriLen = FormCanonicalPresenceUri(&ep, OC_RSRVD_PRESENCE_URI, presenceUri);
presenceState = OC_PRESENCE_INITIALIZED;
OCDevAddr devAddr = { OC_DEFAULT_ADAPTER };
- OICStrcpy(devAddr.addr, sizeof(devAddr.addr), OC_MULTICAST_IP);
- devAddr.port = OC_MULTICAST_PORT;
CAToken_t caToken = NULL;
CAResult_t caResult = CAGenerateToken(&caToken, tokenLength);