This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

OpenThread response handler coap

Hello,

I would like to append data to a coap response like this:

p_response = otCoapNewMessage(p_instance, NULL);
    if (p_response == NULL)
    {
        NRF_LOG_ERROR("Could not create new message in ot_paring_response.");
        return;
    }

    error = otCoapMessageInitResponse(p_response,
                                      p_message,
                                      OT_COAP_TYPE_ACKNOWLEDGMENT,
                                      OT_COAP_CODE_VALID);

    if (error != OT_ERROR_NONE)
    {
        NRF_LOG_ERROR("Could not init new message in ot_paring_response.");
    }
    else
    {
        error = otMessageAppend(p_response, data, sizeof(data));
        ASSERT(error == OT_ERROR_NONE);

        error = otCoapSendResponse(p_instance, p_response, p_message_info);
        ASSERT(error == OT_ERROR_NONE);
    }

    if ((error != OT_ERROR_NONE) && (p_response != NULL))
    {
        otMessageFree(p_response);
    }

I have a response handler that is triggered as the device receive the response. I am able to get the data appended to the message only if it is 0x00 otherwise the handler is not fired. Any possible fix ?

Second question. I want to use openthread to receive a response from all devices around. Is there a way to configure the request such that the response handler is listening to all devices ? Currently he is only listening to the first responding.

Thanks

Parents Reply Children
No Data
Related