Simplify force setup code
And make sure that previous AP is not enabled
This commit is contained in:
parent
4cb6516b75
commit
10e0425acd
@ -94,15 +94,17 @@ void MqttCheckSubscription();
|
|||||||
void MqttChangeGpioValue(int gpio, int value);
|
void MqttChangeGpioValue(int gpio, int value);
|
||||||
bool MqttIsConfigured();
|
bool MqttIsConfigured();
|
||||||
|
|
||||||
void WifiSetup(int bootmode, int forceSetup, char *confSsid, char *confPassword, char *confHost, int ip_config, uint32_t ip, uint32_t gw, uint32_t mask, uint32_t dns, uint32_t dns2) {
|
void WifiSetup(int bootmode, char *confSsid, char *confPassword, char *confHost, int ip_config, uint32_t ip, uint32_t gw, uint32_t mask, uint32_t dns, uint32_t dns2) {
|
||||||
IPAddress myIP;
|
IPAddress myIP;
|
||||||
if (bootmode == BOOTMODE_SETUP || forceSetup) {
|
if (bootmode == BOOTMODE_SETUP) {
|
||||||
SKETCH_DEBUG_PRINT("Configuring access point...");
|
SKETCH_DEBUG_PRINT("Configuring access point...");
|
||||||
SKETCH_DEBUG_PRINTLN(ssid);
|
SKETCH_DEBUG_PRINTLN(ssid);
|
||||||
/* You can set a password to the AP here */
|
/* You can set a password to the AP here */
|
||||||
WiFi.softAP(ssid);
|
WiFi.softAP(ssid);
|
||||||
myIP = WiFi.softAPIP();
|
myIP = WiFi.softAPIP();
|
||||||
} else {
|
} else {
|
||||||
|
SKETCH_DEBUG_PRINTLN("Disable previous AP mode ");
|
||||||
|
WiFi.softAPdisconnect(true);
|
||||||
SKETCH_DEBUG_PRINTLN("Connecting to Wifi...");
|
SKETCH_DEBUG_PRINTLN("Connecting to Wifi...");
|
||||||
if(ip_config == 1){
|
if(ip_config == 1){
|
||||||
SKETCH_DEBUG_PRINTLN("Use static ip configuration");
|
SKETCH_DEBUG_PRINTLN("Use static ip configuration");
|
||||||
@ -232,8 +234,11 @@ void setup() {
|
|||||||
SKETCH_DEBUG_PRINT("Force Setup Mode ? :");
|
SKETCH_DEBUG_PRINT("Force Setup Mode ? :");
|
||||||
SKETCH_DEBUG_PRINT(txStatus ? "No" : "Yes");
|
SKETCH_DEBUG_PRINT(txStatus ? "No" : "Yes");
|
||||||
SKETCH_DEBUG_PRINTLN();
|
SKETCH_DEBUG_PRINTLN();
|
||||||
|
if(txStatus == 0){
|
||||||
|
mode = BOOTMODE_SETUP;
|
||||||
|
}
|
||||||
|
|
||||||
WifiSetup(mode, txStatus == 0, confSsid, confPassword, confHost, ip_mode, ip, gw, mask, dns, dns2);
|
WifiSetup(mode, confSsid, confPassword, confHost, ip_mode, ip, gw, mask, dns, dns2);
|
||||||
if (mode == BOOTMODE_NORMAL) {
|
if (mode == BOOTMODE_NORMAL) {
|
||||||
MqttSetup(mqttServer, mqttUser, mqttPasswd, mqttPort, confHost);
|
MqttSetup(mqttServer, mqttUser, mqttPasswd, mqttPort, confHost);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user