Improve setup-WiFi password generation
This commit is contained in:
parent
7a1ce54248
commit
5425ea7fbf
2 changed files with 27 additions and 12 deletions
|
@ -62,7 +62,7 @@ void setup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tryImprovSetup();
|
setupWifi();
|
||||||
|
|
||||||
setupWebserver();
|
setupWebserver();
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void setup()
|
||||||
forceFullRefresh();
|
forceFullRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tryImprovSetup()
|
void setupWifi()
|
||||||
{
|
{
|
||||||
WiFi.onEvent(WiFiEvent);
|
WiFi.onEvent(WiFiEvent);
|
||||||
WiFi.setAutoConnect(true);
|
WiFi.setAutoConnect(true);
|
||||||
|
@ -140,10 +140,10 @@ void tryImprovSetup()
|
||||||
String softAP_SSID =
|
String softAP_SSID =
|
||||||
String("BTClock" + String(mac[5], 16) + String(mac[1], 16));
|
String("BTClock" + String(mac[5], 16) + String(mac[1], 16));
|
||||||
WiFi.setHostname(softAP_SSID.c_str());
|
WiFi.setHostname(softAP_SSID.c_str());
|
||||||
String softAP_password =
|
String softAP_password = replaceAmbiguousChars(
|
||||||
base64::encode(String(mac[2], 16) + String(mac[4], 16) +
|
base64::encode(String(mac[2], 16) + String(mac[4], 16) +
|
||||||
String(mac[5], 16) + String(mac[1], 16))
|
String(mac[5], 16) + String(mac[1], 16))
|
||||||
.substring(2, 10);
|
.substring(2, 10));
|
||||||
|
|
||||||
wm.setConfigPortalTimeout(preferences.getUInt("wpTimeout", DEFAULT_WP_TIMEOUT));
|
wm.setConfigPortalTimeout(preferences.getUInt("wpTimeout", DEFAULT_WP_TIMEOUT));
|
||||||
wm.setWiFiAutoReconnect(false);
|
wm.setWiFiAutoReconnect(false);
|
||||||
|
@ -274,9 +274,8 @@ void setupPreferences()
|
||||||
else
|
else
|
||||||
setCurrentCurrency(CURRENCY_USD);
|
setCurrentCurrency(CURRENCY_USD);
|
||||||
|
|
||||||
|
|
||||||
addScreenMapping(SCREEN_BLOCK_HEIGHT, "Block Height");
|
addScreenMapping(SCREEN_BLOCK_HEIGHT, "Block Height");
|
||||||
|
|
||||||
addScreenMapping(SCREEN_TIME, "Time");
|
addScreenMapping(SCREEN_TIME, "Time");
|
||||||
addScreenMapping(SCREEN_HALVING_COUNTDOWN, "Halving countdown");
|
addScreenMapping(SCREEN_HALVING_COUNTDOWN, "Halving countdown");
|
||||||
addScreenMapping(SCREEN_BLOCK_FEE_RATE, "Block Fee Rate");
|
addScreenMapping(SCREEN_BLOCK_FEE_RATE, "Block Fee Rate");
|
||||||
|
@ -285,7 +284,6 @@ void setupPreferences()
|
||||||
addScreenMapping(SCREEN_BTC_TICKER, "Ticker");
|
addScreenMapping(SCREEN_BTC_TICKER, "Ticker");
|
||||||
addScreenMapping(SCREEN_MARKET_CAP, "Market Cap");
|
addScreenMapping(SCREEN_MARKET_CAP, "Market Cap");
|
||||||
|
|
||||||
|
|
||||||
// addScreenMapping(SCREEN_SATS_PER_CURRENCY_USD, "Sats per USD");
|
// addScreenMapping(SCREEN_SATS_PER_CURRENCY_USD, "Sats per USD");
|
||||||
// addScreenMapping(SCREEN_BTC_TICKER_USD, "Ticker USD");
|
// addScreenMapping(SCREEN_BTC_TICKER_USD, "Ticker USD");
|
||||||
// addScreenMapping(SCREEN_MARKET_CAP_USD, "Market Cap USD");
|
// addScreenMapping(SCREEN_MARKET_CAP_USD, "Market Cap USD");
|
||||||
|
@ -302,7 +300,7 @@ void setupPreferences()
|
||||||
// screenNameMap[SCREEN_HALVING_COUNTDOWN] = "Halving countdown";
|
// screenNameMap[SCREEN_HALVING_COUNTDOWN] = "Halving countdown";
|
||||||
// screenNameMap[SCREEN_MARKET_CAP] = "Market Cap";
|
// screenNameMap[SCREEN_MARKET_CAP] = "Market Cap";
|
||||||
|
|
||||||
//addCurrencyMappings(getActiveCurrencies());
|
// addCurrencyMappings(getActiveCurrencies());
|
||||||
|
|
||||||
if (preferences.getBool("bitaxeEnabled", DEFAULT_BITAXE_ENABLED))
|
if (preferences.getBool("bitaxeEnabled", DEFAULT_BITAXE_ENABLED))
|
||||||
{
|
{
|
||||||
|
@ -311,6 +309,19 @@ void setupPreferences()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String replaceAmbiguousChars(String input)
|
||||||
|
{
|
||||||
|
const char *ambiguous = "1IlO0";
|
||||||
|
const char *replacements = "LKQM8";
|
||||||
|
|
||||||
|
for (int i = 0; i < strlen(ambiguous); i++)
|
||||||
|
{
|
||||||
|
input.replace(ambiguous[i], replacements[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
// void addCurrencyMappings(const std::vector<std::string>& currencies)
|
// void addCurrencyMappings(const std::vector<std::string>& currencies)
|
||||||
// {
|
// {
|
||||||
// for (const auto& currency : currencies)
|
// for (const auto& currency : currencies)
|
||||||
|
@ -375,9 +386,12 @@ void setupPreferences()
|
||||||
|
|
||||||
void setupWebsocketClients(void *pvParameters)
|
void setupWebsocketClients(void *pvParameters)
|
||||||
{
|
{
|
||||||
if (preferences.getBool("ownDataSource", DEFAULT_OWN_DATA_SOURCE)) {
|
if (preferences.getBool("ownDataSource", DEFAULT_OWN_DATA_SOURCE))
|
||||||
|
{
|
||||||
setupV2Notify();
|
setupV2Notify();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
setupBlockNotify();
|
setupBlockNotify();
|
||||||
setupPriceNotify();
|
setupPriceNotify();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ uint getLastTimeSync();
|
||||||
void setupPreferences();
|
void setupPreferences();
|
||||||
void setupWebsocketClients(void *pvParameters);
|
void setupWebsocketClients(void *pvParameters);
|
||||||
void setupHardware();
|
void setupHardware();
|
||||||
void tryImprovSetup();
|
void setupWifi();
|
||||||
void setupTimers();
|
void setupTimers();
|
||||||
void finishSetup();
|
void finishSetup();
|
||||||
void setupMcp();
|
void setupMcp();
|
||||||
|
@ -81,4 +81,5 @@ void addScreenMapping(int value, const char* name);
|
||||||
// void addScreenMapping(int value, const String& name);
|
// void addScreenMapping(int value, const String& name);
|
||||||
// void addScreenMapping(int value, const std::string& name);
|
// void addScreenMapping(int value, const std::string& name);
|
||||||
|
|
||||||
int findScreenIndexByValue(int value);
|
int findScreenIndexByValue(int value);
|
||||||
|
String replaceAmbiguousChars(String input);
|
Loading…
Reference in a new issue