Recover ESP8266 build and ESPWifiManualSetup
#563 Move protocol change method outside of wifimanager scope and correct build error for ESP8266
This commit is contained in:
1 parent
0d486633ed
commit
26501b2176
2 files changed
+22
-22
No files matched your search
+1
-1
@@ -107,7 +107,6 @@ char mqtt_topic[mqtt_topic_max_size] = Base_Topic;
|
|||||||
char gateway_name[parameters_size * 2] = Gateway_Name;
|
char gateway_name[parameters_size * 2] = Gateway_Name;
|
||||||
|
|
||||||
#if defined(ESP8266)||defined(ESP32)
|
#if defined(ESP8266)||defined(ESP32)
|
||||||
#include "esp_wifi.h"
|
|
||||||
#define ATTEMPTS_BEFORE_BG 10 // Number of wifi connection attempts before going to BG protocol
|
#define ATTEMPTS_BEFORE_BG 10 // Number of wifi connection attempts before going to BG protocol
|
||||||
#define ATTEMPTS_BEFORE_B 20 // Number of wifi connection attempts before going to B protocol
|
#define ATTEMPTS_BEFORE_B 20 // Number of wifi connection attempts before going to B protocol
|
||||||
#endif
|
#endif
|
||||||
@@ -115,6 +114,7 @@ char gateway_name[parameters_size * 2] = Gateway_Name;
|
|||||||
// WIFI mode, uncomment to force a wifi mode, if not uncommented the ESP will connect without a mode forced
|
// WIFI mode, uncomment to force a wifi mode, if not uncommented the ESP will connect without a mode forced
|
||||||
// if there is a reconnection issue it will try to connect with G mode and if not working with B mode
|
// if there is a reconnection issue it will try to connect with G mode and if not working with B mode
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
|
#include "esp_wifi.h"
|
||||||
uint8_t wifiProtocol = 0; // default mode, automatic selection
|
uint8_t wifiProtocol = 0; // default mode, automatic selection
|
||||||
//uint8_t wifiProtocol = WIFI_PROTOCOL_11B;
|
//uint8_t wifiProtocol = WIFI_PROTOCOL_11B;
|
||||||
//uint8_t wifiProtocol = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G; // can't have only one https://github.com/espressif/esp-idf/issues/702
|
//uint8_t wifiProtocol = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G; // can't have only one https://github.com/espressif/esp-idf/issues/702
|
||||||
|
|||||||
+21
-21
@@ -134,7 +134,6 @@ int failure_number_mqtt = 0; // number of failure connecting to MQTT
|
|||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include "esp_wifi.h"
|
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
@@ -753,6 +752,27 @@ void setup()
|
|||||||
Log.notice(F("Setup OpenMQTTGateway end" CR));
|
Log.notice(F("Setup OpenMQTTGateway end" CR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ESP8266) || defined(ESP32)
|
||||||
|
// the 2 methods below are used to recover wifi connection by changing the protocols
|
||||||
|
void forceWifiProtocol(){
|
||||||
|
#ifdef ESP32
|
||||||
|
Log.trace(F("ESP32: Forcing to wifi %d" CR), wifiProtocol);
|
||||||
|
esp_wifi_set_protocol(WIFI_IF_STA, wifiProtocol);
|
||||||
|
#elif ESP8266
|
||||||
|
Log.trace(F("ESP8266: Forcing to wifi %d" CR), wifiProtocol);
|
||||||
|
WiFi.setPhyMode((WiFiPhyMode_t)wifiProtocol);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void reinit_wifi()
|
||||||
|
{
|
||||||
|
delay(10);
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
|
if (!wifiProtocol) forceWifiProtocol();
|
||||||
|
WiFi.begin();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ESPWifiManualSetup)
|
#if defined(ESPWifiManualSetup)
|
||||||
void setup_wifi()
|
void setup_wifi()
|
||||||
{
|
{
|
||||||
@@ -843,16 +863,6 @@ void eraseAndRestart()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void forceWifiProtocol(){
|
|
||||||
#ifdef ESP32
|
|
||||||
Log.trace(F("ESP32: Forcing to wifi %d" CR), wifiProtocol);
|
|
||||||
esp_wifi_set_protocol(WIFI_IF_STA, wifiProtocol);
|
|
||||||
#elif ESP8266
|
|
||||||
Log.trace(F("ESP8266: Forcing to wifi %d" CR), wifiProtocol);
|
|
||||||
WiFi.setPhyMode(wifiProtocol);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup_wifimanager(bool reset_settings)
|
void setup_wifimanager(bool reset_settings)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1010,16 +1020,6 @@ void setup_wifimanager(bool reset_settings)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reinit_wifi()
|
|
||||||
{
|
|
||||||
|
|
||||||
delay(10);
|
|
||||||
WiFi.mode(WIFI_STA);
|
|
||||||
if (!wifiProtocol) forceWifiProtocol();
|
|
||||||
WiFi.begin();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // Arduino case
|
#else // Arduino case
|
||||||
void setup_ethernet()
|
void setup_ethernet()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user