AmendHub

Download:

jcs

/

wifi_da

/

amendments

/

19

main: Do a periodic scan every 30 seconds to update SSID list

Also some logger tweaks

jcs made amendment 19 11 months ago
--- main.c Tue Oct 24 10:20:44 2023 +++ main.c Tue Oct 24 23:10:32 2023 @@ -234,35 +234,45 @@ void handle_timer(void) { static long last_update = 0; + static long last_scan = 0; if (!win) return; - DEBUG_LOG(("%ld - handle_timer", Ticks)); - switch (da_state) { case STATE_SCANNING: /* check every second */ if ((Ticks - last_update) < (60 * 1)) break; + DEBUG_LOG(("%ld - handle_timer - checking for scan completion", + Ticks)); last_update = Ticks; if (!scsi_wifi_scan_finished(wifi_scsi_id)) { + DEBUG_LOG(("%ld - handle_timer - scan not done", Ticks)); if (Time - wifi_scan_started <= 5) break; warn("Wi-Fi scan failed to finish, canceling"); } + last_scan = Ticks; da_state = STATE_IDLE; + DEBUG_LOG(("%ld - handle_timer - scan done, updating list", Ticks)); update_wifi_ssid_list(true); break; case STATE_IDLE: - /* refresh RSSI every 5 seconds */ + /* refresh SSID/RSSI every 5 seconds, scan every 30 */ if ((Ticks - last_update) < (60 * 5)) break; last_update = Ticks; - update_wifi_cur_info(); + + if ((Ticks - last_scan) > (60 * 30)) { + da_state = STATE_SCANNING; + DEBUG_LOG(("%ld - handle_timer - idle, scanning", Ticks)); + scsi_wifi_scan(wifi_scsi_id); + } else { + DEBUG_LOG(("%ld - handle_timer - idle, updating info", Ticks)); + update_wifi_cur_info(); + } break; - default: - return; } } @@ -291,12 +301,19 @@ logger_vprintf(const char *format, va_list ap) GetPort(&savePort); SetPort(logger); + + if (logger_y >= (logger->portRect.bottom - logger->portRect.top)) { + EraseRect(&logger->portRect); + logger_y = 12; + } + MoveTo(4, logger_y); TextFont(geneva); TextSize(9); DrawText(buf, 0, len); logger_y += 10; + ValidRect(&logger->portRect); SetPort(savePort); } #endif