Browse Source

esp32: assign a more sensible MAC address for AP mode

For some reason, the Arduino core never sets a MAC address for SoftAP
mode. Create a more reasonable address than 0:0:3:0:0:0 which seems to
be what comes up otherwise.
H. Peter Anvin 1 year ago
parent
commit
75bc42429c
5 changed files with 9 additions and 0 deletions
  1. 9 0
      esp32/max80/wifi.cpp
  2. BIN
      esp32/output/max80.ino.bin
  3. BIN
      fpga/output/max80.fw
  4. BIN
      fpga/output/v1.fw
  5. BIN
      fpga/output/v2.fw

+ 9 - 0
esp32/max80/wifi.cpp

@@ -451,6 +451,15 @@ static void wifi_config_ap(void)
     uint8_t mac[6];
     static char ap_ssid[64];
 
+    // The default SoftAP MAC is totally useless, so try to
+    // set it to something more sensible...
+    WiFi.macAddress(mac);
+    uint8_t add = !!(mac[0] & 2);
+    mac[0] |= 2;		// Set local bit
+    mac[5] += add;		// Increment last byte if already local
+    esp_wifi_set_mac(WIFI_IF_AP, mac);
+
+    // Read it back to check what we got...
     WiFi.softAPmacAddress(mac);
     setvar_mac(status_net_ap_mac, mac);
 

BIN
esp32/output/max80.ino.bin


BIN
fpga/output/max80.fw


BIN
fpga/output/v1.fw


BIN
fpga/output/v2.fw