Possible to check when a packet has been transmitted?

umisef
Posts: 2
Joined: Thu Dec 17, 2015 3:05 pm

Possible to check when a packet has been transmitted?

Postby umisef » Thu Dec 17, 2015 3:30 pm

For a low power application, we are keeping an ESP8266 powered down most of the time. Regularly, it will power up, take a measurement, and then use ESP-NOW to send the measured value to a gateway. After doing so, it gets powered down again.

However, when we trigger the power-down as soon as the callback registered with esp_now_register_send_cb() is called, most of the packets are never received. If instead we wait another 300ms (using ets_delay_us(300000)), the transmission is successful. The needed wait appears to depend on the packet size used.

It appears that the sent-callback is called as soon as the CPU has submitted data to the radio, and thus potentially before the radio has actually sent the data. And once the ESP gets powered down, such not-yet-sent data is lost.
Unfortunately, our (extremely limited) power budget requires us to power down at the absolute earliest possible time, so simply delaying for a safe, maximum amount of time is not an option.

Obviously, the CPU must be able to check whether the radio is still buffering data or not (to decide whether submitting more data would result in overflow), but I have not seen that functionality exposed. Is there any API for it? Or possibly just a bit in a hardware register that can be read? Any indication at all which is accessible from a user application?

eyal
Posts: 12
Joined: Thu Apr 09, 2015 8:52 pm

Re: Possible to check when a packet has been transmitted?

Postby eyal » Fri Dec 18, 2015 12:56 pm

I use nodemcu-firmware which is lua over the SDK. I have the exact same problem with UDP packets, and now have a stupid 30ms wait before powering down (deep sleep) the module. I send a 150 bytes payload. For reference, my program takes only 250ms to read and send the data so a proper callback will be nice. Currently the 'sent' cb happens immediately.

Furthermore, I think that all buffers should be drained when a power down (or interface close) takes place.

Alternatively, functions to check for pending send data will allow me to wait only long enough.

TIA

Who is online

Users browsing this forum: No registered users and 19 guests