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

Problems on nrf52840 coap server to receive packages

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

Parents
  • Hi,

    Can you provide more details about the "internet coap client"? How are the packets addressed to the CoAP server node in the Thread network? Do you have global IPv6 connectivity to the border router?

    Can you post logs, packet captures, etc that can help with identifying where the packets stop? If you could also upload the modified CoAP server project to show the changes you made, that would also be helpful.

    Best regards,
    Jørgen

  • Hi,

    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.

    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
    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 modified 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
Reply
  • Hi,

    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.

    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
    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 modified 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
Children
No Data
Related