Skip to content

Commit

Permalink
Home Accessory Architect v12.7.2 Merlin
Browse files Browse the repository at this point in the history
  • Loading branch information
RavenSystem committed Aug 3, 2023
1 parent abfabef commit bf1280a
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 164 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.5.1"
#define INSTALLER_VERSION "7.5.2"

#endif // __HAA_OTA_HEADER_H__
15 changes: 7 additions & 8 deletions HAA/HAA_Installer/main/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ <h2>Please, support this project by <a href="https://paypal.me/ravensystem">dona
<option value="2">DIO</option>
<option value="3">DOUT</option>
</select></label></div>
<input type="submit" id="join" value="Save"/><br><br>
<input type="button" id="refresh" value="⟲ Search WiFi" onClick="window.location.reload(true)"/>
<input type="submit" id="join" value="Save"><br><br>
<input type="button" id="refresh" value="⟲ Search WiFi" onClick="window.location.reload(true)">
Current: <!-- part HTML_SETTINGS_CURRENT_WIFI --><br>
<div class="nonetworks" style="display:none;">
None found
Expand All @@ -60,21 +60,21 @@ <h2>Please, support this project by <a href="https://paypal.me/ravensystem">dona
</ul>
<div class="field required ssid" style="display:none;">
<label for="ssid">SSID</label>
<input type="text" id="ssid" name="sid" maxlength="63"/>
<input type="text" id="ssid" name="sid" maxlength="63">
</div>
<div class="field required pass" style="display:none;">
<label for="pass">Password</label>
<input type="password" id="pass" name="psw" maxlength="63"/>
<input type="password" id="pass" name="psw" maxlength="63">
</div>
<div class="field bssid" style="display:none;">
<label for="bssid">BSSID</label>
<input type="text" id="bssid" name="bid" maxlength="12"/>
<input type="text" id="bssid" name="bid" maxlength="12">
</div>
<div class="field">
<label>Update Server</label>
<input type="text" name="ser" value="<!-- part HTML_SETTINGS_REPOSERVER -->" />
<input type="text" name="ser" value="<!-- part HTML_SETTINGS_REPOSERVER -->">
<label>Port</label>
<input type="text" name="prt" maxlength="5" value="<!-- part HTML_SETTINGS_REPOPORT -->" />
<input type="text" name="prt" maxlength="5" value="<!-- part HTML_SETTINGS_REPOPORT -->">
<input type="checkbox" name="ssl" value="y" <!-- part HTML_SETTINGS_REPOSSL -->> HTTPS<br>
</div>
</form>
Expand Down Expand Up @@ -114,7 +114,6 @@ <h2>If you have paid for this firmware or for a device with it installed, you ha
hide(pass_block);
disable(pass_field);
pass_field.value="";
show(bssid_block);
enable(join_button);
}
}
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.7.1"
#define HAA_FIRMWARE_VERSION "12.7.2"
#define HAA_FIRMWARE_BETA_REVISION ""
#define HAA_FIRMWARE_CODENAME "Merlin"

