Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "WiFi.h"
- void setup() {
- Serial.begin(115200);
- WiFi.mode(WIFI_MODE_STA);
- esp_wifi_set_promiscuous(true);
- esp_wifi_set_promiscuous_filter(&filter);
- esp_wifi_set_promiscuous_rx_cb(&sniffer_callback);
- esp_wifi_start();
- }
- void loop() {
- // Nothing to do here - everything happens in the callback
- }
- void sniffer_callback(void* buf, wifi_promiscuous_pkt_type_t type) {
- const wifi_promiscuous_pkt_t *ppkt = (wifi_promiscuous_pkt_t *)buf;
- Serial.print("Packet: ");
- for (int i = 0; i < ppkt->rx_ctrl.sig_len; i++) {
- Serial.print(ppkt->payload[i], HEX);
- Serial.print(" ");
- }
- Serial.println();
- }
- wifi_promiscuous_filter_t filter = {
- .filter_mask = WIFI_PROMIS_FILTER_MASK_ALL,
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement