Problems on nrf52840 coap server to receive packages

164 views
Skip to first unread message

yinzhou tao

unread,
Oct 20, 2020, 10:59:51 PM10/20/20
to openthread-users
Hi All, 

I want to implement a function to send data from the internet coap client to nrf52840 DK coap server. The nrf52840 runs .hex file which is one modified from Nordic Thread SDK example\thread\simple_coap_server, but I find that whether I use the otCoapAddResource registered function or the coap_default_handler function, neither received the coap data that internet coap client sent. I've caught coap message on the wpan0 interface of OTBR, but the function didn't work as if it hadn't received those package, that is the OTBR in wpan0 has received this package, but it doesn't deliver to nrf52840 DK coap sever. 

Therefore, how do I get the nrf52840 DK coap server to receive and process packages from coap client successfully?

I really appreciate any help you can provide. 

Best, 
Tao

Jonathan Hui

unread,
Oct 21, 2020, 12:49:03 AM10/21/20
to yinzhou tao, openthread-users
Are you able to communicate with the nRF52840 DK from the CoAP client in any way? Are you able to ping the nRF52840 DK from your CoAP client device?

Can you provide a packet trace on both the wpan0 interface as well as a sniffer packet capture from the Thread network?

--
Jonathan Hui



--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/d7af1501-63fb-4e4c-98ee-59316bcf8c9en%40googlegroups.com.
Message has been deleted

yinzhou tao

unread,
Oct 22, 2020, 5:50:13 AM10/22/20
to openthread-users
Hi Jonathan, 

Thanks for answering my questions. Actually, my coap server needs to both send and receive coap packages. The nrf52840 coap server needs to send a registration package to the cloud server first, then I can receive a reply package from the cloud. So, I can confirm that the whole network is working. Previously, you suggested me to capturing packets on both the wpan0 interface as well as a sniffer packet capture from the Thread network.

To follow your suggestion, I captured and confirmed that the RCP sent the package to the thread network (according the official nordic SDK https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v4.0.0%2Fnrf802154_sniffer.html).  



This picture is the captured packages, you can see the first and second packages is the interaction between the cloud server and nrf52840 coap server. nrf52840 coap server  address is fd11:22::2d65:6cbb:4e63:ef8. I think the nrf52840 coap server should receive this package. The last package is the one that sent from the cloud to the coap server. 

Here is my code extract:  

static otCoapResource m_property_set_request_resource =
{
    .mUriPath = "/$sys/CxD2hb4NHT/tttt/thing/property/set",
    .mHandler = property_set_request_handler,
    .mContext = NULL,
    .mNext    = NULL
};

static void thread_coap_init(void)
{
    thread_coap_utils_configuration_t thread_coap_configuration =
    {
        .coap_server_enabled               = true,
        .coap_client_enabled               = true,
        .configurable_led_blinking_enabled = false,
    };

    thread_coap_utils_init(&thread_coap_configuration);
}

void thread_coap_utils_init(const thread_coap_utils_configuration_t * p_config)
{
    otInstance * p_instance = thread_ot_instance_get();

    otError error = otCoapStart(p_instance, OT_DEFAULT_COAP_PORT);
    ASSERT(error == OT_ERROR_NONE);
    otCoapSetDefaultHandler(p_instance, coap_default_handler, NULL);
    m_config = *p_config;

    m_light_command_handler = light_changed_default;
    if (m_config.coap_server_enabled)
    {
        retval = app_timer_create(&m_provisioning_timer,
                                  APP_TIMER_MODE_SINGLE_SHOT,
                                  provisioning_timer_handler);
        ASSERT(retval == NRF_SUCCESS);

        m_light_resource.mContext        = p_instance;
        m_property_set_request_resource.mContext = p_instance;

        error = otCoapAddResource(p_instance, &m_light_resource);
        ASSERT(error == OT_ERROR_NONE);
        error = otCoapAddResource(p_instance, &m_property_set_request_resource);
        ASSERT(error == OT_ERROR_NONE);
    }
}
static void property_set_request_handler(void                * p_context,
                                         otMessage           * p_message,
                                         const otMessageInfo * p_message_info)
{
    printf("property_set_request_handler\n");
}

The function property_set_request_handler is not called.  
Is there some problems with my code that caused the received coap package handle improperly?

Best,
tao

yinzhou tao

unread,
Oct 22, 2020, 5:56:09 AM10/22/20
to openthread-users
wireshark_sniffer.png

Jonathan Hui

unread,
Oct 22, 2020, 11:33:41 AM10/22/20
to yinzhou tao, openthread-users
Can you provide the full pcap file (along with the Thread Master Key) so that we can see more details than what's shown in the screenshot?

--
Jonathan Hui



yinzhou tao

unread,
Oct 22, 2020, 9:33:23 PM10/22/20
to openthread-users
Hi Jonathan,  
 
I have attached  the .pcap that trace on both the wpan0 interface as well as a sniffer packet capture from the Thread network.
Thread Master Key is  00112233445566778899aabbccddeeff
Best,  
tao
10.23-wpan0.pcap
10.23-sniffer.pcap

Jonathan Hui

unread,
Oct 24, 2020, 1:11:13 AM10/24/20
to yinzhou tao, openthread-users
The sniffer trace does confirm that the CoAP PUT request is being sent over the air and received by the intended recipient.

Is it possible for you to share your source code?

You might also want to check out src/cli/cli_coap.cpp for examples of using the OpenThread CoAP APIs.

--
Jonathan Hui



yinzhou tao

unread,
Oct 26, 2020, 3:41:08 AM10/26/20
to openthread-users
Hi Jonathan,   
  I have attached  may source code.

  Is there some problems with my code that caused the received coap package handle improperly?

Best,
tao
thread_coap_utils.c
main.c
Reply all
Reply to author
Forward
0 new messages