Skip to content
Open
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
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
9 changes: 5 additions & 4 deletions main/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
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