mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-30 03:43:44 +00:00
Use unique SSID on first boot
This commit is contained in:
@@ -124,16 +124,12 @@ void AmsConfiguration::clearNetworkConfig(NetworkConfig& config) {
|
||||
memset(config.ssid, 0, 32);
|
||||
memset(config.psk, 0, 64);
|
||||
clearNetworkConfigIp(config);
|
||||
|
||||
uint16_t chipId;
|
||||
getUniqueName(config.hostname, 32);
|
||||
#if defined(ESP32)
|
||||
chipId = ( ESP.getEfuseMac() >> 32 ) % 0xFFFFFFFF;
|
||||
config.power = 195;
|
||||
#else
|
||||
chipId = ESP.getChipId();
|
||||
config.power = 205;
|
||||
#endif
|
||||
strcpy(config.hostname, (String("ams-") + String(chipId, HEX)).c_str());
|
||||
config.mdns = true;
|
||||
config.sleep = 0xFF;
|
||||
config.use11b = 1;
|
||||
@@ -983,6 +979,23 @@ void AmsConfiguration::setUiLanguageChanged() {
|
||||
uiLanguageChanged = true;
|
||||
}
|
||||
|
||||
uint32_t AmsConfiguration::getChipId() {
|
||||
uint32_t chipId;
|
||||
#if defined(ESP32)
|
||||
for(int i=0; i<17; i=i+8) {
|
||||
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
|
||||
}
|
||||
#else
|
||||
chipId = ESP.getChipId();
|
||||
#endif
|
||||
return chipId;
|
||||
}
|
||||
|
||||
void AmsConfiguration::getUniqueName(char* buffer, size_t length) {
|
||||
uint32_t chipId = getChipId();
|
||||
snprintf(buffer, length, "ams-%06x", chipId);
|
||||
}
|
||||
|
||||
void AmsConfiguration::clear() {
|
||||
EEPROM.begin(EEPROM_SIZE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user