updated DeviceName handling
This commit is contained in:
parent
a22f71649a
commit
52026296f2
@ -35,7 +35,7 @@
|
||||
<nav class="navbar fixed-top navbar-dark bg-primary" id="navbar1">
|
||||
<a class="navbar-brand" href="#">
|
||||
<img src="static/img/logo.png" width="30" height="30" class="d-inline-block align-top mr-1" alt="">
|
||||
DE Airsoft Timer
|
||||
<span class="data-devicename">DE Airsoft Timer</span>
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar"
|
||||
aria-controls="collapsingNavbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
@ -63,7 +63,7 @@
|
||||
<div class="col text-center">
|
||||
<div class="jumbotron">
|
||||
<img src="static/img/logo.png" width="120" height="120" class="img-fluid" alt="">
|
||||
<h3 class="pt-3">Dark Emergency Timer</h3>
|
||||
<h3 class="pt-3"><span class="data-devicename">DE Airsoft Timer</span></h3>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Div Group Battery remain -->
|
||||
|
@ -190,6 +190,10 @@ function fillValuesToHTML(dataset) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Aktualisiere den <title>-Tag, wenn der Schlüssel 'devicename' im dataset vorhanden ist
|
||||
if (key === "devicename") {
|
||||
document.title = dataset[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,10 @@
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#ifndef HOST_NAME
|
||||
#define HOST_NAME "AirsoftTimer_%08X"
|
||||
#ifndef DEVICE_NAME
|
||||
#define HOST_NAME "AirsoftTimer"
|
||||
#else
|
||||
#define HOST_NAME DEVICE_NAME
|
||||
#endif
|
||||
|
||||
#define SHUTDOWN_DELAY_MS 5000
|
||||
|
@ -11,6 +11,7 @@ typedef struct Globals_s
|
||||
char systemStatustxt[16] = ""; /**< Text representation of system status */
|
||||
EERequest_t requestEEAction = EE_IDLE; /**< EEPROM-related request */
|
||||
char DeviceName[33]; /**< Device name */
|
||||
char DeviceNameId[sizeof(DeviceName) + 8]; /**< Device name plus 8 chars chipID */
|
||||
char FlashVersion[10]; /**< Flash version */
|
||||
uint16_t eePersistanceAdress; /**< EEPROM persistence address */
|
||||
bool hasDTC;
|
||||
|
@ -84,7 +84,8 @@ void setup()
|
||||
system_update_cpu_freq(SYS_CPU_80MHZ);
|
||||
|
||||
// Generate a unique device name based on ESP chip ID
|
||||
snprintf(globals.DeviceName, 32, HOST_NAME, ESP.getChipId());
|
||||
strncpy(globals.DeviceName, HOST_NAME, sizeof(globals.DeviceName));
|
||||
snprintf(globals.DeviceNameId, sizeof(globals.DeviceNameId), "%s_%08X", globals.DeviceName, ESP.getChipId());
|
||||
|
||||
// Disable WiFi persistent storage
|
||||
WiFi.persistent(false);
|
||||
@ -95,7 +96,7 @@ void setup()
|
||||
#ifdef FEATURE_ENABLE_WIFI_CLIENT
|
||||
// Configure WiFi settings for client mode if enabled
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.setHostname(globals.DeviceName);
|
||||
WiFi.setHostname(globals.DeviceNameId);
|
||||
wifiMulti.addAP(QUOTE(WIFI_SSID_CLIENT), QUOTE(WIFI_PASSWORD_CLIENT));
|
||||
tmrWiFiMaintainConnection.start();
|
||||
#else
|
||||
@ -108,7 +109,7 @@ void setup()
|
||||
Serial.setDebugOutput(false);
|
||||
|
||||
Serial.print("\n\n-------------------START-------------------\n");
|
||||
Serial.print(globals.DeviceName);
|
||||
Serial.print(globals.DeviceNameId);
|
||||
Serial.print("\nby Hiabuto Defense\n");
|
||||
|
||||
// Initialize EEPROM, load configuration, and persistence data from EEPROM
|
||||
@ -150,7 +151,7 @@ void setup()
|
||||
|
||||
// Set up OTA updates
|
||||
ArduinoOTA.setPort(8266);
|
||||
ArduinoOTA.setHostname(globals.DeviceName);
|
||||
ArduinoOTA.setHostname(globals.DeviceNameId);
|
||||
ArduinoOTA.setPassword(QUOTE(ADMIN_PASSWORD));
|
||||
|
||||
ArduinoOTA.onStart([]()
|
||||
@ -583,7 +584,7 @@ void toggleWiFiAP(bool shutdown)
|
||||
// Start WiFi in Access Point (AP) mode
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.softAPConfig(IPAddress(WIFI_AP_IP_GW), IPAddress(WIFI_AP_IP_GW), IPAddress(255, 255, 255, 0));
|
||||
WiFi.softAP(globals.DeviceName, QUOTE(WIFI_AP_PASSWORD));
|
||||
WiFi.softAP(globals.DeviceNameId, QUOTE(WIFI_AP_PASSWORD));
|
||||
|
||||
// Stop WiFi maintenance connection ticker if enabled and display debug messages
|
||||
#ifdef FEATURE_ENABLE_WIFI_CLIENT
|
||||
|
@ -71,7 +71,7 @@ void initWebUI()
|
||||
}
|
||||
|
||||
// Initialize mDNS and add service
|
||||
MDNS.begin(globals.DeviceName);
|
||||
MDNS.begin(globals.DeviceNameId);
|
||||
MDNS.addService("http", "tcp", 80);
|
||||
|
||||
// Set up WebSocket event handler and attach to web server
|
||||
@ -342,7 +342,7 @@ void WebServerEEJSON_Callback(AsyncWebServerRequest *request)
|
||||
|
||||
char buffer[16];
|
||||
|
||||
info["DeviceName"] = globals.DeviceName;
|
||||
info["DeviceNameId"] = globals.DeviceNameId;
|
||||
sprintf(buffer, "%d.%02d", constants.Required_Flash_Version_major, constants.Required_Flash_Version_minor);
|
||||
info["FW-Version"] = buffer;
|
||||
info["FS-Version"] = globals.FlashVersion;
|
||||
@ -653,6 +653,7 @@ void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping)
|
||||
if (send_mapping)
|
||||
{
|
||||
const char mapping[] = "MAPPING_STATIC:"
|
||||
"devicename;"
|
||||
"active_faction_on_reboot;"
|
||||
"batteryType;"
|
||||
"name_faction1;"
|
||||
@ -669,6 +670,7 @@ void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping)
|
||||
|
||||
String temp = "STATIC:";
|
||||
|
||||
temp.concat(String(globals.DeviceName) + ";");
|
||||
temp.concat(String(ConfigData.active_faction_on_reboot) + ";");
|
||||
temp.concat(String(ConfigData.batteryType) + ";");
|
||||
temp.concat(String(ConfigData.Faction_1_Name) + ";");
|
||||
|
Loading…
x
Reference in New Issue
Block a user