Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd-esp32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(AE_FILTRATION On CACHE BOOL "Set filtration mode by default" FORCE)

# add user provided config wich will be included as regular .h file
# Add a user-provided config file, which will be included as a regular .h file
set(USER_CONFIG "user_config.h" CACHE PATH "" FORCE)
# ${USER_CONFIG} must be an absolute path or a path to something listed in include directories
# Add a user-provided config file, which will be included as a regular .h file.
set(USER_CONFIG "${CMAKE_CURRENT_LIST_DIR}/main/user_config.h" CACHE FILEPATH
"Path to the Aether user configuration header")
include_directories(${CMAKE_CURRENT_LIST_DIR}/main)

if (CM_PLATFORM STREQUAL "ESP32")
Expand Down
1 change: 0 additions & 1 deletion main/boards/m5stack_atom_lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion main/boards/nano_esp32_c6.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 10 additions & 25 deletions main/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
#include <cstdlib>
#include <iostream>


#include "aether/all.h"
#include "aether/env.h"
#include "sensors/sensors.h"
#include "sleeping/sleeping.h"


using namespace std::chrono_literals;

/**
Expand All @@ -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("752fa297-ec98-47d9-8def-a3ef80ecca42");
#endif

#ifdef ESP_PLATFORM
Expand Down Expand Up @@ -88,7 +91,7 @@ void SleepReady();
// Go to sleep method
void GoToSleep(ae::TimePoint time_point);

static ae::RcPtr<ae::AetherApp> aether_app;
static std::unique_ptr<ae::AetherApp> aether_app;
static ae::Client::ptr client;
static std::unique_ptr<ae::P2pStream> message_stream;

Expand Down Expand Up @@ -130,7 +133,7 @@ void loop() {
} else {
// cleanup resources
message_stream.reset();
aether_app.Reset();
aether_app.reset();
}
}

Expand Down Expand Up @@ -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);
Expand All @@ -206,28 +210,9 @@ 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;
}
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)};

message_stream->Write(std::move(message)).status_event().Subscribe([](auto) {
// with any result ready to sleep
Expand Down
6 changes: 3 additions & 3 deletions main/sensors/esp_main_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions main/sensors/stcc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions main/sleeping/ulp_sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "aether/all.h"

#if ULP_SLEEP == 1
# include <iostream>

# include <freertos/FreeRTOS.h>
# include <freertos/task.h>
Expand Down
46 changes: 25 additions & 21 deletions main/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,42 @@
#if ESP_PLATFORM
# include "sdkconfig.h"
#endif
#include "aether/config_consts.h"

#define AE_CRYPTO_ASYNC AE_HYDRO_CRYPTO_PK
#define AE_CRYPTO_SYNC AE_HYDRO_CRYPTO_SK
#define AE_SIGNATURE AE_HYDRO_SIGNATURE
#define AE_KDF AE_HYDRO_KDF
#if !defined IS_ULP_COCPU
# include "aether/config_consts.h"

#if AE_DISTILLATION || AE_FILTRATION
# define AE_SUPPORT_REGISTRATION 1
# define AE_SUPPORT_CLOUD_DNS 1
#else
# define AE_SUPPORT_REGISTRATION 0
# define AE_SUPPORT_CLOUD_DNS 0
#endif
# define AE_CRYPTO_ASYNC AE_HYDRO_CRYPTO_PK
# define AE_CRYPTO_SYNC AE_HYDRO_CRYPTO_SK
# define AE_SIGNATURE AE_HYDRO_SIGNATURE
# define AE_KDF AE_HYDRO_KDF

#define AE_SUPPORT_SPIFS_FS 1
# if AE_DISTILLATION || AE_FILTRATION
# define AE_SUPPORT_REGISTRATION 1
# define AE_SUPPORT_CLOUD_DNS 1
# else
# define AE_SUPPORT_REGISTRATION 0
# define AE_SUPPORT_CLOUD_DNS 0
# endif

# define AE_SUPPORT_SPIFS_FS 1

// telemetry
#define AE_TELE_ENABLED 1
#define AE_TELE_LOG_CONSOLE 1
# define AE_TELE_ENABLED 1
# define AE_TELE_LOG_CONSOLE 1

#define AE_STATISTICS_MAX_SIZE 1024
# define AE_STATISTICS_MAX_SIZE 1024

#define AE_TELE_DEBUG_MODULES AE_ALL
# define AE_TELE_DEBUG_MODULES AE_ALL
#endif

#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
Expand Down
3 changes: 2 additions & 1 deletion sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions system/partitions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, , 0x6000,
phy_init, data, phy, , 0x1000,
factory, app, factory, , 2M,
storage, data, spiffs, , 1900K
factory, app, factory, , 3M,
storage, data, spiffs, , 900K
8 changes: 0 additions & 8 deletions ulp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ ulp_add_build_binary_targets(${ULP_APP_NAME})

target_include_directories(${ULP_APP_NAME} PUBLIC "${CMAKE_CURRENT_LIST_DIR}/../main")

include(../cmake/CPM.cmake)
CPMAddPackage(URI "https://github.com/aethernetio/aether-client-cpp.git#main")

# not link but only setup include directory for aether/config_consts.h
target_include_directories(${ULP_APP_NAME} PUBLIC "${aether-client-cpp_SOURCE_DIR}")

target_compile_definitions(${ULP_APP_NAME} PRIVATE "ULP_MODE=1")

# Calculate where the build folder of the main project is located
# ExternalProject is usually built inside build/ulp_main-prefix/src/ulp_main-build
# We need to go up to the root of the build folder
Expand Down