COAP_CLIENT_LIB request issue

Hi.

I'm using nrf Connect SDK v3.0.1 and Zephyr v4.0.99 to implement a IoT device which connects to a Thingsboard server with CoAP. With the COAP_CLIENT Lib I want to download data in 945 chunks of 512 byte size.

I've used the coap_download example as a template for my implementation. I create the request and send it to the library with coap_client_req(). When the server responds, the callback function gets called in which I process the data (copy it to a queue in my case) and give a sem to tell the coap thread to cancel the request (coap_client_cancel_request()). This works as many times as I have configured in CONFIG_COAP_CLIENT_MAX_REQUESTS. After that the lib reports an error "No more free requests".

It looks for me that the cancel of the request didn't work. But maybe I didn't understand the usage of the COAP_CLIENT lib.
Are there any hints to use it correctly?

Thanks
BR
Christian

Parents
  • Well, since the path changes, you need to send a different request per chunk as you said. It indeed looks like the cancellation fails. Exactly where do you call coap_client_cancel_request() and what are your parameters? If you'd like, you could upload your source file or your callback function and I can have a look at it.


    It should look something like this:

    static void on_coap_response()
    {
        /* 1. Copy payload to your queue */
        copy_to_queue();
    
        /* 2. Free the slot immediately */
        coap_client_cancel_request();
    
        /* 3. Wake up the thread that will launch the next chunk */
        k_sem_give(&ready_sem);
    }
    

Reply
  • Well, since the path changes, you need to send a different request per chunk as you said. It indeed looks like the cancellation fails. Exactly where do you call coap_client_cancel_request() and what are your parameters? If you'd like, you could upload your source file or your callback function and I can have a look at it.


    It should look something like this:

    static void on_coap_response()
    {
        /* 1. Copy payload to your queue */
        copy_to_queue();
    
        /* 2. Free the slot immediately */
        coap_client_cancel_request();
    
        /* 3. Wake up the thread that will launch the next chunk */
        k_sem_give(&ready_sem);
    }
    

Children
No Data
Related