From 8693ec8bf673a2ea5a6a9d618118c858e8cb74b2 Mon Sep 17 00:00:00 2001 From: RavenSystem Date: Tue, 4 Jul 2023 12:26:11 +0200 Subject: [PATCH] Home Accessory Architect v12.6.1 Merlin --- HAA/HAA_Installer/main/Makefile | 21 ++++++++++++--------- HAA/HAA_Installer/main/header.h | 2 +- HAA/HAA_Installer/main/ota.c | 21 ++++++++++++++------- HAA/HAA_Installer/main/setup.c | 4 ++-- HAA/HAA_Main/main/Makefile | 5 +++-- HAA/HAA_Main/main/header.h | 2 +- HAA/HAA_Main/main/main.c | 9 ++++++--- HAA/HAA_Main/main/setup.c | 6 +++++- README.md | 2 +- 9 files changed, 45 insertions(+), 27 deletions(-) diff --git a/HAA/HAA_Installer/main/Makefile b/HAA/HAA_Installer/main/Makefile index 12582e23..78932d1b 100644 --- a/HAA/HAA_Installer/main/Makefile +++ b/HAA/HAA_Installer/main/Makefile @@ -73,22 +73,21 @@ EXTRA_CFLAGS += $(EXTRA_WOLFSSL_CFLAGS) # Max HAA OTA MAIN Installer firmware size is 397296 bytes -EXTRA_CFLAGS += -DSPIFLASH_HOMEKIT_BASE_ADDR=0xF2000 -EXTRA_CFLAGS += -DHAA_CHIP_NAME=\"esp8266\" - -EXTRA_CFLAGS += -DTCP_MSS=1460 -EXTRA_CFLAGS += -DTCP_WND=2920 -EXTRA_CFLAGS += -DTCP_SND_BUF=2920 -EXTRA_CFLAGS += -DLWIP_WND_SCALE=1 -DTCP_RCV_SCALE=0 - EXTRA_CFLAGS += -Os EXTRA_CFLAGS += -Wall -std=gnu99 EXTRA_CFLAGS += -Wextra -Wno-unused-parameter #EXTRA_CFLAGS += -Wpedantic -EXTRA_CFLAGS += -DWIFI_PARAM_SAVE=0 +EXTRA_CFLAGS += -DSPIFLASH_HOMEKIT_BASE_ADDR=0xF2000 +EXTRA_CFLAGS += -DHAA_CHIP_NAME=\"esp8266\" + +EXTRA_CFLAGS += -DTCP_MSS=1460 +EXTRA_CFLAGS += -DTCP_WND=5840 +EXTRA_CFLAGS += -DTCP_SND_BUF=5840 +EXTRA_CFLAGS += -DLWIP_WND_SCALE=1 -DTCP_RCV_SCALE=0 +EXTRA_CFLAGS += -DLWIP_NETIF_HOSTNAME=1 EXTRA_CFLAGS += -DARP_TABLE_SIZE=10 EXTRA_CFLAGS += -DDNS_TABLE_SIZE=4 EXTRA_CFLAGS += -DDNS_MAX_SERVERS=2 @@ -97,6 +96,10 @@ EXTRA_CFLAGS += -DDHCP_DOES_ARP_CHECK=0 EXTRA_CFLAGS += -DLWIP_DHCP_AGGRESSIVE #EXTRA_CFLAGS += -DCHECKSUM_CHECK_UDP=0 +EXTRA_CFLAGS += -DDHCP_SERVER_MAX_LEASES=2 + +EXTRA_CFLAGS += -DWIFI_PARAM_SAVE=0 + EXTRA_CFLAGS += -DconfigMAX_TASK_NAME_LEN=7 EXTRA_CFLAGS += -DconfigCHECK_FOR_STACK_OVERFLOW=2 EXTRA_CFLAGS += -DconfigMINIMAL_STACK_SIZE=256 diff --git a/HAA/HAA_Installer/main/header.h b/HAA/HAA_Installer/main/header.h index 93870ef5..18819262 100644 --- a/HAA/HAA_Installer/main/header.h +++ b/HAA/HAA_Installer/main/header.h @@ -10,6 +10,6 @@ #include "../../common/common_headers.h" -#define INSTALLER_VERSION "7.4.0" +#define INSTALLER_VERSION "7.4.1" #endif // __HAA_OTA_HEADER_H__ diff --git a/HAA/HAA_Installer/main/ota.c b/HAA/HAA_Installer/main/ota.c index e8b83d92..2f4408c3 100644 --- a/HAA/HAA_Installer/main/ota.c +++ b/HAA/HAA_Installer/main/ota.c @@ -220,10 +220,13 @@ static int ota_connect(char* host, uint16_t port, int *socket, WOLFSSL** ssl, co .ai_family = AF_UNSPEC, .ai_socktype = SOCK_STREAM, }; - struct addrinfo* res; - + + struct addrinfo* res = NULL; + void print_error() { - freeaddrinfo(res); + if (res) { + freeaddrinfo(res); + } INFO("!"); } @@ -460,10 +463,14 @@ static int ota_get_final_location(char* repo, char* file, uint16_t port, const b } case -2: lwip_close(socket); - case -3: + //case -3: default: ; } + + if (ota_conn_result < 0) { + vTaskDelay(5000 / portTICK_PERIOD_MS); + } } if (error < 0) { @@ -531,12 +538,12 @@ static int ota_get_file_ex(char* repo, char* file, int sector, uint8_t* buffer, } case -2: lwip_close(socket); - case -3: + //case -3: default: ; } - vTaskDelay(1000 / portTICK_PERIOD_MS); + vTaskDelay(5000 / portTICK_PERIOD_MS); } if (result >= 0) { @@ -763,7 +770,7 @@ static int ota_get_file_ex(char* repo, char* file, int sector, uint8_t* buffer, } case -2: lwip_close(socket); - case -3: + //case -3: default: ; } diff --git a/HAA/HAA_Installer/main/setup.c b/HAA/HAA_Installer/main/setup.c index 5a86d916..fcbc3cb6 100644 --- a/HAA/HAA_Installer/main/setup.c +++ b/HAA/HAA_Installer/main/setup.c @@ -178,7 +178,7 @@ static void client_send_redirect(client_t *client, int code, const char *redirec client_send(client, buffer, len); } -bool wifi_config_got_ip() { +static bool wifi_config_got_ip() { #ifdef ESP_PLATFORM return got_ip; #else @@ -1149,7 +1149,7 @@ static void wifi_config_softap_start() { ip4_addr_t first_client_ip; first_client_ip.addr = ap_ip.ip.addr + htonl(1); - dhcpserver_start(&first_client_ip, 4); + dhcpserver_start(&first_client_ip, DHCP_SERVER_MAX_LEASES); #endif context->wifi_networks_semaph = xSemaphoreCreateBinary(); diff --git a/HAA/HAA_Main/main/Makefile b/HAA/HAA_Main/main/Makefile index 8b561492..8406665a 100644 --- a/HAA/HAA_Main/main/Makefile +++ b/HAA/HAA_Main/main/Makefile @@ -59,8 +59,8 @@ EXTRA_CFLAGS += -DHOMEKIT_DISABLE_VALUE_RANGES EXTRA_CFLAGS += -DHAA_CHIP_NAME=\"esp8266\" EXTRA_CFLAGS += -DTCP_MSS=1460 -EXTRA_CFLAGS += -DTCP_WND=2920 -EXTRA_CFLAGS += -DTCP_SND_BUF=2920 +EXTRA_CFLAGS += -DTCP_WND=5840 +EXTRA_CFLAGS += -DTCP_SND_BUF=5840 EXTRA_CFLAGS += -DLWIP_WND_SCALE=1 -DTCP_RCV_SCALE=0 EXTRA_CFLAGS += -DLWIP_NETIF_HOSTNAME=1 @@ -77,6 +77,7 @@ EXTRA_CFLAGS += -DMEMP_NUM_NETCONN=16 #EXTRA_CFLAGS += -DMEMP_NUM_TCP_PCB=9 #EXTRA_CFLAGS += -DMEMP_NUM_TCP_PCB_LISTEN=1 +EXTRA_CFLAGS += -DDHCP_SERVER_MAX_LEASES=2 EXTRA_CFLAGS += -DWIFI_PARAM_SAVE=0 diff --git a/HAA/HAA_Main/main/header.h b/HAA/HAA_Main/main/header.h index daf0c420..d20f6781 100644 --- a/HAA/HAA_Main/main/header.h +++ b/HAA/HAA_Main/main/header.h @@ -11,7 +11,7 @@ #include "../../common/common_headers.h" // Version -#define HAA_FIRMWARE_VERSION "12.6.0" +#define HAA_FIRMWARE_VERSION "12.6.1" #define HAA_FIRMWARE_BETA_REVISION "" #define HAA_FIRMWARE_CODENAME "Merlin" diff --git a/HAA/HAA_Main/main/main.c b/HAA/HAA_Main/main/main.c index e8691e67..e6154505 100644 --- a/HAA/HAA_Main/main/main.c +++ b/HAA/HAA_Main/main/main.c @@ -358,7 +358,7 @@ const char http_header2[] = "\r\nUser-Agent: HAA/"HAA_FIRMWARE_VERSION"\r\nConne const char http_header_len[] = "Content-length: "; int new_net_con(char* host, uint16_t port_n, bool is_udp, uint8_t* payload, size_t payload_len, int* s, uint8_t rcvtimeout_s, int rcvtimeout_us) { - struct addrinfo* res; + struct addrinfo* res = NULL; struct addrinfo hints; int result; char port[8]; @@ -374,7 +374,9 @@ int new_net_con(char* host, uint16_t port_n, bool is_udp, uint8_t* payload, size } if (getaddrinfo(host, port, &hints, &res) != 0) { - free(res); + if (res) { + free(res); + } return -3; } @@ -736,7 +738,8 @@ int ping_host(char* host) { .ai_family = AF_UNSPEC, .ai_socktype = SOCK_RAW }; - struct addrinfo* res; + + struct addrinfo* res = NULL; int err = getaddrinfo(host, NULL, &hints, &res); diff --git a/HAA/HAA_Main/main/setup.c b/HAA/HAA_Main/main/setup.c index 387ca54e..bea3ad58 100644 --- a/HAA/HAA_Main/main/setup.c +++ b/HAA/HAA_Main/main/setup.c @@ -609,6 +609,10 @@ static void setup_announcer_task() { }; while (getaddrinfo(SETUP_ANNOUNCER_DESTINATION, SETUP_ANNOUNCER_PORT, &hints, &context->res) != 0) { + if (context->res) { + free(context->res); + context->res = NULL; + } vTaskDelay(MS_TO_TICKS(200)); } @@ -1192,7 +1196,7 @@ static void wifi_config_softap_start() { ip4_addr_t first_client_ip; first_client_ip.addr = ap_ip.ip.addr + htonl(1); - dhcpserver_start(&first_client_ip, 4); + dhcpserver_start(&first_client_ip, DHCP_SERVER_MAX_LEASES); #endif context->wifi_networks_semaph = xSemaphoreCreateBinary(); diff --git a/README.md b/README.md index d245202d..d8831c50 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@

-Firmware to bring native Apple HomeKit support to any device based on ESP32 and ESP8266 microcontrollers. +Firmware to bring native Apple HomeKit support and custom configurations to any device based on ESP32, including all ESP-IDF WiFi compatible chips, and ESP8266 microcontrollers. HAA supports many different [HomeKit service types](https://github.com/RavenSystem/esp-homekit-devices/wiki/Service-Types), with a lot of possibilities and customizations.