mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
xiao c3: migrated to esm, added missing roles, cleanup
This commit is contained in:
parent
da52d08168
commit
4dc3dda2d8
4 changed files with 61 additions and 23 deletions
112
variants/xiao_c3/XiaoC3Board.h
Normal file
112
variants/xiao_c3/XiaoC3Board.h
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
#pragma once
|
||||
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <driver/rtc_io.h>
|
||||
#include <driver/uart.h>
|
||||
|
||||
class XiaoC3Board : public ESP32Board {
|
||||
public:
|
||||
void begin() {
|
||||
ESP32Board::begin();
|
||||
|
||||
esp_reset_reason_t reason = esp_reset_reason();
|
||||
if (reason == ESP_RST_DEEPSLEEP) {
|
||||
long wakeup_source = esp_sleep_get_gpio_wakeup_status(); // esp_sleep_get_ext1_wakeup_status();
|
||||
if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep)
|
||||
startup_reason = BD_STARTUP_RX_PACKET;
|
||||
}
|
||||
|
||||
#if defined(LORA_TX_BOOST_PIN)
|
||||
gpio_hold_dis((gpio_num_t) LORA_TX_BOOST_PIN);
|
||||
gpio_deep_sleep_hold_dis();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PIN_VBAT_READ
|
||||
// battery read support
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
#endif
|
||||
|
||||
#ifdef LORA_TX_BOOST_PIN
|
||||
pinMode(LORA_TX_BOOST_PIN, OUTPUT);
|
||||
digitalWrite(LORA_TX_BOOST_PIN, HIGH);
|
||||
#endif
|
||||
|
||||
#ifdef P_LORA_TX_LED
|
||||
pinMode(P_LORA_TX_LED, OUTPUT);
|
||||
digitalWrite(P_LORA_TX_LED, LOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
void enterDeepSleep(uint32_t secs, int8_t wake_pin = -1) {
|
||||
gpio_set_direction(gpio_num_t(P_LORA_DIO_1), GPIO_MODE_INPUT);
|
||||
if (wake_pin >= 0) {
|
||||
gpio_set_direction((gpio_num_t)wake_pin, GPIO_MODE_INPUT);
|
||||
}
|
||||
|
||||
//hold disable, isolate and power domain config functions may be unnecessary
|
||||
//gpio_deep_sleep_hold_dis();
|
||||
//esp_sleep_config_gpio_isolate();
|
||||
gpio_deep_sleep_hold_en();
|
||||
|
||||
#if defined(LORA_TX_BOOST_PIN)
|
||||
gpio_hold_en((gpio_num_t) LORA_TX_BOOST_PIN);
|
||||
gpio_deep_sleep_hold_en();
|
||||
#endif
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
if (wake_pin >= 0) {
|
||||
esp_deep_sleep_enable_gpio_wakeup((1 << P_LORA_DIO_1) | (1 << wake_pin), ESP_GPIO_WAKEUP_GPIO_HIGH);
|
||||
} else {
|
||||
esp_deep_sleep_enable_gpio_wakeup(1 << P_LORA_DIO_1, ESP_GPIO_WAKEUP_GPIO_HIGH);
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
#if defined(LORA_TX_BOOST_PIN) || defined(P_LORA_TX_LED)
|
||||
void onBeforeTransmit() override {
|
||||
#if defined(P_LORA_TX_LED)
|
||||
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
|
||||
#endif
|
||||
#if defined(LORA_TX_BOOST_PIN)
|
||||
digitalWrite(LORA_TX_BOOST_PIN, LOW);
|
||||
delay(5);
|
||||
#endif
|
||||
}
|
||||
void onAfterTransmit() override {
|
||||
#if defined(LORA_TX_BOOST_PIN)
|
||||
digitalWrite(LORA_TX_BOOST_PIN, HIGH);
|
||||
#endif
|
||||
#if defined(P_LORA_TX_LED)
|
||||
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
#ifdef PIN_VBAT_READ
|
||||
analogReadResolution(10);
|
||||
uint32_t raw = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
raw += analogRead(PIN_VBAT_READ);
|
||||
}
|
||||
raw = raw / 8;
|
||||
|
||||
return ((5.78 * raw) / 1024.0) * 1000;
|
||||
#else
|
||||
return 0; // not supported
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* getManufacturerName() const override {
|
||||
return "Xiao C3";
|
||||
}
|
||||
};
|
||||
|
|
@ -3,6 +3,8 @@ extends = esp32_base
|
|||
board = seeed_xiao_esp32c3
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
${sensor_base.build_flags}
|
||||
-UENV_INCLUDE_GPS
|
||||
-I variants/xiao_c3
|
||||
-D ESP32_CPU_FREQ=80
|
||||
-D PIN_VBAT_READ=D0
|
||||
|
|
@ -12,23 +14,27 @@ build_flags =
|
|||
-D P_LORA_BUSY=D3
|
||||
-D PIN_BOARD_SDA=D6
|
||||
-D PIN_BOARD_SCL=D7
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_RXEN=D5
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/xiao_c3>
|
||||
+<helpers/sensors>
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
${sensor_base.lib_deps}
|
||||
|
||||
[env:Xiao_C3_sx1262_repeater]
|
||||
[env:Xiao_C3_repeater]
|
||||
extends = Xiao_esp32_C3
|
||||
build_src_filter = ${Xiao_esp32_C3.build_src_filter}
|
||||
+<../examples/simple_repeater/*.cpp>
|
||||
build_flags =
|
||||
${Xiao_esp32_C3.build_flags}
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D LORA_TX_POWER=22
|
||||
-D ADVERT_NAME='"Xiao C3 Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
|
|
@ -41,6 +47,24 @@ lib_deps =
|
|||
${esp32_ota.lib_deps}
|
||||
bakercp/CRC32 @ ^2.0.0
|
||||
|
||||
[env:Xiao_C3_room_server]
|
||||
extends = Xiao_esp32_C3
|
||||
build_src_filter = ${Xiao_esp32_C3.build_src_filter}
|
||||
+<../examples/simple_room_server/*.cpp>
|
||||
build_flags =
|
||||
${Xiao_esp32_C3.build_flags}
|
||||
-D ADVERT_NAME='"Xiao C3 Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps =
|
||||
${Xiao_esp32_C3.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
bakercp/CRC32 @ ^2.0.0
|
||||
|
||||
[env:Xiao_C3_companion_radio_ble]
|
||||
extends = Xiao_esp32_C3
|
||||
build_src_filter = ${Xiao_esp32_C3.build_src_filter}
|
||||
|
|
@ -48,10 +72,6 @@ build_src_filter = ${Xiao_esp32_C3.build_src_filter}
|
|||
+<helpers/esp32/*.cpp>
|
||||
build_flags =
|
||||
${Xiao_esp32_C3.build_flags}
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D LORA_TX_POWER=22
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
|
|
@ -71,10 +91,6 @@ build_src_filter = ${Xiao_esp32_C3.build_src_filter}
|
|||
+<helpers/esp32/*.cpp>
|
||||
build_flags =
|
||||
${Xiao_esp32_C3.build_flags}
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D LORA_TX_POWER=22
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
|
|
@ -85,3 +101,24 @@ lib_deps =
|
|||
${Xiao_esp32_C3.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Xiao_C3_companion_radio_wifi]
|
||||
extends = Xiao_esp32_C3
|
||||
build_src_filter = ${Xiao_esp32_C3.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<helpers/esp32/*.cpp>
|
||||
build_flags =
|
||||
${Xiao_esp32_C3.build_flags}
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D WIFI_DEBUG_LOGGING=1
|
||||
-D WIFI_SSID='"myssid"'
|
||||
-D WIFI_PWD='"mypwd"'
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps =
|
||||
${Xiao_esp32_C3.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,14 @@ WRAPPER_CLASS radio_driver(radio, board);
|
|||
|
||||
ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||
#else
|
||||
EnvironmentSensorManager sensors;
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
fallback_clock.begin();
|
||||
|
|
|
|||
|
|
@ -3,16 +3,15 @@
|
|||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/XiaoC3Board.h>
|
||||
#include <XiaoC3Board.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/radiolib/CustomSX1268Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
|
||||
extern XiaoC3Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
extern EnvironmentSensorManager sensors;
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue