}
}
#endif
+
+#ifndef WITH_ARDUINO
+void CALogAdapterStateInfo(CATransportAdapter_t adapter, CANetworkStatus_t state)
+{
+ OIC_LOG(DEBUG, CA_ADAPTER_UTILS_TAG, "CALogAdapterStateInfo");
+ OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
+ CALogAdapterTypeInfo(adapter);
+ if (CA_INTERFACE_UP == state)
+ {
+ OIC_LOG(DEBUG, ANALYZER_TAG, "adapter status is changed to CA_INTERFACE_UP");
+ }
+ else
+ {
+ OIC_LOG(DEBUG, ANALYZER_TAG, "adapter status is changed to CA_INTERFACE_DOWN");
+ }
+ OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
+}
+
+void CALogSendStateInfo(CATransportAdapter_t adapter,
+ const char *addr, uint16_t port, ssize_t sentLen,
+ bool isSuccess, const char* message)
+{
+ OIC_LOG(DEBUG, CA_ADAPTER_UTILS_TAG, "CALogSendStateInfo");
+ OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
+
+ if (true == isSuccess)
+ {
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "Send Success, sent length = [%d]", sentLen);
+ }
+ else
+ {
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "Send Failure, error message = [%s]",
+ message != NULL ? message : "no message");
+ }
+
+ CALogAdapterTypeInfo(adapter);
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "Address = [%s]:[%d]", addr, port);
+ OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
+}
+
+void CALogAdapterTypeInfo(CATransportAdapter_t adapter)
+{
+ switch(adapter)
+ {
+ case CA_ADAPTER_IP:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Transport Type = [OC_ADAPTER_IP]");
+ break;
+ case CA_ADAPTER_TCP:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Transport Type = [OC_ADAPTER_TCP]");
+ break;
+ case CA_ADAPTER_GATT_BTLE:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Transport Type = [OC_ADAPTER_GATT_BTLE]");
+ break;
+ case CA_ADAPTER_RFCOMM_BTEDR:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Transport Type = [OC_ADAPTER_RFCOMM_BTEDR]");
+ break;
+ default:
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "Transport Type = [%d]", adapter);
+ break;
+ }
+}
+#endif
static bool CADropSecondMessage(CAHistory_t *history, const CAEndpoint_t *endpoint, uint16_t id,
CAToken_t token, uint8_t tokenLength);
+/**
+ * print send / receive message of CoAP.
+ * @param[in] data CA information which has send/receive message and endpoint.
+ * @param[in] pdu CoAP pdu low data.
+ */
+static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu);
+
#ifdef WITH_BWT
void CAAddDataToSendThread(CAData_t *data)
{
}
#endif // WITH_BWT
- CALogPDUInfo(pdu, data->remoteEndpoint);
+ CALogPDUInfo(data, pdu);
res = CASendMulticastData(data->remoteEndpoint, pdu->transport_hdr, pdu->length, data->dataType);
if (CA_STATUS_OK != res)
}
}
#endif // WITH_BWT
- CALogPDUInfo(pdu, data->remoteEndpoint);
+ CALogPDUInfo(data, pdu);
OIC_LOG_V(INFO, TAG, "CASendUnicastData type : %d", data->dataType);
res = CASendUnicastData(data->remoteEndpoint, pdu->transport_hdr, pdu->length, data->dataType);
VERIFY_NON_NULL_VOID(sep, TAG, "remoteEndpoint");
VERIFY_NON_NULL_VOID(data, TAG, "data");
- OIC_LOG(DEBUG, TAG, "received pdu data :");
- OIC_LOG_BUFFER(DEBUG, TAG, data, dataLen);
-
uint32_t code = CA_NOT_FOUND;
CAData_t *cadata = NULL;
if (NULL == pdu)
{
OIC_LOG(ERROR, TAG, "Parse PDU failed");
- return;
+ goto exit;
}
OIC_LOG_V(DEBUG, TAG, "code = %d", code);
{
OIC_LOG(ERROR, TAG, "CAReceivedPacketCallback, CAGenerateHandlerData failed!");
coap_delete_pdu(pdu);
- return;
+ goto exit;
}
}
else
{
OIC_LOG(ERROR, TAG, "CAReceivedPacketCallback, CAGenerateHandlerData failed!");
coap_delete_pdu(pdu);
- return;
+ goto exit;
}
#ifdef WITH_TCP
cadata->type = SEND_TYPE_UNICAST;
+ CALogPDUInfo(cadata, pdu);
+
#ifdef SINGLE_THREAD
CAProcessReceivedData(cadata);
#else
#endif // SINGLE_THREAD
coap_delete_pdu(pdu);
+
+exit:
+ OIC_LOG(DEBUG, TAG, "received pdu data :");
+ OIC_LOG_BUFFER(DEBUG, TAG, data, dataLen);
}
void CAHandleRequestResponseCallbacks()
#endif // SINGLE_THREAD
}
-void CALogPDUInfo(coap_pdu_t *pdu, const CAEndpoint_t *endpoint)
-{
- VERIFY_NON_NULL_VOID(pdu, TAG, "pdu");
- VERIFY_NON_NULL_VOID(endpoint, TAG, "endpoint");
-
-#ifdef WITH_BWT
- if (CAIsSupportedBlockwiseTransfer(endpoint->adapter))
- {
- OIC_LOG_V(DEBUG, TAG, "PDU Maker - type : %d", pdu->transport_hdr->udp.type);
-
- OIC_LOG_V(DEBUG, TAG, "PDU Maker - code : %d", pdu->transport_hdr->udp.code);
- }
-#endif
-
- OIC_LOG(DEBUG, TAG, "PDU Maker - token :");
- OIC_LOG_BUFFER(DEBUG, TAG, pdu->transport_hdr->udp.token,
- pdu->transport_hdr->udp.token_length);
-
- OIC_LOG(DEBUG, TAG, "PDU Maker - payload :");
- OIC_LOG_BUFFER(DEBUG, TAG, (const uint8_t *) pdu->transport_hdr, pdu->length);
-}
-
static void CALogPayloadInfo(CAInfo_t *info)
{
if (info)
#endif
OIC_LOG(DEBUG, TAG, "CASendErrorInfo OUT");
}
+
+#ifndef ARDUINO
+static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu)
+{
+ OIC_LOG(DEBUG, TAG, "CALogPDUInfo");
+
+ VERIFY_NON_NULL_VOID(data, TAG, "data");
+ VERIFY_NON_NULL_VOID(pdu, TAG, "pdu");
+
+ OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
+ if(SEND_TYPE_MULTICAST == data->type)
+ {
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Is Multicast = true");
+ }
+ else
+ {
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Is Multicast = false");
+ }
+
+ if (NULL != data->remoteEndpoint)
+ {
+ CALogAdapterTypeInfo(data->remoteEndpoint->adapter);
+ OIC_LOG(DEBUG, ANALYZER_TAG, "-------------------------------------------------");
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "Address = [%s]:[%d]", data->remoteEndpoint->addr,
+ data->remoteEndpoint->port);
+ OIC_LOG(DEBUG, ANALYZER_TAG, "-------------------------------------------------");
+ }
+
+ switch(data->dataType)
+ {
+ case CA_REQUEST_DATA:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Data Type = [CA_REQUEST_DATA]");
+ break;
+ case CA_RESPONSE_DATA:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Data Type = [CA_RESPONSE_DATA]");
+ break;
+ case CA_ERROR_DATA:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Data Type = [CA_ERROR_DATA]");
+ break;
+ case CA_RESPONSE_FOR_RES:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Data Type = [CA_RESPONSE_FOR_RES]");
+ break;
+ default:
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "Data Type = [%d]", data->dataType);
+ break;
+ }
+ OIC_LOG(DEBUG, ANALYZER_TAG, "-------------------------------------------------");
+
+ const CAInfo_t *info = NULL;
+ if (NULL != data->requestInfo)
+ {
+ switch(data->requestInfo->method)
+ {
+ case CA_GET:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Method = [GET]");
+ break;
+ case CA_POST:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Method = [POST]");
+ break;
+ case CA_PUT:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Method = [PUT]");
+ break;
+ case CA_DELETE:
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Method = [DELETE]");
+ break;
+ default:
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "Method = [%d]", data->requestInfo->method);
+ break;
+ }
+ info = &data->requestInfo->info;
+ }
+
+ if (NULL != data->responseInfo)
+ {
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "result code = [%d]", data->responseInfo->result);
+ info = &data->responseInfo->info;
+ }
+
+ if (pdu->transport_hdr)
+ {
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "Msg ID = [%d]", pdu->transport_hdr->udp.id);
+ }
+
+ if (info)
+ {
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Coap Token");
+ OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG, (const uint8_t *) info->token, info->tokenLength);
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "Res URI = [%s]", info->resourceUri);
+ OIC_LOG(DEBUG, ANALYZER_TAG, "-------------------------------------------------");
+
+ if (CA_FORMAT_APPLICATION_CBOR == info->payloadFormat)
+ {
+ OIC_LOG(DEBUG, ANALYZER_TAG, "Payload Format = [CA_FORMAT_APPLICATION_CBOR]");
+ }
+ else
+ {
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "Payload Format = [%d]", info->payloadFormat);
+ }
+
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Message Full Size = [%d]", pdu->length);
+ OIC_LOG(DEBUG, ANALYZER_TAG, "CoAP Header (+ 0xFF)");
+ OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG, (const uint8_t *) pdu->transport_hdr,
+ pdu->length - info->payloadSize);
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Header size = [%d]", pdu->length - info->payloadSize);
+
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Payload");
+ OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG, info->payload, info->payloadSize);
+ OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Payload Size = [%d]", info->payloadSize);
+ }
+
+ OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
+}
+#else
+static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu)
+{
+ VERIFY_NON_NULL_VOID(pdu, TAG, "pdu");
+ (void)data;
+
+ OIC_LOG_V(DEBUG, TAG, "PDU Maker - payload : %s", pdu->data);
+ OIC_LOG_V(DEBUG, TAG, "PDU Maker - type : %d", pdu->transport_hdr->udp.type);
+ OIC_LOG_V(DEBUG, TAG, "PDU Maker - code : %d", pdu->transport_hdr->udp.code);
+ OIC_LOG(DEBUG, TAG, "PDU Maker - token :");
+ OIC_LOG_BUFFER(DEBUG, TAG, pdu->transport_hdr->udp.token,
+ pdu->transport_hdr->udp.token_length);
+}
+#endif