I am using:
NCS 3.0.1
nRF52840DK
My project is based on the coap_client sample, currently running on a nRF52840DK. I have modified it to add the 'observe' option in the request to the server. The response handler is invoked when the server responds to the original request. However, the client returns a Reset message to later notifications from the server, and does not invoke the response handler.
I have implemented observer functionality on the client using NCS 2.4.1, and when I compile this project for NCS 2.4.1, the client sends an ACK to the server when it receives a notifications.
The server is implemented on a Raspberry Pi (with OTBR) using libcoap.
In prf.conf
static void send_dustsensor_request(struct k_work *item) { ARG_UNUSED(item); LOG_INF("Send 'dustsensor' GET request \r\n"); if (g_server_addr.mFields.m8[0] == 0) { LOG_WRN("Peer address not set. Can't send dustsensor get"); return; } poll_period_response_set(); ot_coap_send_request(OT_COAP_CODE_GET, &g_server_addr, dustsensor_option, (uint8_t *)&g_eui64, sizeof(g_eui64), on_dustsensor_reply, 1, 0); // observe } otError ot_coap_send_request(enum otCoapCode code, otIp6Address *addr,const char *uri_path, uint8_t *payload, uint16_t payload_size, otCoapResponseHandler reply_cb, bool observe_option, uint32_t observe_flag) { otError error = OT_ERROR_NO_BUFS; otMessage *request; otInstance *instance; otMessageInfo message_info; instance = openthread_get_default_instance(); request = otCoapNewMessage(instance, NULL); if (request == NULL) { goto end; } memset(&message_info, 0, sizeof(otMessageInfo)); memcpy(&(message_info.mPeerAddr), addr, sizeof(otIp6Address)); message_info.mPeerPort = OT_DEFAULT_COAP_PORT; otCoapMessageInit(request, OT_COAP_TYPE_CONFIRMABLE, code); otCoapMessageGenerateToken(request, 8); // Options, must be in ascending order of option number if ((code == OT_COAP_CODE_GET) && observe_option) { //error = otCoapMessageAppendUintOption(request, OT_COAP_OPTION_OBSERVE, observe_flag); error = otCoapMessageAppendObserveOption(request, observe_flag); if (error != OT_ERROR_NONE) LOG_ERR("otCoapMessageAppendUintOption() returned %d", error); } error = otCoapMessageAppendUriPathOptions(request, uri_path); // otCoapMessageAppendContentFormatOption(request, OT_COAP_OPTION_CONTENT_FORMAT_TEXT_PLAIN); // Payload error = otCoapMessageSetPayloadMarker(request); if (error != OT_ERROR_NONE) { goto end; } if (payload != NULL) { error = otMessageAppend(request, payload, payload_size); if (error != OT_ERROR_NONE) { goto end; } } otCoapTxParameters txParms; txParms.mAckRandomFactorDenominator = 1.0; error = otCoapSendRequest(instance, request, &message_info, reply_cb, NULL); LOG_INF("otCoapSendRequest() returned %d\r\n", error); end: if (error != OT_ERROR_NONE && request != NULL) { otMessageFree(request); } if (error == OT_ERROR_NO_BUFS) g_reboot = true; return error; }
Frame 1458: original request from client
Frame 1460: server response
Frame 1469: Server notification
Frame 1471: RST from client
How do I get debug log output from ot:coap? I've included the 'debug' snippet, and the 'logging' snippet, but am not seeing an low level debug output.