diff --git a/src/main.cpp b/src/main.cpp index 59773e2b..951d27a7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -241,7 +241,7 @@ class ButtonThread : public OSThread } #endif } else { - //DEBUG_MSG("Long press %u\n", (millis() - longPressTime)); + // DEBUG_MSG("Long press %u\n", (millis() - longPressTime)); } } @@ -298,6 +298,21 @@ void setup() digitalWrite(RESET_OLED, 1); #endif + // If BUTTON_PIN is held down during the startup process, + // force the device to go into a SoftAP mode. + bool forceSoftAP = 0; +#ifdef BUTTON_PIN +#ifndef NO_ESP32 + pinMode(BUTTON_PIN, INPUT); + + // BUTTON_PIN is pulled high by a 12k resistor. + if (!digitalRead(BUTTON_PIN)) { + forceSoftAP = 1; + } + +#endif +#endif + OSThread::setup(); ledPeriodic = new Periodic("Blink", ledBlinker); @@ -466,6 +481,13 @@ void setup() } #endif + if (forceSoftAP == false) { + strcpy(radioConfig.preferences.wifi_ssid, "meshtasticAdmin"); + strcpy(radioConfig.preferences.wifi_password, "12345678"); + radioConfig.preferences.wifi_ap_mode = true; + DEBUG_MSG("Forcing SoftAP\n"); + } + // Initialize Wifi initWifi();