From 1c6d4eaabad6c235e7a5586156e214ebf3e9c091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomislav=20Kopi=C4=87?= Date: Tue, 5 Nov 2024 13:33:40 +0100 Subject: [PATCH] Change AP SSID generator --- src/netman.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/netman.h b/src/netman.h index 3b1015f..a859671 100644 --- a/src/netman.h +++ b/src/netman.h @@ -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();