-
-
Save prateekrajgautam/0ebde60700e0b8568da3e377aa4e7c4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "freertos/FreeRTOS.h" | |
#include "nvs_flash.h" | |
#include "lwip/err.h" | |
#include "esp_wifi.h" | |
#include "esp_wifi_internal.h" | |
#include "esp_system.h" | |
#include "esp_event.h" | |
#include "esp_event_loop.h" | |
uint16_t offset = 0; | |
esp_err_t event_handler(void* ctx, system_event_t* event) | |
{ | |
return ESP_OK; | |
} | |
void promiscuousmode(void* buffer, wifi_promiscuous_pkt_type_t type) | |
{ | |
wifi_promiscuous_pkt_t* p = (wifi_promiscuous_pkt_t*)buffer; | |
//remove last 4 bytes of mgmt packets | |
//if (type == WIFI_PKT_MGMT) (packet->rx_ctrl.sig_len) -= 4; | |
for (int i = 0; i < p->rx_ctrl.sig_len; i++) { | |
if (i % 8 == 0) { | |
printf("%06X ", offset); | |
offset += 8; | |
} | |
printf("%02X ", p->payload[i]); | |
if (i % 8 == 7) { | |
printf("\n"); | |
} | |
else if ((i + 1) == p->rx_ctrl.sig_len) { | |
printf("\n"); | |
} | |
} | |
offset = 0; | |
} | |
void app_main(void) | |
{ | |
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); | |
esp_interface_t wifi_if; | |
nvs_flash_init(); | |
tcpip_adapter_init(); | |
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL)); | |
ESP_ERROR_CHECK(esp_wifi_init(&cfg)); | |
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); | |
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); | |
ESP_ERROR_CHECK(esp_wifi_start()); | |
esp_wifi_set_promiscuous(true); | |
esp_wifi_set_promiscuous_rx_cb(&promiscuousmode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment