Hello Support
I have a question about the function " uint16_t otCoapMessageGetMessageId(const otMessage *aMessage); ". I need to know the message ID for my application.
On client side:
I send some multicast messages from CoAP clients to servers. If I send the multicast to a Link-Local address like "ff02::1" the function getMessageID returns the right ID. But if I send the message to an Mesh-Local address like "ff03::1" the function return always 0.
On server side:
It works always perfectly the function returns the right message ID.
I tested it with the example "Thread Simple CoAP Client" on a PCA10056:
void thread_coap_utils_multicast_light_request_send(uint8_t command, thread_coap_utils_multicast_scope_t scope) { otError error = OT_ERROR_NONE; otMessage * p_request; otMessageInfo message_info; const char * p_scope = NULL; otInstance * p_instance = thread_ot_instance_get(); do { p_request = otCoapNewMessage(p_instance, NULL); if (p_request == NULL) { NRF_LOG_INFO("Failed to allocate message for CoAP Request\r\n"); break; } otCoapMessageInit(p_request, OT_COAP_TYPE_NON_CONFIRMABLE, OT_COAP_CODE_PUT); error = otCoapMessageAppendUriPathOptions(p_request, "light"); ASSERT(error == OT_ERROR_NONE); error = otCoapMessageSetPayloadMarker(p_request); ASSERT(error == OT_ERROR_NONE); error = otMessageAppend(p_request, &command, sizeof(command)); if (error != OT_ERROR_NONE) { break; } switch (scope) { case THREAD_COAP_UTILS_MULTICAST_LINK_LOCAL: p_scope = "ff02::1"; break; case THREAD_COAP_UTILS_MULTICAST_REALM_LOCAL: p_scope = "ff03::1"; break; default: ASSERT(false); } memset(&message_info, 0, sizeof(message_info)); message_info.mPeerPort = OT_DEFAULT_COAP_PORT; error = otIp6AddressFromString(p_scope, &message_info.mPeerAddr); ASSERT(error == OT_ERROR_NONE); error = otCoapSendRequest(p_instance, p_request, &message_info, NULL, NULL); NRF_LOG_INFO("Message ID: %u", otCoapMessageGetMessageId(p_request)); // Return 0 if address is Mesh-Local (ff03::1) } while (false); if (error != OT_ERROR_NONE && p_request != NULL) { NRF_LOG_INFO("Failed to send CoAP Request: %d\r\n", error); otMessageFree(p_request); } }
I tried to make and replace the latest openthread libraries but the problem is still there.
Thank you for your support
Best Regards
Roiben