diff --git a/.gitignore b/.gitignore index e5348d3..4d25375 100644 --- a/.gitignore +++ b/.gitignore @@ -291,3 +291,5 @@ dkms.conf *.out *.app +managed_components/ +dependencies.lock diff --git a/CMakeLists.txt b/CMakeLists.txt index 561307f..c67b51e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,3 @@ - -set(EXTRA_COMPONENT_DIRS $ENV{ESP_IDF_LIB_PATH}/components) - # The following lines of boilerplate have to be in your project's CMakeLists # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) diff --git a/main/control.c b/main/control.c index 7a80cf6..e852fcc 100644 --- a/main/control.c +++ b/main/control.c @@ -291,6 +291,7 @@ eControlState getControlState(void) eControlWeekday getControlCurrentWeekday(void) { + // Get current time time_t now; struct tm timeinfo; time(&now); @@ -357,15 +358,15 @@ static void findControlCurrentTemperatureEntry(void) const sControlDay *sunday = &gControlTable[6]; gCurrentControlEntry = sunday->aTemperatureEntries[sunday->entryCount - 1]; } - xSemaphoreGiveRecursive(xMutexAccessControl); /* ESP_LOGI(TAG, "Active entry found - Time: %02d:%02d, " - "Return Temp: %lf, Chamber Temp: %lf", - gCurrentControlEntry.timestamp.hour, - gCurrentControlEntry.timestamp.minute, - gCurrentControlEntry.fReturnFlowTemperature, - gCurrentControlEntry.fChamberTemperature); - */ + "Return Temp: %lf, Chamber Temp: %lf", + gCurrentControlEntry.timestamp.hour, + gCurrentControlEntry.timestamp.minute, + gCurrentControlEntry.fReturnFlowTemperature, + gCurrentControlEntry.fChamberTemperature); + */ + xSemaphoreGiveRecursive(xMutexAccessControl); return; } } diff --git a/main/idf_component.yml b/main/idf_component.yml new file mode 100644 index 0000000..5fa17bf --- /dev/null +++ b/main/idf_component.yml @@ -0,0 +1,17 @@ +## IDF Component Manager Manifest File +dependencies: + ## Required IDF version + idf: + version: '>=4.1.0' + # # Put list of dependencies here + # # For components maintained by Espressif: + # component: "~1.0.0" + # # For 3rd party components: + # username/component: ">=1.0.0,<2.0.0" + # username2/component2: + # version: "~1.0.0" + # # For transient dependencies `public` flag can be set. + # # `public` flag doesn't have an effect dependencies of the `main` component. + # # All dependencies of `main` are public by default. + # public: true + esp-idf-lib/ds18x20: '*' diff --git a/main/safety.c b/main/safety.c index fbf3d27..2045df4 100644 --- a/main/safety.c +++ b/main/safety.c @@ -31,7 +31,6 @@ static sSensorSanityCheck sanityChecks[NUMBER_OF_SENSOR_SANITY_CHECKS] = { {SENSOR_NO_ERROR, "outdoor_temperature", {SENSOR_LIMIT_OUTDOOR_MAX, SENSOR_LIMIT_OUTDOOR_MIN}, 0.0f, 0U, getOutdoorTemperature}, {SENSOR_NO_ERROR, "inlet_flow_temperature", {SENSOR_LIMIT_INLET_MAX, SENSOR_LIMIT_INLET_MIN}, 0.0f, 0U, getInletFlowTemperature}, {SENSOR_NO_ERROR, "return_flow_temperature", {SENSOR_LIMIT_RETURN_MAX, SENSOR_LIMIT_RETURN_MIN}, 0.0f, 0U, getReturnFlowTemperature}}; - static eSafetyState sSafetyState = SAFETY_NO_ERROR; /* Private function prototypes */ diff --git a/main/wifi.c b/main/wifi.c index ace3e96..afcd013 100644 --- a/main/wifi.c +++ b/main/wifi.c @@ -37,6 +37,7 @@ static bool s_initial_connect = true; static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data); +static bool parse_bssid(const char *bssid_str, uint8_t *bssid); esp_err_t initWifi(void) { @@ -80,6 +81,21 @@ esp_err_t initWifi(void) .threshold.authmode = WIFI_AUTH_WPA2_PSK, }, }; + +#if CONFIG_ENV_WIFI_BSSID_LOCK + /* Lock to specific AP by BSSID */ + if (parse_bssid(CONFIG_ENV_WIFI_BSSID, wifi_config.sta.bssid)) + { + wifi_config.sta.bssid_set = true; + ESP_LOGI(TAG, "BSSID lock enabled: %s", CONFIG_ENV_WIFI_BSSID); + } + else + { + ESP_LOGE(TAG, "Invalid BSSID format: %s", CONFIG_ENV_WIFI_BSSID); + wifi_config.sta.bssid_set = false; + } +#endif + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); @@ -176,3 +192,27 @@ static void event_handler(void *arg, esp_event_base_t event_base, } } } + +/** + * @brief Parse BSSID string to byte array + * + * @param bssid_str BSSID string in format "XX:XX:XX:XX:XX:XX" + * @param bssid Output byte array (6 bytes) + * @return true on success, false on parse error + */ +static bool parse_bssid(const char *bssid_str, uint8_t *bssid) +{ + unsigned int tmp[6]; + int parsed = sscanf(bssid_str, "%x:%x:%x:%x:%x:%x", + &tmp[0], &tmp[1], &tmp[2], + &tmp[3], &tmp[4], &tmp[5]); + if (parsed != 6) + { + return false; + } + for (int i = 0; i < 6; i++) + { + bssid[i] = (uint8_t)tmp[i]; + } + return true; +}