Skip to content

Commit d6a1a31

Browse files
committed
Print avg RSSI when checking for roaming
1 parent 634841f commit d6a1a31

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/mgos_wifi_sta.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void mgos_wifi_sta_scan_cb(int num_res, struct mgos_wifi_scan_result *res,
350350
mgos_wifi_sta_build_queue(num_res, res, true /* check_history */, &seen_cfg);
351351
if (SLIST_EMPTY(&s_ap_queue)) {
352352
// No good quality APs left to try, keep trying bad ones.
353-
LOG(LL_INFO, ("Second pass"));
353+
LOG(LL_DEBUG, ("Second pass"));
354354
mgos_wifi_sta_build_queue(num_res, res, false /* check_history */,
355355
&seen_cfg);
356356
}
@@ -461,7 +461,6 @@ static void mgos_wifi_sta_run(int wifi_ev, void *ev_data, bool timeout) {
461461
/* If we are roaming and have no good candidate, go back. */
462462
int cur_rssi = mgos_wifi_sta_get_rssi();
463463
bool ok = false;
464-
s_rssi_info.val <<= 8;
465464
if (ape == NULL || ape->rssi == 0) {
466465
LOG(LL_INFO, ("No candidate APs"));
467466
} else if (s_cur_entry != NULL && memcmp(s_cur_entry->bssid, ape->bssid,
@@ -590,15 +589,13 @@ static void mgos_wifi_sta_run(int wifi_ev, void *ev_data, bool timeout) {
590589
sum += s_rssi_info.samples[i];
591590
}
592591
int avg_rssi = sum / (int) ARRAY_SIZE(s_rssi_info.samples);
593-
int64_t now = mgos_uptime_micros();
594592
if (avg_rssi < roam_rssi_thr &&
595-
(now - s_last_roam_attempt > roam_intvl * 1000000)) {
596-
LOG(LL_INFO,
597-
("Current RSSI %d, will scan for a better AP", cur_rssi));
593+
mgos_uptime_micros() - s_last_roam_attempt > roam_intvl * 1000000) {
594+
LOG(LL_INFO, ("Avg RSSI %d, will scan for a better AP", avg_rssi));
598595
s_roaming = true;
599596
s_state = WIFI_STA_SCAN;
600-
mgos_wifi_sta_set_timeout(true /* run_now */);
601597
s_last_roam_attempt = mgos_uptime_micros();
598+
mgos_wifi_sta_set_timeout(true /* run_now */);
602599
}
603600
}
604601
}

0 commit comments

Comments
 (0)