Change AP SSID generator

This commit is contained in:
Tomislav Kopić 2024-11-05 13:33:40 +01:00
parent f835aa0122
commit 1c6d4eaaba
No known key found for this signature in database
GPG Key ID: 77B232765688AEA7

View File

@ -53,11 +53,16 @@ void netman::init(String ssid, String pass, bool hidden) {
pass = "8characters";
}
// Get the last 4 characters of the MAC address
String macAddress = WiFi.macAddress();
String macSuffix = macAddress.substring(macAddress.length() - 5).replace(":", "");
// Set default SSID if none provided
_ssid = ssid.isEmpty() ? "SmartCube_" + String(ESP.getChipId()) : ssid;
_ssid = ssid.isEmpty() ? "SmartCube_" + macSuffix : ssid;
_pass = pass;
_hidden = hidden;
// Initialize LittleFS with error handling
if (!LittleFS.begin()) {
display.clearDisplay();
@ -159,8 +164,12 @@ void netman::createAP() {
display.clearDisplay();
display.setCursor(0, 0);
display.println("AccessPoint created");
display.setCursor(0, 12);
display.println("SSID:");
display.setTextSize(2);
display.println(_ssid.c_str());
display.setTextSize(1);
display.setCursor(0, 32);
display.println("IP:");
display.println(WiFi.softAPIP().toString());
display.display();