Skip to content

Commit

Permalink
Home Accessory Architect v12.4.4 Merlin
Browse files Browse the repository at this point in the history
  • Loading branch information
RavenSystem committed May 30, 2023
1 parent 4941a52 commit f8baa9f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 44 deletions.
2 changes: 1 addition & 1 deletion HAA/HAA_Installer/main/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

#include "../../common/common_headers.h"

#define INSTALLER_VERSION "7.2.2"
#define INSTALLER_VERSION "7.2.3"

#endif // __HAA_OTA_HEADER_H__
18 changes: 5 additions & 13 deletions HAA/HAA_Installer/main/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static void wifi_smart_connect_task(void* arg) {

INFO("Best %02x%02x%02x%02x%02x%02x", best_bssid[0], best_bssid[1], best_bssid[2], best_bssid[3], best_bssid[4], best_bssid[5]);

sysparam_set_blob(WIFI_BSSID_SYSPARAM, best_bssid, (size_t) 6);
sysparam_set_blob(WIFI_BSSID_SYSPARAM, best_bssid, 6);

sdk_wifi_station_disconnect();

Expand All @@ -238,13 +238,7 @@ static void wifi_smart_connect_task(void* arg) {
#ifdef ESP_PLATFORM
wifi_config_t sta_config = {
.sta = {
.password = "",
.scan_method = WIFI_ALL_CHANNEL_SCAN,
.rm_enabled = 1,
.btm_enabled = 1 ,
.mbo_enabled = 1,
.pmf_cfg.capable = 1,
.ft_enabled = 1,
.bssid_set = 1,
},
};
Expand Down Expand Up @@ -372,8 +366,7 @@ static void wifi_scan_sc_done(void* arg, sdk_scan_status_t status) {
}

uint8_t *wifi_bssid = NULL;
size_t len = 6;
sysparam_get_blob(WIFI_BSSID_SYSPARAM, &wifi_bssid, &len);
sysparam_get_blob(WIFI_BSSID_SYSPARAM, &wifi_bssid, NULL);

free(wifi_ssid);

Expand Down Expand Up @@ -874,13 +867,13 @@ static void wifi_config_server_on_settings_update_task(void* args) {
bssid[i] = (uint8_t) strtol(hex, NULL, 16);
}

sysparam_set_blob(WIFI_BSSID_SYSPARAM, bssid, (size_t) 6);
sysparam_set_blob(WIFI_BSSID_SYSPARAM, bssid, 6);

} else {
sysparam_erase(WIFI_BSSID_SYSPARAM);
}

if (password_param->value) {
if (password_param && password_param->value) {
sysparam_set_string(WIFI_PASSWORD_SYSPARAM, password_param->value);
} else {
sysparam_set_string(WIFI_PASSWORD_SYSPARAM, "");
Expand Down Expand Up @@ -1303,8 +1296,7 @@ static uint8_t wifi_config_connect(const uint8_t phy) {
sysparam_get_int8(WIFI_MODE_SYSPARAM, &wifi_mode);

uint8_t *wifi_bssid = NULL;
size_t len = 6;
sysparam_get_blob(WIFI_BSSID_SYSPARAM, &wifi_bssid, &len);
sysparam_get_blob(WIFI_BSSID_SYSPARAM, &wifi_bssid, NULL);

INFO_NNL("BSSID ");
if (wifi_bssid) {
Expand Down
2 changes: 1 addition & 1 deletion HAA/HAA_Main/main/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "../../common/common_headers.h"

// Version
#define HAA_FIRMWARE_VERSION "12.4.3"
#define HAA_FIRMWARE_VERSION "12.4.4"
#define HAA_FIRMWARE_BETA_REVISION ""
#define HAA_FIRMWARE_CODENAME "Merlin"

Expand Down
38 changes: 24 additions & 14 deletions HAA/HAA_Main/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,8 @@ void wifi_ping_gw_task() {
vTaskDelete(NULL);
}

void wifi_reconnection_task(void* args) {
if (main_config.wifi_status > WIFI_STATUS_DISCONNECTED) {
void wifi_reconnection_task() {
if (main_config.wifi_status == WIFI_STATUS_CONNECTED) {
sdk_wifi_station_disconnect();
sdk_wifi_station_connect();
main_config.wifi_status = WIFI_STATUS_CONNECTING;
Expand Down Expand Up @@ -970,6 +970,9 @@ void wifi_reconnection_task(void* args) {
led_blink(3);

do_actions(ch_group_find_by_serv(SERV_TYPE_ROOT_DEVICE), 5);

} else if ((main_config.wifi_error_count % 30) == 0) {
main_config.wifi_status = WIFI_STATUS_DISCONNECTED;
}
}

Expand All @@ -979,10 +982,14 @@ void wifi_reconnection_task(void* args) {
vTaskDelete(NULL);
}

void set_main_wifi_status_connecting() {
main_config.wifi_status = WIFI_STATUS_CONNECTING;
}

void wifi_watchdog() {
//INFO("Wifi status %i, sleep mode %i", main_config.wifi_status, sdk_wifi_get_sleep_type());
const int current_ip = wifi_config_get_ip();
if (current_ip >= 0 && main_config.wifi_error_count <= main_config.wifi_ping_max_errors) {
if (main_config.wifi_status == WIFI_STATUS_CONNECTED && current_ip >= 0 && main_config.wifi_error_count <= main_config.wifi_ping_max_errors) {
#ifdef ESP_PLATFORM
uint8_t channel_primary = main_config.wifi_channel;
esp_wifi_get_channel(&channel_primary, NULL);
Expand All @@ -993,15 +1000,19 @@ void wifi_watchdog() {

if (main_config.wifi_mode == 3) {
if (main_config.wifi_roaming_count == 0) {
rs_esp_timer_change_period(WIFI_WATCHDOG_TIMER, WIFI_WATCHDOG_POLL_PERIOD_MS);
if (rs_esp_timer_change_period(WIFI_WATCHDOG_TIMER, WIFI_WATCHDOG_POLL_PERIOD_MS) != pdPASS) {
return;
}
}

main_config.wifi_roaming_count++;

if (main_config.wifi_roaming_count >= WIFI_WATCHDOG_ROAMING_PERIOD) {
rs_esp_timer_change_period(WIFI_WATCHDOG_TIMER, 5000);
main_config.wifi_roaming_count = 0;
wifi_config_smart_connect();
if (rs_esp_timer_change_period(WIFI_WATCHDOG_TIMER, 8000) == pdPASS) {
main_config.wifi_roaming_count = 0;
wifi_config_smart_connect();
return;
}
} else {
main_config.wifi_roaming_count++;
}
}

Expand Down Expand Up @@ -1035,17 +1046,16 @@ void wifi_watchdog() {
}

} else {
ERROR("Wifi error");
ERROR("Wifi");

uint32_t force_disconnect = 0;
if (main_config.wifi_error_count > main_config.wifi_ping_max_errors) {
force_disconnect = 1;
if ((main_config.wifi_status == WIFI_STATUS_CONNECTED && main_config.wifi_mode >= 2) ||
main_config.wifi_error_count > main_config.wifi_ping_max_errors) {
main_config.wifi_status = WIFI_STATUS_DISCONNECTED;
}

main_config.wifi_error_count = 0;

if (xTaskCreate(wifi_reconnection_task, "RCN", WIFI_RECONNECTION_TASK_SIZE, (void*) force_disconnect, WIFI_RECONNECTION_TASK_PRIORITY, NULL) != pdPASS) {
if (xTaskCreate(wifi_reconnection_task, "RCN", WIFI_RECONNECTION_TASK_SIZE, NULL, WIFI_RECONNECTION_TASK_PRIORITY, NULL) != pdPASS) {
ERROR("New RCN");
homekit_remove_oldest_client();
}
Expand Down
24 changes: 10 additions & 14 deletions HAA/HAA_Main/main/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@

#include "header.h"

#include "main.h"

#define SETUP_ANNOUNCER_DESTINATION "255.255.255.255"
#define SETUP_ANNOUNCER_PORT "4567"

Expand Down Expand Up @@ -261,10 +263,12 @@ static void wifi_smart_connect_task(void* arg) {

INFO("Best %02x%02x%02x%02x%02x%02x", best_bssid[0], best_bssid[1], best_bssid[2], best_bssid[3], best_bssid[4], best_bssid[5]);

sysparam_set_blob(WIFI_BSSID_SYSPARAM, best_bssid, (size_t) 6);
sysparam_set_blob(WIFI_BSSID_SYSPARAM, best_bssid, 6);

sdk_wifi_station_disconnect();

set_main_wifi_status_connecting();

char* wifi_ssid = NULL;
sysparam_get_string(WIFI_SSID_SYSPARAM, &wifi_ssid);

Expand All @@ -274,13 +278,7 @@ static void wifi_smart_connect_task(void* arg) {
#ifdef ESP_PLATFORM
wifi_config_t sta_config = {
.sta = {
.password = "",
.scan_method = WIFI_ALL_CHANNEL_SCAN,
.rm_enabled = 1,
.btm_enabled = 1 ,
.mbo_enabled = 1,
.pmf_cfg.capable = 1,
.ft_enabled = 1,
.bssid_set = 1,
},
};
Expand Down Expand Up @@ -407,9 +405,8 @@ static void wifi_scan_sc_done(void* arg, sdk_scan_status_t status) {
return;
}

uint8_t *wifi_bssid = NULL;
size_t len = 6;
sysparam_get_blob(WIFI_BSSID_SYSPARAM, &wifi_bssid, &len);
uint8_t* wifi_bssid = NULL;
sysparam_get_blob(WIFI_BSSID_SYSPARAM, &wifi_bssid, NULL);

free(wifi_ssid);

Expand Down Expand Up @@ -929,13 +926,13 @@ static void wifi_config_server_on_settings_update_task(void* args) {
bssid[i] = (uint8_t) strtol(hex, NULL, 16);
}

sysparam_set_blob(WIFI_BSSID_SYSPARAM, bssid, (size_t) 6);
sysparam_set_blob(WIFI_BSSID_SYSPARAM, bssid, 6);

} else {
sysparam_erase(WIFI_BSSID_SYSPARAM);
}

if (password_param->value) {
if (password_param && password_param->value) {
sysparam_set_string(WIFI_PASSWORD_SYSPARAM, password_param->value);
} else {
sysparam_set_string(WIFI_PASSWORD_SYSPARAM, "");
Expand Down Expand Up @@ -1393,8 +1390,7 @@ uint8_t wifi_config_connect(const uint8_t mode, const uint8_t phy, const bool wi
sysparam_get_int8(WIFI_MODE_SYSPARAM, &wifi_mode);

uint8_t *wifi_bssid = NULL;
size_t len = 6;
sysparam_get_blob(WIFI_BSSID_SYSPARAM, &wifi_bssid, &len);
sysparam_get_blob(WIFI_BSSID_SYSPARAM, &wifi_bssid, NULL);

INFO_NNL("BSSID ");
if (wifi_bssid) {
Expand Down
2 changes: 1 addition & 1 deletion libs/homekit-rsf/src/mdnsresponder.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ void mdns_announce() {
}

void mdns_announce_pause() {
rs_esp_timer_stop_forced(mdns_announce_timer);
rs_esp_timer_stop(mdns_announce_timer);
mdns_status = MDNS_STATUS_WORKING;
}

Expand Down

0 comments on commit f8baa9f

Please sign in to comment.