aws_iot sample: the purpose of delayed connect_work

I have been trying the aws_iot sample in nRF Connect SDK v2.7.0 for build target nrf7002dk/nrf5340/cpuapp, in which connect_work is scheduled with a 5 second delay in the function on_net_event_l4_connected. What is the purpose of this delay?

As a test I have tried replacing the 5 second delay with K_NO_WAIT, and noticed that aws_iot_connect returns error -116 with an increased rate (although this error also occasionally happens with the K_SECONDS(5) delay), is this the reason for the 5 second delay? Is it recommended to always have some amount delay between a NET_EVENT_L4_CONNECTED event and calling aws_iot_connect?

Parents
  • Hi,

     

    Johan Kopra said:
    At first I tried concatenating NET_EVENT_IPV4_DHCP_BOUND to the L4_EVENT_MASK and adding a corresponding log message to l4_event_handler, but did not see evidence of NET_EVENT_IPV4_DHCP_BOUND events. Eventually I was able to see NET_EVENT_IPV4_DHCP_BOUND events by using a separate callback for them.

    My apologies, I should have given an example here, but I'm glad to hear that you found a solution to this.

    Johan Kopra said:
    With a little testing I have observed up to a 10 second delay between the l4-connected event and NET_EVENT_IPV4_DHCP_BOUND event. AWS connection seems to work when attempted after NET_EVENT_IPV4_DHCP_BOUND without adding a delay.

    Glad to hear that the initial connection is more stable now. This is an interesting find. I tested a couple of networks, and got both of these events almost simultaneously (milliseconds apart). I'll report your findings back to the team responsible for these samples.

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    Johan Kopra said:
    At first I tried concatenating NET_EVENT_IPV4_DHCP_BOUND to the L4_EVENT_MASK and adding a corresponding log message to l4_event_handler, but did not see evidence of NET_EVENT_IPV4_DHCP_BOUND events. Eventually I was able to see NET_EVENT_IPV4_DHCP_BOUND events by using a separate callback for them.

    My apologies, I should have given an example here, but I'm glad to hear that you found a solution to this.

    Johan Kopra said:
    With a little testing I have observed up to a 10 second delay between the l4-connected event and NET_EVENT_IPV4_DHCP_BOUND event. AWS connection seems to work when attempted after NET_EVENT_IPV4_DHCP_BOUND without adding a delay.

    Glad to hear that the initial connection is more stable now. This is an interesting find. I tested a couple of networks, and got both of these events almost simultaneously (milliseconds apart). I'll report your findings back to the team responsible for these samples.

     

    Kind regards,

    Håkon

Children
No Data
Related