I have a project that utilizes both Espressif's freemodbus implementation (via RS232 to RS485 convertor connected to pins 16, 17 and control pin to 18) and uses Wi-Fi in promiscuous mode. When Wi-Fi is used as AP/connected to and AP Modbus works correctly (can normally communicate, signal on RTS pin is present.) That being said after starting Wi-Fi in promiscuous mode used to capture Wi-Fi probe requests with:
Code: Select all
tcpip_adapter_init();
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) );
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() );
const wifi_promiscuous_filter_t filt = {
.filter_mask = WIFI_EVENT_MASK_AP_PROBEREQRECVED
};
ESP_ERROR_CHECK(esp_wifi_set_channel(WIFI_CHANNEL, WIFI_SECOND_CHAN_NONE));
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&filt));
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&WiFiSniffer::wifiSnifferPacketHandler));
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true));
Modbus RTS signal stops either immediately stops or stops after few second. Same goes for TX signal. Just to be clear when device starts right away with Wi-Fi in promiscuous mode active, instead of acting as AP, problem still persists. When filtering uout what function call leads to this behavior esp_wifi_set_promiscuous_rx_cb was found to be responsible.