Nanosecond precision packet arrival time for WiFi
Posted: Fri Sep 15, 2023 9:05 am
Hi everyone,
To implement Time-Of-Flight scenarios, I need to know the exact packet arrival time (accurate to ESP32 clock of 240MHz - 4 nanosecond) in the promiscuous mode callback. The current `rx_ctrl->timestamp` field received in the payload is not sufficient as it is precise only to the current microsecond, which makes it moot for calculating ToF.
Since ESP32 supports 802.11mc FTM, the packet arrival time can be read at a higher precision. I'm wondering if:
1. There is an inbuild method I could leverage for it?
2. In case there isn't one, how and where can I modify the code which assigns the fields for rx_ctrl (RSSI, Channel, Timestamp etc.) to instead write the CPU clock register (which can be retreived by `get_ccount_register()` ) in the timestamp field as soon as the packet is received.
3. Where is the internal code implementation for FTM, which I could use as a reference?
4. Is it possible to create a "one-sided" FTM request in the current API? This is now available in Android.
To implement Time-Of-Flight scenarios, I need to know the exact packet arrival time (accurate to ESP32 clock of 240MHz - 4 nanosecond) in the promiscuous mode callback. The current `rx_ctrl->timestamp` field received in the payload is not sufficient as it is precise only to the current microsecond, which makes it moot for calculating ToF.
Since ESP32 supports 802.11mc FTM, the packet arrival time can be read at a higher precision. I'm wondering if:
1. There is an inbuild method I could leverage for it?
2. In case there isn't one, how and where can I modify the code which assigns the fields for rx_ctrl (RSSI, Channel, Timestamp etc.) to instead write the CPU clock register (which can be retreived by `get_ccount_register()` ) in the timestamp field as soon as the packet is received.
3. Where is the internal code implementation for FTM, which I could use as a reference?
4. Is it possible to create a "one-sided" FTM request in the current API? This is now available in Android.