Only check for "holding down reset button" if button is available

This commit is contained in:
Vegar Westerlund
2019-06-10 11:05:01 +02:00
parent 4fb17239f0
commit e6d0a0915e
2 changed files with 20 additions and 12 deletions

View File

@@ -28,22 +28,28 @@ void HanConfigAp::setup(int accessPointButtonPin, Stream* debugger)
config.load();
if (this->debugger) config.print(this->debugger);
// Test if we're holding down the AP pin, over 5 seconds
int time = millis() + 5000;
print("Press the AP button now to boot as access point");
while (millis() < time)
if (accessPointButtonPin != INVALID_BUTTON_PIN)
{
print(".");
if (digitalRead(accessPointButtonPin) == LOW)
// Assign pin for boot as AP
pinMode(accessPointButtonPin, INPUT_PULLUP);
// Test if we're holding down the AP pin, over 5 seconds
int time = millis() + 5000;
print("Press the AP button now to boot as access point");
while (millis() < time)
{
print("AP button was pressed. Booting as access point now. Look for SSID ");
println(this->AP_SSID);
isActivated = true;
break;
print(".");
if (digitalRead(accessPointButtonPin) == LOW)
{
print("AP button was pressed. Booting as access point now. Look for SSID ");
println(this->AP_SSID);
isActivated = true;
break;
}
delay(100);
}
delay(100);
println("");
}
println("");
}
if (isActivated)

View File

@@ -22,6 +22,8 @@
#include <DNSServer.h>
#include "configuration.h"
#define INVALID_BUTTON_PIN 0xFFFFFFFF
class HanConfigAp {
public:
void setup(int accessPointButtonPin, Stream* debugger);