4

I didn't find much documentation about ESP promiscuous mode (just from the espressif sdk although I'm using ArduinoIDE https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/api-reference/wifi/esp_wifi.html )

So from seeing some sample codes ( https://github.com/spacehuhn/ArduinoPcap/blob/master/examples/esp8266_pcap_serial/esp8266_pcap_serial.ino and https://www.youtube.com/watch?v=3Ac6X6ZBQ0g ) the esp8266 doesn't work properly for some people but for others (https://www.esp8266.com/viewtopic.php?t=12127) it seems to work properly, so I don't know if it's a hardware limitation.

I tried making a simple sketch to try it for my NodeMCU 0.9 and compared the packets from wireshark and I saw the majority of the packets come incomplete or with anomalies

#include <ESP8266WiFi.h>
#include <Arduino.h>

extern "C" { #include <user_interface.h> }

static void ICACHE_FLASH_ATTR handlePacket(unsigned char* buf, uint16_t len) { for (int c=0; c < len; c++){ Serial.printf("%d:%d ", c, (int)buf[c]);
} Serial.println(); }

void setup() { Serial.begin(115200); Serial. println();

wifi_set_opmode(STATION_MODE); wifi_promiscuous_enable(0); WiFi.disconnect(); wifi_set_promiscuous_rx_cb(handlePacket); wifi_set_channel(6); wifi_promiscuous_enable(1); }

void loop(){}

From the example code that works, the guy seems to use esp8266 sdk, is the ArduinoIDE a limitation for this monitor mode thing?

https://bbs.espressif.com/viewtopic.php?t=3072
https://github.com/kieransimkin/esp8266-freedom

tatu101
  • 73
  • 4
  • Printing to serial from an interrupt is a very bad idea. Real time capture and output of network packets to serial is bound to run into the speed limits of the serial port, so incomplete and/or anomalous output is not unexpected. – StarCat Jul 26 '23 at 09:24
  • Other than what @StarCat mentioned, I think you use the wrong macro ICACEH_FLASH_ATTR, it is supported to be ICACHE_RAM_ATTR. – hcheung Jul 26 '23 at 12:41
  • @hcheung I was just following an example, I didnt really know what that mean, but from here ( https://stackoverflow.com/questions/58113937/esp8266-arduino-why-is-it-necessary-to-add-the-icache-ram-attr-macro-to-isrs-an ) it seems that the best for often called functions is to not have any cache at all – tatu101 Aug 01 '23 at 18:55

0 Answers0