diff --git a/main/eq3_bootwifi.c b/main/eq3_bootwifi.c index 4d791c1..d4a6106 100644 --- a/main/eq3_bootwifi.c +++ b/main/eq3_bootwifi.c @@ -904,7 +904,7 @@ static void saveConnectionInfo(connection_info_t *pConnectionInfo) { * Become a station connecting to an existing access point. */ static void becomeStation(connection_info_t *pConnectionInfo) { - ESP_LOGD(tag, "- Connecting to access point \"%s\" ...", pConnectionInfo->ssid); + ESP_LOGI(tag, "- Connecting to access point \"%s\" ...", pConnectionInfo->ssid); assert(strlen(pConnectionInfo->ssid) > 0); /* If this is a retry don't re-initialise sta mode */ @@ -912,13 +912,19 @@ static void becomeStation(connection_info_t *pConnectionInfo) { ESP_ERROR_CHECK(esp_wifi_stop()); // If we have a static IP address information, use that. if (pConnectionInfo->ipInfo.ip.addr != 0) { - ESP_LOGD(tag, " - using a static IP address of " IPSTR, IP2STR(&pConnectionInfo->ipInfo.ip)); + ESP_LOGI(tag, " - using a static IP address of " IPSTR, IP2STR(&pConnectionInfo->ipInfo.ip)); tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_STA, &pConnectionInfo->ipInfo); } else { tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA); } - + if(strlen(pConnectionInfo->mqttid) == 0){ + tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, "EQ3-heatcontroller"); + ESP_LOGI(tag, "Hostname EQ3-heatcontroller"); + }else{ + tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, pConnectionInfo->mqttid); + ESP_LOGI(tag, "Hostname %s", pConnectionInfo->mqttid); + } ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA)); wifi_config_t sta_config; memset(&sta_config, 0, sizeof(wifi_config_t)); @@ -939,7 +945,7 @@ static void becomeStation(connection_info_t *pConnectionInfo) { * Become an access point. */ static void becomeAccessPoint() { - ESP_LOGD(tag, "- Starting being an access point ..."); + ESP_LOGI(tag, "- Starting being an access point ..."); // We don't have connection info so be an access point! ESP_ERROR_CHECK(esp_wifi_stop()); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP)); diff --git a/main/eq3_htmlpages.h b/main/eq3_htmlpages.h index aec3252..b722878 100644 --- a/main/eq3_htmlpages.h +++ b/main/eq3_htmlpages.h @@ -143,6 +143,9 @@ const char command_post_device[] = " \ \ diff --git a/main/eq3_main.c b/main/eq3_main.c index 6e47326..4f7a61c 100644 --- a/main/eq3_main.c +++ b/main/eq3_main.c @@ -733,7 +733,7 @@ int handle_request(char *cmdstr){ // Skip any spaces while(*cmdptr == ' ') cmdptr++; - if(strncmp((const char *)cmdptr, "settime", 7) == 0){ + if(start == false && strncmp((const char *)cmdptr, "settime", 7) == 0){ start = true; if(cmdptr[8] != 0 && strlen(cmdptr + 8) < 12){ @@ -771,31 +771,31 @@ int handle_request(char *cmdstr){ } command = EQ3_SETTIME; } - if(strncmp((const char *)cmdptr, "boost", 5) == 0){ + if(start == false && strncmp((const char *)cmdptr, "boost", 5) == 0){ start = true; command = EQ3_BOOST; } - if(strncmp((const char *)cmdptr, "unboost", 7) == 0){ + if(start == false && strncmp((const char *)cmdptr, "unboost", 7) == 0){ start = true; command = EQ3_UNBOOST; } - if(strncmp((const char *)cmdptr, "auto", 4) == 0){ + if(start == false && strncmp((const char *)cmdptr, "auto", 4) == 0){ start = true; command = EQ3_AUTO; } - if(strncmp((const char *)cmdptr, "manual", 6) == 0){ + if(start == false && strncmp((const char *)cmdptr, "manual", 6) == 0){ start = true; command = EQ3_MANUAL; } - if(strncmp((const char *)cmdptr, "lock", 4) == 0){ + if(start == false && strncmp((const char *)cmdptr, "lock", 4) == 0){ start = true; command = EQ3_LOCK; } - if(strncmp((const char *)cmdptr, "unlock", 6) == 0){ + if(start == false && strncmp((const char *)cmdptr, "unlock", 6) == 0){ start = true; command = EQ3_UNLOCK; } - if(strncmp((const char *)cmdptr, "offset", 6) == 0){ + if(start == false && strncmp((const char *)cmdptr, "offset", 6) == 0){ char *endmsg; float offset = strtof(cmdptr + 7, &endmsg); if(offset < -3.5 || offset > 3.5){ @@ -810,7 +810,7 @@ int handle_request(char *cmdstr){ command = EQ3_OFFSET; ESP_LOGI(GATTC_TAG, "set offset val 0x%x\n", cmdparms[0]); } - if(strncmp((const char *)cmdptr, "settemp", 7) == 0){ + if(start == false && strncmp((const char *)cmdptr, "settemp", 7) == 0){ char *endmsg; float temp = strtof(cmdptr + 8, &endmsg); int inttemp = (int)temp; @@ -826,13 +826,13 @@ int handle_request(char *cmdstr){ return -1; } } - if(strncmp((const char *)cmdptr, "off", 3) == 0){ + if(start == false && strncmp((const char *)cmdptr, "off", 3) == 0){ /* 'Off' is achieved by setting the required temperature to 4.5 */ start = true; command = EQ3_SETTEMP; cmdparms[0] = 0x09; /* (4 << 1) | 0x01 */ } - if(strncmp((const char *)cmdptr, "on", 2) == 0){ + if(start == false && strncmp((const char *)cmdptr, "on", 2) == 0){ /* 'On' is achieved by setting the required temperature to 30 */ start = true; command = EQ3_SETTEMP; @@ -1120,7 +1120,7 @@ void wifidone(int rc){ time_t now = 0; struct tm timeinfo = { 0 }; int retry = 0; - const int retry_count = 10; + const int retry_count = 30; while(timeinfo.tm_year < (2019 - 1900) && ++retry < retry_count) { ESP_LOGI(GATTC_TAG, "Waiting for system time to be set... (%d/%d)", retry, retry_count); vTaskDelay(2000 / portTICK_PERIOD_MS); diff --git a/main/eq3_main.h b/main/eq3_main.h index 3f083ff..fcda607 100644 --- a/main/eq3_main.h +++ b/main/eq3_main.h @@ -2,7 +2,7 @@ #define EQ3_MAIN_H #define EQ3_MAJVER "1" -#define EQ3_MINVER "49" +#define EQ3_MINVER "51" #define EQ3_EXTRAVER "-beta" void eq3_log_init(void);