Browse Source

lock ap channel for faster reconnect

main
Hendrik Langer 5 years ago
parent
commit
2f54640b29
  1. 6
      src/main.cpp

6
src/main.cpp

@ -106,6 +106,7 @@ unsigned long lastSuccess = 0;
IPAddress ip, dns, gateway, subnet;
char ssid[64];
char password[64];
int32_t channel;
struct __attribute__((packed)) SENSOR_DATA {
float temperature;
@ -282,6 +283,8 @@ void ICACHE_FLASH_ATTR sendValues() {
WiFi.forceSleepWake();
delay(1); // yield();
WiFi.mode(WIFI_STA);
//wifi_country_t wc = { .cc="DE", .schan=1, .nchan=13, .policy=WIFI_COUNTRY_POLICY_AUTO};
//wifi_set_country(&wc);
if ( ip != INADDR_NONE && dns != INADDR_NONE && gateway != INADDR_NONE && subnet != INADDR_NONE
&& ((ip[0] == 192 && ip[1] == 168) || (ip[0] == 172 && ip[1] == 16))
@ -291,7 +294,7 @@ void ICACHE_FLASH_ATTR sendValues() {
DEBUG_MSG("[WiFi] STATIC IP\n");
WiFi.config(ip, dns, gateway, subnet);
WiFi.begin(ssid, password);
WiFi.begin(ssid, password, channel);
int tries = 0;
constexpr unsigned int retry_delay = 500;
constexpr unsigned int max_retry_delay = 10000;
@ -335,6 +338,7 @@ void ICACHE_FLASH_ATTR sendValues() {
subnet = WiFi.subnetMask();
strncpy(ssid, WiFi.SSID().c_str(), 64);
strncpy(password, WiFi.psk().c_str(), 64);
channel = WiFi.channel();
last_dhcp = rtcMillis();
}

Loading…
Cancel
Save