Skip to content

Commit 8792daf

Browse files
marcnausebessman
andauthored
feat: add NIC specific part of MAC address as suffix to SSID (#15)
Co-authored-by: Alexander Bessman <[email protected]>
1 parent c2a796f commit 8792daf

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

docs/esptool.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ You should see something like this:
8888
Leaving...
8989
Hard resetting via RTS pin...
9090

91-
Now pull the ESP-01's GPIO_0 pin high and reset it. If the new firmware was flashed successfully, it will start broadcasting an SSID called "PSLab".
91+
Now pull the ESP-01's GPIO_0 pin high and reset it. If the new firmware was flashed successfully, it will start broadcasting an SSID starting with "PSLab_" followed by the last three octets of the MAC address of the ESP-01 (e.g. "PSLab_0DCE2F").

src/ESP01Firmware/ESP01Firmware.ino

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void setup() {
1313

1414
WiFi.setSleepMode(WIFI_NONE_SLEEP);
1515

16-
WiFi.softAP(ssid, password);
16+
WiFi.softAP(ssid + get_suffix(), password);
1717

1818
server.begin();
1919
}
@@ -35,4 +35,17 @@ void loop() {
3535
}
3636
client.stop();
3737
}
38-
}
38+
}
39+
40+
/**
41+
* @brief Return a suffix based on the NIC specific part of the MAC address
42+
*
43+
* @return The final three octets of the MAC address, prefixed with underscore
44+
*/
45+
String get_suffix() {
46+
// Remove vendor ID
47+
String mac = WiFi.macAddress().substring(9, 17);
48+
// Remove colons
49+
mac.replace(":", "");
50+
return "_" + mac;
51+
}

0 commit comments

Comments
 (0)