I try figure out if wifi devices are in the same room as an ESP32. So started my Idea by writing a proof of concept on my laptop in python. I used Scapy as library and saw that the DOT11 Radiotap header supported something called "dBm_AntSignal". After switching my network card into monitor mode I was able to see the relative signal strength to them and to which AP they are connected to.
https://scapy.readthedocs.io/en/latest/ ... 1.RadioTap
Important to mention here is the fact that it was the relative signal strength between my laptop and the sending device.
So with this in mind I tried to reproduce this in Arduino C++ with an ESP32.
So by using:
Code: Select all
void wifi_sniffer_init()
{
nvs_flash_init();
tcpip_adapter_init();
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_country(&wifi_country)); /* set country for channel range [1, 13] */
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL));
ESP_ERROR_CHECK(esp_wifi_start());
esp_wifi_set_promiscuous_filter(&wifi_filter); // set frame filter
//esp_wifi_set_ps(WIFI_PS_MIN_MODEM); //WORKAROUND FOR BT
esp_wifi_set_promiscuous(true);
esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler);
}
Code: Select all
void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type)
{
/* if (type != WIFI_PKT_MGMT)
return;
*/
const wifi_promiscuous_pkt_t *ppkt = (wifi_promiscuous_pkt_t *)buff;
const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)ppkt->payload;
const wifi_ieee80211_mac_hdr_t *hdr = &ipkt->hdr;
const wifi_header_frame_control_t *frame_ctrl = (wifi_header_frame_control_t *)&hdr->frame_ctrl;
}
But this is only the signal strength between device and router and not between the sending device and my esp.
I've read about 802.11mc ToF measurement via rtt but I think its not very compatible and available on my ESP-WROOM-32D.
Is it possible to get the raw signal strength that arrived at esp32 antenna ?
Thank you :>