-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Open
Description
Board
ESP32 NodeMCU Dev Board (and also on ESP32S3 boards)
Device Description
Board only.
Hardware Configuration
Board only
Version
latest stable Release (if not listed below)
Type
Task
IDE Name
Arduino IDE v1.8.19 with https://github.com/espressif/arduino-esp32 as at 15Aug25 (IDE v3.3.0)
Operating System
Windows 10
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
115200
Description
The "esp_wifi_get_protocol()" call expects a 'uint8_t pointer', but actually appears to use it as a 'uint16_t pointer' thereby corrupting the next variable in the program.
Sketch
// The "esp_wifi_get_protocol()" call expects a 'uint8_t pointer', but actually appears to use it as a 'uint16_t pointer'...
// thereby corrupting the next variable in the program.
// https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/network/esp_wifi.html#_CPPv421esp_wifi_get_protocol16wifi_interface_tP7uint8_t
#include <WiFi.h>
#include <WiFiManager.h>
void setup() {
Serial.begin(115200); delay(3000);
Serial.printf("\nIDE SDK=v%s\n",ESP_ARDUINO_VERSION_STR);
WiFi.mode(WIFI_STA); // WiFi.mode(WIFI_AP); // WIFI_IF_AP
uint8_t x[20];
memset(x,8,20);
for (int y=0;y<20;y++) Serial.printf("%i ",x[y]); Serial.println();
uint8_t *phy_mode=x+10;
boolean success=(esp_wifi_get_protocol(WIFI_IF_STA,phy_mode)==ESP_OK);
// esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap)
Serial.printf("esp_wifi_get_protocol: success=%i, phy_mode=%u\n",success,*phy_mode);
for (int y=0;y<20;y++) Serial.printf("%i ",x[y]); Serial.println();
Serial.println("Note that 2 bytes have been changed/corrupted by the call: the 'phy_mode' byte and the 'subsequent' byte");
}
void loop() {}
Debug Message
IDE SDK=v3.3.0
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
esp_wifi_get_protocol: success=1, phy_mode=7
8 8 8 8 8 8 8 8 8 8 7 0 8 8 8 8 8 8 8 8
Note that 2 bytes have been changed/corrupted by the call: the 'phy_mode' byte and the 'subsequent' byte
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.
Metadata
Metadata
Assignees
Labels
No labels