Faster wifi connecting (up to 2sec restart -> connected) (#1297)

* Wifi fast connect + extra

* --
This commit is contained in:
NonPIayerCharacter
2025-04-15 17:38:10 +03:00
committed by GitHub
parent 714d9c9ab1
commit ac3c5d6da6
19 changed files with 542 additions and 158 deletions

View File

@ -1416,6 +1416,7 @@ int http_fn_cfg_wifi(http_request_t* request) {
rtw_scan_result_t* record = &result->ap_details;
record->SSID.val[record->SSID.len] = 0;
hprintf255(request, "SSID: %s, Channel: %i, Signal %i<br>", record->SSID.val, record->channel, record->signal_strength);
return 0;
}
scan_hdl = xSemaphoreCreateBinary();
@ -1527,6 +1528,7 @@ int http_fn_cfg_wifi_set(http_request_t* request) {
bChanged |= CFG_SetWiFiPass(tmpA);
}
poststr(request, "WiFi mode set: connect to WLAN.");
if(bChanged) HAL_DisableEnhancedFastConnect();
}
if (http_getArg(request->url, "ssid2", tmpA, sizeof(tmpA))) {
bChanged |= CFG_SetWiFiSSID2(tmpA);
@ -2220,7 +2222,7 @@ void doHomeAssistantDiscovery(const char* topic, http_request_t* request) {
}
}
}
if (1) {
if(CFG_HasFlag(OBK_FLAG_MQTT_BROADCASTSELFSTATEPERMINUTE) || CFG_HasFlag(OBK_FLAG_MQTT_BROADCASTSELFSTATEONCONNECT)) {
//use -1 for channel as these don't correspond to channels
#ifndef NO_CHIP_TEMPERATURE
dev_info = hass_init_sensor_device_info(HASS_TEMP, -1, -1, -1, 1);
@ -2872,6 +2874,7 @@ const char* g_obk_flagNames[] = {
"[PWR] Invert AC dir",
"[HTTP] Hide ON/OFF for relays (only red/green buttons)",
"[MQTT] Never add get sufix",
"[WiFi] (RTL/BK) Enhanced fast connect by saving AP data to flash (preferable with Flag 37 & static ip). Quick reset 3 times to connect normally",
"error",
"error",
"error",

View File

@ -97,9 +97,10 @@ extern uint32_t current_fw_idx;
#include "wdt_api.h"
extern uint32_t current_fw_idx;
extern uint8_t flash_size_8720;
#undef DEFAULT_FLASH_LEN
#define DEFAULT_FLASH_LEN 0x400000
#define DEFAULT_FLASH_LEN (flash_size_8720 << 20)
#endif
@ -2778,6 +2779,13 @@ update_ota_exit:
goto update_ota_exit;
}
if(flash_size_8720 == 2)
{
ADDLOG_ERROR(LOG_FEATURE_OTA, "Only 2MB flash detected - OTA is not supported");
ret = -1;
goto update_ota_exit;
}
memset((uint8_t*)&OtaTargetHdr, 0, sizeof(update_ota_target_hdr));
DBG_INFO_MSG_OFF(MODULE_FLASH);
@ -2818,7 +2826,7 @@ update_ota_exit:
goto update_ota_exit;
}
ADDLOG_INFO(LOG_FEATURE_OTA, "Erasing...");
//ADDLOG_INFO(LOG_FEATURE_OTA, "Erasing...");
for(int i = 0; i < OtaTargetHdr.ValidImgCnt; i++)
{
ADDLOG_INFO(LOG_FEATURE_OTA, "Target addr:0x%08x, img len: %i", OtaTargetHdr.FileImgHdr[i].FlashAddr, OtaTargetHdr.FileImgHdr[i].ImgLen);