Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quick wifi connect using saved AP parameters #17

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Add support for up to four MQTT GroupTopics using the same optional Device Group names (#8014)
- Add console command history (#7483, #8015)
- Add support for longer template names
- Add quick wifi connect using saved AP parameters when ``SetOption56 0`` (#3189)
1 change: 1 addition & 0 deletions tasmota/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Add command ``Sensor10 0/1/2`` to control BH1750 resolution - 0 = High (default), 1 = High2, 2 = Low (#8016)
- Add command ``Sensor10 31..254`` to control BH1750 measurement time which defaults to 69 (#8016)
- Add command ``SetOption91 1`` to enable fading at startup / power on
- Add quick wifi connect using saved AP parameters when ``SetOption56 0`` (#3189)

### 8.2.0.2 20200328

Expand Down
4 changes: 3 additions & 1 deletion tasmota/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,10 @@ struct SYSCFG {
uint8_t bri_preset_low; // F06
uint8_t bri_preset_high; // F07
int8_t hum_comp; // F08
uint8_t channel; // F09
uint8_t bssid[6]; // F0A

uint8_t free_f09[175]; // F09
uint8_t free_f10[168]; // F10

uint16_t pulse_counter_debounce_low; // FB8
uint16_t pulse_counter_debounce_high; // FBA
Expand Down
10 changes: 9 additions & 1 deletion tasmota/support_wifi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ void WifiCheckIp(void)
Settings.ip_address[1] = (uint32_t)WiFi.gatewayIP();
Settings.ip_address[2] = (uint32_t)WiFi.subnetMask();
Settings.ip_address[3] = (uint32_t)WiFi.dnsIP();

// Save current AP parameters for quick reconnect
Settings.channel = WiFi.channel();
uint8_t *bssid = WiFi.BSSID();
memcpy((void*) &Settings.bssid, (void*) bssid, sizeof(Settings.bssid));
}
Wifi.status = WL_CONNECTED;
#ifdef USE_DISCOVERY
Expand All @@ -423,6 +428,7 @@ void WifiCheckIp(void)
break;
case WL_NO_SSID_AVAIL:
AddLog_P(LOG_LEVEL_INFO, S_LOG_WIFI, PSTR(D_CONNECT_FAILED_AP_NOT_REACHED));
Settings.channel = 0; // Disable stored AP
if (WIFI_WAIT == Settings.sta_config) {
Wifi.retry = Wifi.retry_init;
} else {
Expand Down Expand Up @@ -462,7 +468,7 @@ void WifiCheckIp(void)
}
} else {
if (Wifi.retry_init == Wifi.retry) {
WifiBegin(3, 0); // Select default SSID
WifiBegin(3, Settings.channel); // Select default SSID
}
if ((Settings.sta_config != WIFI_WAIT) && ((Wifi.retry_init / 2) == Wifi.retry)) {
WifiBegin(2, 0); // Select alternate SSID
Expand Down Expand Up @@ -650,6 +656,8 @@ void WifiConnect(void)
Wifi.retry = Wifi.retry_init;
Wifi.counter = 1;

memcpy((void*) &Wifi.bssid, (void*) Settings.bssid, sizeof(Wifi.bssid));

#ifdef WIFI_RF_PRE_INIT
if (rf_pre_init_flag) {
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Pre-init done"));
Expand Down