-
Notifications
You must be signed in to change notification settings - Fork 170
NEMO Portal - Type SSID Using Cardputer Keyboard #69
Changes from all commits
8d0411c
ac34a3d
67a9d8d
2256f54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
#define LOGIN_MESSAGE "Please log in to browse securely." | ||
#define LOGIN_BUTTON "Next" | ||
#define LOGIN_AFTER_MESSAGE "Please wait a few minutes. Soon you will be able to access the internet." | ||
#define TYPE_SSID_TEXT "Lenght between 2 and 32\nInvalid: ?,$,\",[,\\,],+\n\nType the SSID\nPress Enter to Confirm\n\n" | ||
#elif defined(LANGUAGE_PT_BR) | ||
#define LOGIN_TITLE "Fazer login" | ||
#define LOGIN_SUBTITLE "Use sua Conta do Google" | ||
|
@@ -26,6 +27,7 @@ | |
#define LOGIN_MESSAGE "Por favor, faça login para navegar de forma segura." | ||
#define LOGIN_BUTTON "Avançar" | ||
#define LOGIN_AFTER_MESSAGE "Fazendo login..." | ||
#define TYPE_SSID_TEXT "Tamanho entre 2 e 32\nInvalidos: ?,$,\",[,\\,],+\n\nDigite o SSID\nEnter para Confirmar\n\n" | ||
#endif | ||
|
||
int totalCapturedCredentials = 0; | ||
|
@@ -40,13 +42,6 @@ unsigned long bootTime = 0, lastActivity = 0, lastTick = 0, tickCtr = 0; | |
DNSServer dnsServer; | ||
WebServer webServer(80); | ||
|
||
void setupWiFi() { | ||
Serial.println("Initializing WiFi"); | ||
WiFi.mode(WIFI_AP); | ||
WiFi.softAPConfig(AP_GATEWAY, AP_GATEWAY, IPAddress(255, 255, 255, 0)); | ||
WiFi.softAP(apSsidName); | ||
} | ||
|
||
void setSSID(String ssid){ | ||
#if defined USE_EEPROM | ||
Serial.printf("Writing %d bytes of SSID to EEPROM\n", ssid.length()); | ||
|
@@ -62,6 +57,61 @@ void setSSID(String ssid){ | |
return; | ||
} | ||
|
||
void confirmOrTypeSSID(){ | ||
DISP.fillScreen(BLACK); | ||
DISP.setSwapBytes(true); | ||
DISP.setTextSize(MEDIUM_TEXT); | ||
DISP.setTextColor(TFT_RED, BGCOLOR); | ||
DISP.setCursor(0, 0); | ||
DISP.println("WiFi SSID"); | ||
DISP.setTextSize(TINY_TEXT); | ||
DISP.setTextColor(FGCOLOR, BGCOLOR); | ||
DISP.println(TYPE_SSID_TEXT); | ||
DISP.setTextSize(SMALL_TEXT); | ||
uint8_t ssidTextCursorY = DISP.getCursorY(); | ||
String currentSSID = String(apSsidName.c_str()); | ||
DISP.printf("%s", currentSSID.c_str()); | ||
bool ssid_ok = false; | ||
|
||
while(!ssid_ok){ | ||
M5Cardputer.update(); | ||
if(M5Cardputer.Keyboard.isChange() && M5Cardputer.Keyboard.isPressed()) { | ||
Keyboard_Class::KeysState status = M5Cardputer.Keyboard.keysState(); | ||
if(status.del) { | ||
currentSSID.remove(currentSSID.length() - 1); | ||
} | ||
if(status.enter) { | ||
ssid_ok = true; | ||
} | ||
if(currentSSID.length() >= 32) { | ||
continue; | ||
} | ||
for(auto i : status.word) { | ||
if(i != '?' && i != '$' && i != '\"' && i != '[' && i != '\\' && i != ']' && i != '+'){ | ||
currentSSID += i; | ||
} | ||
} | ||
DISP.fillRect(0, ssidTextCursorY, DISP.width(), DISP.width()- ssidTextCursorY, BLACK); | ||
DISP.setCursor(0, ssidTextCursorY); | ||
DISP.printf("%s", currentSSID.c_str()); | ||
} | ||
} | ||
|
||
if(currentSSID != apSsidName && currentSSID.length() > 2){ | ||
setSSID(currentSSID); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will write to EEPROM every single time you start NEMO portal, causing excess EEPROM wear. Additionally, this will cause which ever WiFi you clone from WiFi scanner to be the new default SSID for NEMO Portal even if you don't want it to be. Two changes I would like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice point, @n0xa! I completely agree that EEPROM writing can be optimized by implementing your suggestion 2. Regarding the first suggestion (y/n confirmation), I don't think it would improve the user experience. In fact, I think the current flow is very clean because the previously used SSID will be populated on the screen, so if the user just wants to launch the NEMO Portal, it can simply press Enter and the previous SSID will be used. |
||
} | ||
} | ||
|
||
void setupWiFi() { | ||
Serial.println("Initializing WiFi"); | ||
#if defined(CARDPUTER) | ||
confirmOrTypeSSID(); | ||
#endif // Cardputer | ||
WiFi.mode(WIFI_AP); | ||
WiFi.softAPConfig(AP_GATEWAY, AP_GATEWAY, IPAddress(255, 255, 255, 0)); | ||
WiFi.softAP(apSsidName); | ||
} | ||
|
||
void getSSID(){ | ||
String ssid=""; | ||
#if defined USE_EEPROM | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the concept, but I'd like to set it up so NEMO Portal launches the portal right when you select the menu option. Could we move the SSID Modification flow so when a special button is pressed on a cardputer, we can alter the SSID?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm that is a interesting point, @n0xa.
Thinking about user experience, in my opinion, the SSID definition step wouldn't impact the UX.
In fact, I think the current flow is very clean because the previously used SSID will be populated on the screen, so if the user just wants to launch the NEMO Portal, it can simply press Enter and the previous SSID will be used.
What do you think?