mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
optional wifi tweaks - #725
This commit is contained in:
@@ -31,36 +31,13 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
switch (event) {
|
switch (event) {
|
||||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||||
EMSESP::logger().info(F("WiFi Disconnected. Reason code=%d"), info.disconnected.reason);
|
EMSESP::logger().info(F("WiFi Disconnected. Reason code=%d"), info.disconnected.reason);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSTEM_EVENT_STA_GOT_IP:
|
case SYSTEM_EVENT_STA_GOT_IP:
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
EMSESP::logger().info(F("WiFi Connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
|
EMSESP::logger().info(F("WiFi Connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
|
||||||
#endif
|
#endif
|
||||||
|
EMSESP::system_.wifi_tweak();
|
||||||
/*
|
|
||||||
|
|
||||||
// Lower WiFi tx power to free up current for bus-powered
|
|
||||||
// WIFI_POWER_19_5dBm = 78,// 19.5dBm <-- default
|
|
||||||
// WIFI_POWER_19dBm = 76,// 19dBm
|
|
||||||
// WIFI_POWER_18_5dBm = 74,// 18.5dBm
|
|
||||||
// WIFI_POWER_17dBm = 68,// 17dBm
|
|
||||||
// WIFI_POWER_15dBm = 60,// 15dBm
|
|
||||||
// WIFI_POWER_13dBm = 52,// 13dBm
|
|
||||||
// WIFI_POWER_11dBm = 44,// 11dBm
|
|
||||||
// WIFI_POWER_8_5dBm = 34,// 8.5dBm
|
|
||||||
// WIFI_POWER_7dBm = 28,// 7dBm
|
|
||||||
// WIFI_POWER_5dBm = 20,// 5dBm
|
|
||||||
// WIFI_POWER_2dBm = 8,// 2dBm
|
|
||||||
// WIFI_POWER_MINUS_1dBm = -4// -1dBm
|
|
||||||
|
|
||||||
wifi_power_t a1 = WiFi.getTxPower();
|
|
||||||
bool ok = WiFi.setTxPower(WIFI_POWER_19_5dBm);
|
|
||||||
wifi_power_t a2 = WiFi.getTxPower();
|
|
||||||
LOG_INFO("Adjusting Wifi Tx power from %d to %d (%s)", a1, a2, ok ? "ok" : "failed");
|
|
||||||
*/
|
|
||||||
|
|
||||||
EMSESP::system_.send_heartbeat();
|
EMSESP::system_.send_heartbeat();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,33 @@ void System::get_settings() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// adjust WiFi settings
|
||||||
|
// this for problem solving mesh and connection issues, and also get EMS bus-powered more stable by lowering power
|
||||||
|
void System::wifi_tweak() {
|
||||||
|
#if defined(EMSESP_WIFI_TWEAK)
|
||||||
|
// Default Tx Power is 80 = 20dBm <-- default
|
||||||
|
// WIFI_POWER_19_5dBm = 78,// 19.5dBm
|
||||||
|
// WIFI_POWER_19dBm = 76,// 19dBm
|
||||||
|
// WIFI_POWER_18_5dBm = 74,// 18.5dBm
|
||||||
|
// WIFI_POWER_17dBm = 68,// 17dBm
|
||||||
|
// WIFI_POWER_15dBm = 60,// 15dBm
|
||||||
|
// WIFI_POWER_13dBm = 52,// 13dBm
|
||||||
|
// WIFI_POWER_11dBm = 44,// 11dBm
|
||||||
|
// WIFI_POWER_8_5dBm = 34,// 8.5dBm
|
||||||
|
// WIFI_POWER_7dBm = 28,// 7dBm
|
||||||
|
// WIFI_POWER_5dBm = 20,// 5dBm
|
||||||
|
// WIFI_POWER_2dBm = 8,// 2dBm
|
||||||
|
// WIFI_POWER_MINUS_1dBm = -4// -1dBm
|
||||||
|
wifi_power_t p1 = WiFi.getTxPower();
|
||||||
|
bool pok = WiFi.setTxPower(WIFI_POWER_19_5dBm);
|
||||||
|
wifi_power_t p2 = WiFi.getTxPower();
|
||||||
|
bool s1 = WiFi.getSleep();
|
||||||
|
WiFi.setSleep(false); // turn off sleep - WIFI_PS_NONE
|
||||||
|
bool s2 = WiFi.getSleep();
|
||||||
|
LOG_INFO(F("Adjusting Wifi - Tx power %d->%d, Sleep %d->%d"), p1, p2, s1, s2);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// first call. Sets memory and starts up the UART Serial bridge
|
// first call. Sets memory and starts up the UART Serial bridge
|
||||||
void System::start(uint32_t heap_start) {
|
void System::start(uint32_t heap_start) {
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class System {
|
|||||||
bool upload_status();
|
bool upload_status();
|
||||||
void show_mem(const char * note);
|
void show_mem(const char * note);
|
||||||
void get_settings();
|
void get_settings();
|
||||||
|
void wifi_tweak();
|
||||||
|
|
||||||
void led_init(bool refresh);
|
void led_init(bool refresh);
|
||||||
void syslog_init(bool refresh);
|
void syslog_init(bool refresh);
|
||||||
|
|||||||
Reference in New Issue
Block a user