My project is based on the Thread cloud coap client example. I would like to know if my CoAP POSTs to the cloud are successful.
I added a "post_response_handler" to the SendRequest:
//error = otCoapSendRequest(p_instance, p_request, &message_info, NULL, NULL);
error = otCoapSendRequest(p_instance, p_request, &message_info, post_response_handler, NULL); //added response handler
The post_response_handler is firing after a successful post, but I can't figure out how to extract the coap response code (typedef enum otCoapCode) from the message. Here's what I have so far. Any help would be greatly appreciated.
static void post_response_handler( void * p_context,
otCoapHeader * p_header,
otMessage * p_message,
const otMessageInfo * p_message_info,
otError result)
{
(void)p_context;
(void)p_header;
// restore the polling period back to initial slow value
UNUSED_VARIABLE(poll_period_restore(thread_ot_instance_get()));
UNUSED_VARIABLE(otMessageRead(p_message,
otMessageGetOffset(p_message),
&???????.???????,
sizeof(?????????.???????))
);
NRF_LOG_INFO("CoAP code: %d\r\n", &????????.???????);
}