2222#include "esp_heap_caps.h"
2323#include "esp_wifi.h"
2424#include "esp_timer.h"
25+ #if CONFIG_SOC_TEMP_SENSOR_SUPPORTED
2526#include "driver/temperature_sensor.h"
27+ #endif
2628#include "nvs_flash.h"
2729#include "nvs.h"
2830#include "cJSON.h"
@@ -63,8 +65,9 @@ struct ml_config_ctx {
6365 /* WiFi multi-SSID list */
6466 ml_config_wifi_list_t wifi_list ;
6567
66- /* Temperature sensor */
68+ #if CONFIG_SOC_TEMP_SENSOR_SUPPORTED
6769 temperature_sensor_handle_t temp_sensor ;
70+ #endif
6871
6972 /* HTTP server */
7073 httpd_handle_t httpd ;
@@ -698,6 +701,7 @@ static esp_err_t handler_monitor(httpd_req_t *req) {
698701 if (!json ) return ESP_FAIL ;
699702
700703 /* Temperature */
704+ #if CONFIG_SOC_TEMP_SENSOR_SUPPORTED
701705 float temp_c = 0 ;
702706 if (ctx -> temp_sensor ) {
703707 if (temperature_sensor_get_celsius (ctx -> temp_sensor , & temp_c ) == ESP_OK ) {
@@ -708,6 +712,9 @@ static esp_err_t handler_monitor(httpd_req_t *req) {
708712 } else {
709713 cJSON_AddNullToObject (json , "temp_c" );
710714 }
715+ #else
716+ cJSON_AddNullToObject (json , "temp_c" );
717+ #endif
711718
712719 /* WiFi RSSI */
713720 int rssi = 0 ;
@@ -1084,6 +1091,7 @@ ml_config_ctx_t *ml_config_httpd_init(void) {
10841091 config_load_peers (ctx );
10851092 config_load_wifi_list (ctx );
10861093
1094+ #if CONFIG_SOC_TEMP_SENSOR_SUPPORTED
10871095 /* Initialize temperature sensor */
10881096 temperature_sensor_config_t tsens_cfg = TEMPERATURE_SENSOR_CONFIG_DEFAULT (10 , 80 );
10891097 if (temperature_sensor_install (& tsens_cfg , & ctx -> temp_sensor ) == ESP_OK ) {
@@ -1093,6 +1101,7 @@ ml_config_ctx_t *ml_config_httpd_init(void) {
10931101 ctx -> temp_sensor = NULL ;
10941102 ESP_LOGW (TAG , "Temperature sensor init failed (non-critical)" );
10951103 }
1104+ #endif
10961105
10971106 ESP_LOGI (TAG , "Config module initialized" );
10981107 return ctx ;
@@ -1149,10 +1158,12 @@ void ml_config_httpd_stop(ml_config_ctx_t *ctx) {
11491158void ml_config_httpd_deinit (ml_config_ctx_t * ctx ) {
11501159 if (!ctx ) return ;
11511160 ml_config_httpd_stop (ctx );
1161+ #if CONFIG_SOC_TEMP_SENSOR_SUPPORTED
11521162 if (ctx -> temp_sensor ) {
11531163 temperature_sensor_disable (ctx -> temp_sensor );
11541164 temperature_sensor_uninstall (ctx -> temp_sensor );
11551165 }
1166+ #endif
11561167 if (ctx -> nvs ) nvs_close (ctx -> nvs );
11571168 if (ctx -> peer_mutex ) vSemaphoreDelete (ctx -> peer_mutex );
11581169 free (ctx );
0 commit comments