Expand Down
75 changes: 37 additions & 38 deletions HAA/HAA_Main/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ void wifi_ping_gw_task() {
void wifi_reconnection_task() {
rs_esp_timer_stop_forced(WIFI_WATCHDOG_TIMER);

homekit_mdns_announce_pause();
homekit_mdns_announce_stop();

if (main_config.wifi_status == WIFI_STATUS_CONNECTED) {
sdk_wifi_station_disconnect();
Expand All @@ -917,8 +917,6 @@ void wifi_reconnection_task() {

led_blink(6);

do_actions(ch_group_find_by_serv(SERV_TYPE_ROOT_DEVICE), 4);

vTaskDelay(MS_TO_TICKS(500));

for (;;) {
Expand Down Expand Up @@ -962,7 +960,7 @@ void wifi_reconnection_task() {

save_last_working_phy();

homekit_mdns_announce();
homekit_mdns_announce_start();

do_actions(ch_group_find_by_serv(SERV_TYPE_ROOT_DEVICE), 3);

Expand Down Expand Up @@ -999,6 +997,8 @@ void set_main_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();
int wifi_error = false;

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;
Expand Down Expand Up @@ -1027,20 +1027,15 @@ void wifi_watchdog() {
}

if (main_config.wifi_channel != current_channel) {
main_config.wifi_channel = current_channel;
INFO("Wifi new Ch %i", current_channel);
homekit_mdns_announce();
wifi_error = true;
main_config.wifi_status = WIFI_STATUS_CONNECTING;
do_actions(ch_group_find_by_serv(SERV_TYPE_ROOT_DEVICE), 6);

main_config.wifi_arp_count = 0;
}

if (main_config.wifi_ip != current_ip) {
main_config.wifi_ip = current_ip;
homekit_mdns_announce();
wifi_error = true;
main_config.wifi_status = WIFI_STATUS_CONNECTING;
do_actions(ch_group_find_by_serv(SERV_TYPE_ROOT_DEVICE), 7);

main_config.wifi_arp_count = 0;
}

if (main_config.wifi_arp_count_max > 0) {
Expand All @@ -1059,13 +1054,19 @@ void wifi_watchdog() {
}

} else {
ERROR("Wifi");
wifi_error = true;

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;
}

do_actions(ch_group_find_by_serv(SERV_TYPE_ROOT_DEVICE), 4);
}

if (wifi_error) {
ERROR("Wifi");

main_config.wifi_error_count = 0;

if (xTaskCreate(wifi_reconnection_task, "RCN", WIFI_RECONNECTION_TASK_SIZE, NULL, WIFI_RECONNECTION_TASK_PRIORITY, NULL) != pdPASS) {
Expand Down Expand Up @@ -1534,6 +1535,7 @@ float byte_array_to_num(uint8_t* data, const uint8_t array_size, const uint8_t t
// --- POWER MONITOR
void power_monitor_task(void* args) {
ch_group_t* ch_group = args;
ch_group->is_working = true;

float voltage = 0;
float current = 0;
Expand Down Expand Up @@ -1697,9 +1699,7 @@ void power_monitor_timer_worker(TimerHandle_t xTimer) {
ch_group_t* ch_group = (ch_group_t*) pvTimerGetTimerID(xTimer);
if (ch_group->main_enabled) {
if (!ch_group->is_working) {
if (xTaskCreate(power_monitor_task, "PM", POWER_MONITOR_TASK_SIZE, (void*) ch_group, POWER_MONITOR_TASK_PRIORITY, NULL) == pdPASS) {
ch_group->is_working = true;
} else {
if (xTaskCreate(power_monitor_task, "PM", POWER_MONITOR_TASK_SIZE, (void*) ch_group, POWER_MONITOR_TASK_PRIORITY, NULL) != pdPASS) {
homekit_remove_oldest_client();
ERROR("New PM");
}
Expand Down Expand Up @@ -2729,6 +2729,7 @@ void temperature_task(void* args) {
}

ch_group_t* ch_group = args;
ch_group->is_working = true;

float temperature_value = 0.0;
float humidity_value = 0.0;
Expand Down Expand Up @@ -2943,9 +2944,7 @@ void temperature_timer_worker(TimerHandle_t xTimer) {
if (!homekit_is_pairing()) {
ch_group_t* ch_group = (ch_group_t*) pvTimerGetTimerID(xTimer);
if (!ch_group->is_working) {
if (xTaskCreate(temperature_task, "TEM", TEMPERATURE_TASK_SIZE, (void*) ch_group, TEMPERATURE_TASK_PRIORITY, NULL) == pdPASS) {
ch_group->is_working = true;
} else {
if (xTaskCreate(temperature_task, "TEM", TEMPERATURE_TASK_SIZE, (void*) ch_group, TEMPERATURE_TASK_PRIORITY, NULL) != pdPASS) {
homekit_remove_oldest_client();
ERROR("New TEM");
}
Expand Down Expand Up @@ -3476,22 +3475,24 @@ void rgbw_set_timer_worker() {
while (lightbulb_group) {
if (LIGHTBULB_TYPE != LIGHTBULB_TYPE_VIRTUAL) {
lightbulb_group->has_changed = false;

for (int i = 0; i < LIGHTBULB_CHANNELS; i++) {
int pwm_needs_update = false;

if (private_abs(lightbulb_group->target[i] - lightbulb_group->current[i]) > private_abs(LIGHTBULB_STEP_VALUE[i])) {
all_channels_ready = false;
lightbulb_group->current[i] += LIGHTBULB_STEP_VALUE[i];
lightbulb_group->has_changed = true;
pwm_needs_update = true;

if (LIGHTBULB_TYPE == LIGHTBULB_TYPE_PWM) {
haa_pwm_set_duty(lightbulb_group->gpio[i], lightbulb_group->current[i]);
}
} else if (lightbulb_group->current[i] != lightbulb_group->target[i]) {
lightbulb_group->current[i] = lightbulb_group->target[i];
lightbulb_group->has_changed = true;

if (LIGHTBULB_TYPE == LIGHTBULB_TYPE_PWM) {
haa_pwm_set_duty(lightbulb_group->gpio[i], lightbulb_group->current[i]);
}
pwm_needs_update = true;
}

if (pwm_needs_update && LIGHTBULB_TYPE <= LIGHTBULB_TYPE_PWM_CWWW) {
haa_pwm_set_duty(lightbulb_group->gpio[i], lightbulb_group->current[i]);
}
}

Expand Down Expand Up @@ -4429,6 +4430,7 @@ void hkc_fan_status_setter(homekit_characteristic_t* ch0, const homekit_value_t
// --- LIGHT SENSOR
void light_sensor_task(void* args) {
ch_group_t* ch_group = (ch_group_t*) args;
ch_group->is_working = true;

float luxes = 0.0001f;

Expand Down Expand Up @@ -4488,9 +4490,7 @@ void light_sensor_timer_worker(TimerHandle_t xTimer) {
if (!homekit_is_pairing()) {
ch_group_t* ch_group = (ch_group_t*) pvTimerGetTimerID(xTimer);
if (!ch_group->is_working) {
if (xTaskCreate(light_sensor_task, "LUX", LIGHT_SENSOR_TASK_SIZE, (void*) ch_group, LIGHT_SENSOR_TASK_PRIORITY, NULL) == pdPASS) {
ch_group->is_working = true;
} else {
if (xTaskCreate(light_sensor_task, "LUX", LIGHT_SENSOR_TASK_SIZE, (void*) ch_group, LIGHT_SENSOR_TASK_PRIORITY, NULL) != pdPASS) {
homekit_remove_oldest_client();
ERROR("New LUX");
}
Expand Down Expand Up @@ -4971,6 +4971,7 @@ void free_monitor_task(void* args) {

if (args) {
ch_group = args;
ch_group->is_working = true;
} else {
uart_receiver_data_t* uart_receiver_data = main_config.uart_receiver_data;
while (uart_receiver_data) {
Expand Down Expand Up @@ -5432,6 +5433,8 @@ void free_monitor_task(void* args) {
if (adv_i2c_slave_read(FM_I2C_BUS, (uint8_t) FM_I2C_ADDR, (uint8_t*) &FM_I2C_REG[FM_I2C_REG_FIRST], FM_I2C_REG_LEN, i2c_value, i2c_value_len) == 0) {
value = byte_array_to_num(&i2c_value[FM_I2C_VAL_OFFSET], FM_VAL_LEN, FM_VAL_TYPE);
get_value = true;
} else {
ERROR("<%i> I2C", ch_group->serv_index);
}
}
} else if (fm_sensor_type >= FM_SENSOR_TYPE_UART) {
Expand Down Expand Up @@ -5529,9 +5532,7 @@ void free_monitor_timer_worker(TimerHandle_t xTimer) {
ch_group_t* ch_group = (ch_group_t*) pvTimerGetTimerID(xTimer);
if (ch_group->main_enabled) {
if (!ch_group->is_working) {
if (xTaskCreate(free_monitor_task, "FM", FREE_MONITOR_TASK_SIZE, (void*) ch_group, FREE_MONITOR_TASK_PRIORITY, NULL) == pdPASS) {
ch_group->is_working = true;
} else {
if (xTaskCreate(free_monitor_task, "FM", FREE_MONITOR_TASK_SIZE, (void*) ch_group, FREE_MONITOR_TASK_PRIORITY, NULL) != pdPASS) {
ERROR("New FM");
homekit_remove_oldest_client();
}
Expand Down Expand Up @@ -5623,7 +5624,7 @@ void recv_uart_timer_worker(TimerHandle_t xTimer) {
}

if (uart_has_data & !main_config.uart_recv_is_working) {
if (xTaskCreate(recv_uart_task, "RUA", RECV_UART_TASK_SIZE, NULL, RECV_UART_TASK_PRIORITY, NULL) == pdTRUE) {
if (xTaskCreate(recv_uart_task, "RUA", RECV_UART_TASK_SIZE, NULL, RECV_UART_TASK_PRIORITY, NULL) == pdPASS) {
main_config.uart_recv_is_working = true;
}
}
Expand Down Expand Up @@ -6973,9 +6974,7 @@ void do_actions(ch_group_t* ch_group, uint8_t action) {
if (ch_group->main_enabled) {
if (!ch_group->is_working) {
FM_OVERRIDE_VALUE = action_serv_manager->value;
if (xTaskCreate(free_monitor_task, "FM", FREE_MONITOR_TASK_SIZE, (void*) ch_group, FREE_MONITOR_TASK_PRIORITY, NULL) == pdPASS) {
ch_group->is_working = true;
} else {
if (xTaskCreate(free_monitor_task, "FM", FREE_MONITOR_TASK_SIZE, (void*) ch_group, FREE_MONITOR_TASK_PRIORITY, NULL) != pdPASS) {
homekit_remove_oldest_client();
ERROR("New FM");
}
Expand Down Expand Up @@ -8836,8 +8835,8 @@ void normal_mode_init() {
adc_oneshot_io_to_channel(gpio, NULL, &adc_channel);

adc_oneshot_chan_cfg_t config = {
.bitwidth = ADC_BITWIDTH_12, // Max supported width: 12 bits (0 - 4095)
.atten = IO_GPIO_ADC_ATTENUATION,
.bitwidth = ADC_BITWIDTH_12, // Max supported width: 12 bits (0 - 4095)
};
gpio_ret = adc_oneshot_config_channel(main_config.adc_dac_data->adc_oneshot_handle, adc_channel, &config);

Expand Down
3 changes: 3 additions & 0 deletions HAA/HAA_Main/main/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void set_main_wifi_status_connecting();
13 changes: 6 additions & 7 deletions HAA/HAA_Main/main/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h2>Please, support this project by <a href="https://paypal.me/ravensystem">dona
<input type="checkbox" name="ins" value="y"> Installer Setup<br>
<input type="checkbox" name="ota" value="y"> Firmware Update<br>
<input type="checkbox" name="wap" value="y" <!-- part HTML_SETTINGS_WIFI_AP -->> WiFi AP<br>
WiFi AP Password<input type="password" name="app" maxlength="63"/><br>
WiFi AP Password<input type="password" name="app" maxlength="63"><br>
<label> WiFi Mode <select name="wm">
<option value="0" <!-- part HTML_WIFI_MODE_0 -->>Normal</option>
<option value="1" <!-- part HTML_WIFI_MODE_1 -->>Force BSSID</option>
Expand Down Expand Up @@ -94,8 +94,8 @@ <h2>Please, support this project by <a href="https://paypal.me/ravensystem">dona
<option value="48">48</option>
@@@#endif
</select></label></div>
<input type="submit" id="join" value="Save"/><br><br>
<input type="button" id="refresh" value="⟲ Search WiFi" onClick="window.location.reload(true)"/>
<input type="submit" id="join" value="Save"><br><br>
<input type="button" id="refresh" value="⟲ Search WiFi" onClick="window.location.reload(true)">
Current: <!-- part HTML_SETTINGS_CURRENT_WIFI --><br>
<div class="nonetworks" style="display:none;">
None found
Expand All @@ -108,15 +108,15 @@ <h2>Please, support this project by <a href="https://paypal.me/ravensystem">dona
</ul>
<div class="field required ssid" style="display:none;">
<label for="ssid">SSID</label>
<input type="text" id="ssid" name="sid" maxlength="63"/>
<input type="text" id="ssid" name="sid" maxlength="63">
</div>
<div class="field required pass" style="display:none;">
<label for="pass">Password</label>
<input type="password" id="pass" name="psw" maxlength="63"/>
<input type="password" id="pass" name="psw" maxlength="63">
</div>
<div class="field bssid" style="display:none;">
<label for="bssid">BSSID</label>
<input type="text" id="bssid" name="bid" maxlength="12"/>
<input type="text" id="bssid" name="bid" maxlength="12">
</div></form>
<center>© 2018-2023 Jos&eacute; A. Jim&eacute;nez Campos</center>
<h2>If you have paid for this firmware or for a device with it installed, you have been scammed. You must report the fraud to the authorities and claim the amount paid. <a href="https://raw.githubusercontent.com/RavenSystem/esp-homekit-devices/master/LICENSE">LICENSE</a></h2>
Expand Down Expand Up @@ -154,7 +154,6 @@ <h2>If you have paid for this firmware or for a device with it installed, you ha
hide(pass_block);
disable(pass_field);
pass_field.value="";
show(bssid_block);
enable(join_button);
}
}
Expand Down
Loading

0 comments on commit bf1280a

Please sign in to comment.