How to send a confirmable packet

Hi,

I have bunch of SEDs (sensors/clients) and one or more FTDs (hosts) working on CoAP protocol. SEDs send data packets once in a while and mostly sleeping. I have few questions.

1. Does confirmable packets consume more battery power from the SEDs?

2. Can we set a application call back when ACK fails?

3. The 'coap_send_request ()' function in coap_utils.c seems hardwired to send non-confirmable packets. How can we send confirmable packets in this case? (I dont want to modify SDK functions as they can get overwritten if we update the SDK). Do we have to implement our own version of  'coap_send_request ()' function?

4. 'coap_send_request ()' function has a reply call back as a parameter. How does this function in a non-confirmable/confirmable packets?

Cheers,

Kaushalya

Parents
  • Yes, confirmable packets do consume more battery power from the SEDs because they require the sensors to wait for an acknowledgment (ACK) from the receiver, keeping the radio on for longer periods. You can set an application callback to handle failed ACKs, typically by setting a timeout and managing the event when no ACK is received within that timeframe. If the 'coap_send_request()' function in coap_utils.c is hardwired to send non-confirmable packets and you don’t want to modify the SDK, you will likely need to implement your own version of this function to set the confirmable flag appropriately in the CoAP message. The reply callback in 'coap_send_request()' is invoked when a response is received. For confirmable packets, it is called upon receiving the ACK, while for non-confirmable packets, it is triggered when the response arrives without an acknowledgment mechanism.

  • Hi  Ragnorrak,

    I have implemented confirmable packets and it seems packets are sent to the intended router. In this instance my SED is connected to a parent router and I am sending confirmable packets to another router (destined router). But when I shutdown the destined router, I still get the confirm callback!!. Is the confirm coming from the parent? 

    When the SED is sending the data packet, I am using 'OT_COAP_CODE_PUT'. I tried OT_COAP_CODE_GET instead but still result is the same. I get a callback in either case. Now I am trying to dig into the parameters passed onto the callback to determine if my intended router is in reachable or not.

    My cb is defined like this.

    int *sensor_data_ack (const struct coap_packet *response, struct coap_reply *reply, const struct sockaddr *from) {
    .
    .
    .
    }
    When I looked into *from, which is a sockaddr, I get the sa_family as 0x5c00, which is incorrect I think. This should be AE_INET6, which should evaluate to 2. What's going wrong here?

    Also, do we need to implement the ACK reply in application layer of the receiver?

    Cheers,

    Kaushalya

Reply
  • Hi  Ragnorrak,

    I have implemented confirmable packets and it seems packets are sent to the intended router. In this instance my SED is connected to a parent router and I am sending confirmable packets to another router (destined router). But when I shutdown the destined router, I still get the confirm callback!!. Is the confirm coming from the parent? 

    When the SED is sending the data packet, I am using 'OT_COAP_CODE_PUT'. I tried OT_COAP_CODE_GET instead but still result is the same. I get a callback in either case. Now I am trying to dig into the parameters passed onto the callback to determine if my intended router is in reachable or not.

    My cb is defined like this.

    int *sensor_data_ack (const struct coap_packet *response, struct coap_reply *reply, const struct sockaddr *from) {
    .
    .
    .
    }
    When I looked into *from, which is a sockaddr, I get the sa_family as 0x5c00, which is incorrect I think. This should be AE_INET6, which should evaluate to 2. What's going wrong here?

    Also, do we need to implement the ACK reply in application layer of the receiver?

    Cheers,

    Kaushalya

Children
Related