From e43f9e09f8289ddcf7f8760681633cac13bedf35 Mon Sep 17 00:00:00 2001 From: Kiryanov D V Date: Fri, 28 Aug 2026 13:16:16 +0300 Subject: [PATCH 1/4] Fixing temperature sensor example. --- main/controller.cpp | 34 +++++++++------------------------- main/sensors/esp_main_utils.c | 6 +++--- main/sensors/stcc4.c | 3 +++ 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/main/controller.cpp b/main/controller.cpp index 0e8eb2a..d872e3c 100644 --- a/main/controller.cpp +++ b/main/controller.cpp @@ -19,10 +19,13 @@ #include #include + #include "aether/all.h" +#include "aether/env.h" #include "sensors/sensors.h" #include "sleeping/sleeping.h" + using namespace std::chrono_literals; /** @@ -40,7 +43,7 @@ static constexpr auto kServiceUid = #ifdef SERVICE_UID ae::Uid::FromString(SERVICE_UID); #else - ae::Uid::FromString("e839f1a9-e0ec-4ff6-b85c-d49efaabf24f"); + ae::Uid::FromString("ac3ac9ed-3c62-4009-b8a0-18ee82e2a368"); #endif #ifdef ESP_PLATFORM @@ -88,7 +91,7 @@ void SleepReady(); // Go to sleep method void GoToSleep(ae::TimePoint time_point); -static ae::RcPtr aether_app; +static std::unique_ptr aether_app; static ae::Client::ptr client; static std::unique_ptr message_stream; @@ -130,7 +133,7 @@ void loop() { } else { // cleanup resources message_stream.reset(); - aether_app.Reset(); + aether_app.reset(); } } @@ -193,6 +196,7 @@ void UpdateSensors() { std::int16_t temperature = {}; std::uint32_t humidity = {}; std::uint32_t co2 = {}; + ReadSensors(&temperature, &humidity, nullptr, &co2, nullptr); std::cout << ae::Format(" >>> Temperature: [{}], Humidity: [{}], CO2: [{}]\n", temperature, humidity, co2); @@ -206,28 +210,8 @@ void MessageReceived(ae::DataBuffer const& buffer) { } void SendValue(std::int16_t temperature) { - // The stream is not initialized yet - if (!message_stream) { - return; - } - - struct Header { - std::uint8_t const root_code = 0x3; - std::uint8_t const size = sizeof(std::uint8_t) + sizeof(std::int16_t); - std::uint8_t const dev_code = 0x10; - AE_REFLECT_MEMBERS(root_code, size, dev_code) - }; - static constexpr auto header = Header{}; - - auto message = ae::DataBuffer{}; - message.reserve(sizeof(header) + 2); - { - auto writer = ae::VectorWriter<>{message}; - auto stream = ae::omstream{writer}; - // write message header and temperature value - // temperature in range -100.0 to 100.0 x100 (-10000 to 10000) - stream << header << temperature; - } + auto payload = { 0x03, 0x03, 0x0A, (temperature) & 0xFF, (temperature >> 8) & 0xFF }; + auto message = ae::DataBuffer{std::begin(payload), std::end(payload)}; message_stream->Write(std::move(message)).status_event().Subscribe([](auto) { // with any result ready to sleep diff --git a/main/sensors/esp_main_utils.c b/main/sensors/esp_main_utils.c index 850d998..750808c 100644 --- a/main/sensors/esp_main_utils.c +++ b/main/sensors/esp_main_utils.c @@ -49,17 +49,17 @@ esp_err_t i2c_init(i2c_master_bus_handle_t *bus_handle, i2c_port_t i2c_handle_po return ESP_OK; } -esp_err_t i2c_write(i2c_master_bus_handle_t *bus_handle, i2c_master_dev_handle_t i2c_handle_port, uint8_t address, uint8_t const* data, +esp_err_t i2c_write(i2c_master_dev_handle_t i2c_handle_port, uint8_t address, uint8_t const* data, uint8_t len, int32_t ms_dur) { return i2c_master_transmit(i2c_handle_port, data, len, ms_dur); } -esp_err_t i2c_read(i2c_master_bus_handle_t *bus_handle, i2c_master_dev_handle_t i2c_handle_port, uint8_t address, uint8_t* data, uint8_t len, +esp_err_t i2c_read(i2c_master_dev_handle_t i2c_handle_port, uint8_t address, uint8_t* data, uint8_t len, int32_t ms_dur) { return i2c_master_receive(i2c_handle_port, data, len, ms_dur); } -esp_err_t i2c_write_read(i2c_master_bus_handle_t *bus_handle, i2c_master_dev_handle_t i2c_handle_port, uint8_t address, +esp_err_t i2c_write_read(i2c_master_dev_handle_t i2c_handle_port, uint8_t address, uint8_t const* write_data, uint8_t write_len, uint8_t* read_data, uint8_t read_len, int32_t ms_dur) { return i2c_master_transmit_receive(i2c_handle_port, write_data, write_len, diff --git a/main/sensors/stcc4.c b/main/sensors/stcc4.c index e96d23c..15e9d18 100644 --- a/main/sensors/stcc4.c +++ b/main/sensors/stcc4.c @@ -132,6 +132,9 @@ void ReadSensors(int16_t* temperature, uint32_t* humidity, uint32_t* pressure, if (!initialized) { initialized = Init(); + if (!initialized) { + return; + } } ret = send_command_16bit(STCC4_CMD_MEASURE_SINGLE_SHOT, STCC4_SLAVE_ADDR); From 1c6f423a22203662c3ad544128287e38972db072 Mon Sep 17 00:00:00 2001 From: Kiryanov D V Date: Fri, 28 Aug 2026 15:38:00 +0300 Subject: [PATCH 2/4] Fixing Ci/Cd build. --- main/boards/aether_esp32_c6.h | 2 +- main/boards/m5stack_atom_lite.h | 1 - main/boards/nano_esp32_c6.h | 1 - main/sleeping/ulp_sleep.cpp | 1 + main/user_config.h | 9 +++++---- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main/boards/aether_esp32_c6.h b/main/boards/aether_esp32_c6.h index bc92e41..5e36294 100644 --- a/main/boards/aether_esp32_c6.h +++ b/main/boards/aether_esp32_c6.h @@ -23,7 +23,7 @@ #include "soc/gpio_num.h" #ifndef BOARD_HAS_ULP -# define BOARD_HAS_ULP 0 +# define BOARD_HAS_ULP 1 #endif #ifndef BOARD_HAS_LED # define BOARD_HAS_LED 1 diff --git a/main/boards/m5stack_atom_lite.h b/main/boards/m5stack_atom_lite.h index d89f8c0..0375869 100644 --- a/main/boards/m5stack_atom_lite.h +++ b/main/boards/m5stack_atom_lite.h @@ -20,7 +20,6 @@ # error "Illegal CPU! It must be an ESP32C6." #endif -#include "hal/i2c_types.h" #include "soc/gpio_num.h" #ifndef BOARD_HAS_ULP diff --git a/main/boards/nano_esp32_c6.h b/main/boards/nano_esp32_c6.h index 266137f..1fc6815 100644 --- a/main/boards/nano_esp32_c6.h +++ b/main/boards/nano_esp32_c6.h @@ -20,7 +20,6 @@ # error "Illegal CPU! It must be an ESP32C6." #endif -#include "hal/i2c_types.h" #include "soc/gpio_num.h" #ifndef BOARD_HAS_ULP diff --git a/main/sleeping/ulp_sleep.cpp b/main/sleeping/ulp_sleep.cpp index 5e1c08b..873bfc2 100644 --- a/main/sleeping/ulp_sleep.cpp +++ b/main/sleeping/ulp_sleep.cpp @@ -21,6 +21,7 @@ #include "aether/all.h" #if ULP_SLEEP == 1 +# include # include # include diff --git a/main/user_config.h b/main/user_config.h index 1fc810a..070ebd2 100644 --- a/main/user_config.h +++ b/main/user_config.h @@ -48,10 +48,11 @@ #if defined ESP_PLATFORM // Select the board to build example for # define BOARD_AETHER_ESP32_C6 0 -# define BOARD_FIRE_BEETLE2_С6 1 -# define BOARD_NANO_ESP32_C6 2 -# define BOARD_WROVER_ESP32 3 -# define BOARD_M5STACK_ATOM_LITE 4 +# define BOARD_NANO_ESP32_C6 1 +# define BOARD_M5STACK_ATOM_LITE 2 +// For future extension +// # define BOARD_FIRE_BEETLE2_С6 3 +// # define BOARD_WROVER_ESP32 4 # ifndef BOARD # define BOARD BOARD_AETHER_ESP32_C6 From 73fa96820226e3dced02eeb4bf84d9c91cffc670 Mon Sep 17 00:00:00 2001 From: Kiryanov D V Date: Fri, 28 Aug 2026 15:39:06 +0300 Subject: [PATCH 3/4] Updating Ci/Cd ESP-IDF version to release-v6.0. --- .github/workflows/ci-cd-esp32.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd-esp32.yml b/.github/workflows/ci-cd-esp32.yml index 8932f8e..2960bee 100644 --- a/.github/workflows/ci-cd-esp32.yml +++ b/.github/workflows/ci-cd-esp32.yml @@ -20,7 +20,7 @@ jobs: # See https://hub.docker.com/r/espressif/idf/tags and # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html # for details. - idf_ver: ["release-v5.5"] + idf_ver: ["release-v6.0"] idf_target: ["esp32-c6"] board: ["BOARD_AETHER_ESP32_C6", "BOARD_M5STACK_ATOM_LITE", "BOARD_NANO_ESP32_C6"] From 79a7e2373204ea9bcef82b294e47584884489429 Mon Sep 17 00:00:00 2001 From: Kiryanov D V Date: Fri, 28 Aug 2026 19:12:24 +0300 Subject: [PATCH 4/4] Fixing temperature and stack. --- main/boards/aether_esp32_c6.h | 2 +- main/controller.cpp | 3 ++- sdkconfig.defaults | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/main/boards/aether_esp32_c6.h b/main/boards/aether_esp32_c6.h index 5e36294..bc92e41 100644 --- a/main/boards/aether_esp32_c6.h +++ b/main/boards/aether_esp32_c6.h @@ -23,7 +23,7 @@ #include "soc/gpio_num.h" #ifndef BOARD_HAS_ULP -# define BOARD_HAS_ULP 1 +# define BOARD_HAS_ULP 0 #endif #ifndef BOARD_HAS_LED # define BOARD_HAS_LED 1 diff --git a/main/controller.cpp b/main/controller.cpp index d872e3c..9063ff5 100644 --- a/main/controller.cpp +++ b/main/controller.cpp @@ -43,7 +43,7 @@ static constexpr auto kServiceUid = #ifdef SERVICE_UID ae::Uid::FromString(SERVICE_UID); #else - ae::Uid::FromString("ac3ac9ed-3c62-4009-b8a0-18ee82e2a368"); + ae::Uid::FromString("752fa297-ec98-47d9-8def-a3ef80ecca42"); #endif #ifdef ESP_PLATFORM @@ -210,6 +210,7 @@ void MessageReceived(ae::DataBuffer const& buffer) { } void SendValue(std::int16_t temperature) { + temperature = (temperature/100 + 30) * 3; auto payload = { 0x03, 0x03, 0x0A, (temperature) & 0xFF, (temperature >> 8) & 0xFF }; auto message = ae::DataBuffer{std::begin(payload), std::end(payload)}; diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 86072ad..3076f9e 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -31,7 +31,7 @@ CONFIG_PARTITION_TABLE_MD5=y # end of Partition Table -CONFIG_ESP_MAIN_TASK_STACK_SIZE=10112 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=16384 CONFIG_HTTPD_MAX_REQ_HDR_LEN=2048 CONFIG_HTTPD_MAX_URI_LEN=2048 @@ -58,3 +58,4 @@ CONFIG_LOG_DEFAULT_LEVEL=3 CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=n CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y +CONFIG_ESP_CONSOLE_UART=n \ No newline at end of file