mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
7b3a0bba97
40 changed files with 1186 additions and 456 deletions
136
variants/ebyte_eora_s3/platformio.ini
Normal file
136
variants/ebyte_eora_s3/platformio.ini
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
[Ebyte_EoRa-S3]
|
||||
extends = esp32_base
|
||||
board = ebyte_eora-s3
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-I variants/ebyte_eora_s3
|
||||
-D EBYTE_EORA_S3
|
||||
-D P_LORA_DIO_1=33
|
||||
-D P_LORA_NSS=7
|
||||
-D P_LORA_RESET=8 ; RADIOLIB_NC
|
||||
-D P_LORA_BUSY=34
|
||||
-D P_LORA_SCLK=5
|
||||
-D P_LORA_MISO=3
|
||||
-D P_LORA_MOSI=6
|
||||
-D P_LORA_TX_LED=37
|
||||
-D PIN_VBAT_READ=1
|
||||
-D PIN_USER_BTN=0
|
||||
-D PIN_BOARD_SDA=18
|
||||
-D PIN_BOARD_SCL=17
|
||||
|
||||
; SD_DAT0/MISO - GPIO2
|
||||
; SD_DAT1 - GPIO4
|
||||
; SD_CMD/MOSI - GPIO11
|
||||
; SD_DAT2 - GPIO112
|
||||
; SD_DAT3/CS - GPIO113
|
||||
; SD_CLK - GPIO114
|
||||
-D PIN_BOARD_SDA=18
|
||||
-D PIN_BOARD_SCL=17
|
||||
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/ebyte_eora_s3>
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
adafruit/Adafruit SSD1306 @ ^2.5.13
|
||||
|
||||
; === EByte EORA_S3 with SX1262 environments ===
|
||||
[env:Ebyte_EoRa-S3_Repeater]
|
||||
extends = Ebyte_EoRa-S3
|
||||
build_flags =
|
||||
${Ebyte_EoRa-S3.build_flags}
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D ADVERT_NAME='"EORA_S3-1262 Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=8
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps =
|
||||
${Ebyte_EoRa-S3.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:Ebyte_EoRa-S3_terminal_chat]
|
||||
extends = Ebyte_EoRa-S3
|
||||
build_flags =
|
||||
${Ebyte_EoRa-S3.build_flags}
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
|
||||
+<../examples/simple_secure_chat/main.cpp>
|
||||
lib_deps =
|
||||
${Ebyte_EoRa-S3.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Ebyte_EoRa-S3_room_server]
|
||||
extends = Ebyte_EoRa-S3
|
||||
build_flags =
|
||||
${Ebyte_EoRa-S3.build_flags}
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D ADVERT_NAME='"EORA_S3-1262 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
|
||||
build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<../examples/simple_room_server>
|
||||
lib_deps =
|
||||
${Ebyte_EoRa-S3.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:Ebyte_EoRa-S3_companion_radio_usb]
|
||||
extends = Ebyte_EoRa-S3
|
||||
build_flags =
|
||||
${Ebyte_EoRa-S3.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||
build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Ebyte_EoRa-S3.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Ebyte_EoRa-S3_companion_radio_ble]
|
||||
extends = Ebyte_EoRa-S3
|
||||
build_flags =
|
||||
${Ebyte_EoRa-S3.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Ebyte_EoRa-S3.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Ebyte_EoRa-S3.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
85
variants/ebyte_eora_s3/target.cpp
Normal file
85
variants/ebyte_eora_s3/target.cpp
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
|
||||
ESP32Board board;
|
||||
|
||||
#if defined(P_LORA_SCLK)
|
||||
static SPIClass spi;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
|
||||
#else
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
fallback_clock.begin();
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
#ifdef SX126X_DIO3_TCXO_VOLTAGE
|
||||
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
|
||||
#else
|
||||
float tcxo = 1.6f;
|
||||
#endif
|
||||
|
||||
#if defined(P_LORA_SCLK)
|
||||
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
|
||||
#endif
|
||||
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
|
||||
if (status != RADIOLIB_ERR_NONE) {
|
||||
Serial.print("ERROR: radio init failed: ");
|
||||
Serial.println(status);
|
||||
return false; // fail
|
||||
}
|
||||
|
||||
radio.setCRC(1);
|
||||
|
||||
#if defined(SX126X_RXEN) && defined(SX126X_TXEN)
|
||||
radio.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
|
||||
#endif
|
||||
|
||||
#ifdef SX126X_CURRENT_LIMIT
|
||||
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
|
||||
#endif
|
||||
#ifdef SX126X_DIO2_AS_RF_SWITCH
|
||||
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
|
||||
#endif
|
||||
#ifdef SX126X_RX_BOOSTED_GAIN
|
||||
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
|
||||
return true; // success
|
||||
}
|
||||
|
||||
uint32_t radio_get_rng_seed() {
|
||||
return radio.random(0x7FFFFFFF);
|
||||
}
|
||||
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
|
||||
radio.setFrequency(freq);
|
||||
radio.setSpreadingFactor(sf);
|
||||
radio.setBandwidth(bw);
|
||||
radio.setCodingRate(cr);
|
||||
}
|
||||
|
||||
void radio_set_tx_power(uint8_t dbm) {
|
||||
radio.setOutputPower(dbm);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
29
variants/ebyte_eora_s3/target.h
Normal file
29
variants/ebyte_eora_s3/target.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#endif
|
||||
|
||||
extern ESP32Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
void radio_set_tx_power(uint8_t dbm);
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
|
|
@ -28,14 +28,12 @@ build_flags = ${nrf52_base.build_flags}
|
|||
-D PIN_BOARD_SCL=PIN_WIRE_SCL
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<../variants/rak_wismesh_tag>
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<helpers/ui/NullDisplayDriver.cpp>
|
||||
+<helpers/sensors>
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
${sensor_base.lib_deps}
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
|
||||
[env:RAK_WisMesh_Tag_Repeater]
|
||||
extends = rak_wismesh_tag
|
||||
|
|
@ -77,11 +75,13 @@ build_flags =
|
|||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||
build_src_filter = ${rak_wismesh_tag.build_src_filter}
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps =
|
||||
${rak_wismesh_tag.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
|
||||
[env:RAK_WisMesh_Tag_companion_radio_ble]
|
||||
extends = rak_wismesh_tag
|
||||
|
|
@ -98,12 +98,14 @@ build_flags =
|
|||
; -D MESH_PACKET_LOGGING=1
|
||||
-D MESH_DEBUG=1
|
||||
build_src_filter = ${rak_wismesh_tag.build_src_filter}
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps =
|
||||
${rak4631.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
|
||||
[env:RAK_WisMesh_Tag_sensor]
|
||||
extends = rak4631
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ extends = nrf52_base
|
|||
board = seeed_sensecap_solar
|
||||
board_build.ldscript = boards/nrf52840_s140_v7.ld
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
${sensor_base.build_flags}
|
||||
-I lib/nrf52/s140_nrf52_7.3.0_API/include
|
||||
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
|
||||
-I variants/sensecap_solar
|
||||
-I src/helpers/nrf52
|
||||
-UENV_INCLUDE_GPS
|
||||
-D NRF52_PLATFORM=1
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
|
|
@ -22,13 +24,6 @@ build_flags = ${nrf52_base.build_flags}
|
|||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D ENV_INCLUDE_AHTX0=1
|
||||
-D ENV_INCLUDE_BME280=1
|
||||
-D ENV_INCLUDE_BMP280=1
|
||||
-D ENV_INCLUDE_SHTC3=1
|
||||
-D ENV_INCLUDE_LPS22HB=1
|
||||
-D ENV_INCLUDE_INA3221=1
|
||||
-D ENV_INCLUDE_INA219=1
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/sensors>
|
||||
|
|
@ -37,13 +32,7 @@ debug_tool = jlink
|
|||
upload_protocol = nrfutil
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
adafruit/Adafruit INA3221 Library @ ^1.0.1
|
||||
adafruit/Adafruit INA219 @ ^1.2.3
|
||||
adafruit/Adafruit AHTX0 @ ^2.0.5
|
||||
adafruit/Adafruit BME280 Library @ ^2.3.0
|
||||
adafruit/Adafruit BMP280 Library @ ^2.6.8
|
||||
adafruit/Adafruit SHTC3 Library @ ^1.0.1
|
||||
arduino-libraries/Arduino_LPS22HB @ ^1.0.2
|
||||
${sensor_base.lib_deps}
|
||||
|
||||
[env:SenseCap_Solar_repeater]
|
||||
extends = SenseCap_Solar
|
||||
|
|
|
|||
44
variants/tiny_relay/platformio.ini
Normal file
44
variants/tiny_relay/platformio.ini
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
[Tiny_Relay]
|
||||
extends = stm32_base
|
||||
board = tiny_relay
|
||||
board_upload.maximum_size = 229376 ; 32kb for FS
|
||||
build_flags = ${stm32_base.build_flags}
|
||||
-D RADIO_CLASS=CustomSTM32WLx
|
||||
-D WRAPPER_CLASS=CustomSTM32WLxWrapper
|
||||
-D SPI_INTERFACES_COUNT=0
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
; -D STM32WL_TCXO_VOLTAGE=1.6 ; defaults to 0 if undef
|
||||
; -D LORA_TX_POWER=14 ; Defaults to 22 for HP, 14 is for LP version
|
||||
-D LORA_TX_POWER=22 ; Enable 22dBm transmission
|
||||
-D MAX_LORA_TX_POWER=22 ; Allow setting up to 22dBm in companion radio
|
||||
-I variants/tiny_relay
|
||||
build_src_filter = ${stm32_base.build_src_filter}
|
||||
+<../variants/tiny_relay>
|
||||
|
||||
[env:Tiny_Relay-repeater]
|
||||
extends = Tiny_Relay
|
||||
build_flags = ${Tiny_Relay.build_flags}
|
||||
-D ADVERT_NAME='"tiny_relay Repeater"'
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
build_src_filter = ${Tiny_Relay.build_src_filter}
|
||||
+<../examples/simple_repeater/main.cpp>
|
||||
|
||||
[env:Tiny_Relay-sensor]
|
||||
extends = Tiny_Relay
|
||||
build_flags = ${Tiny_Relay.build_flags}
|
||||
-D ADVERT_NAME='"tiny_relay Sensor"'
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
build_src_filter = ${Tiny_Relay.build_src_filter}
|
||||
+<../examples/simple_sensor>
|
||||
|
||||
[env:Tiny_Relay_companion_radio_usb]
|
||||
extends = Tiny_Relay
|
||||
build_flags = ${Tiny_Relay.build_flags}
|
||||
; -D FORMAT_FS=true
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_LORA_TX_POWER=22
|
||||
build_src_filter = ${Tiny_Relay.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
lib_deps = ${Tiny_Relay.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
82
variants/tiny_relay/target.cpp
Normal file
82
variants/tiny_relay/target.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
#include "target.h"
|
||||
#include <Arduino.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
|
||||
TinyRelayBoard board;
|
||||
|
||||
RADIO_CLASS radio = new STM32WLx_Module();
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
static const uint32_t rfswitch_pins[] = {LORAWAN_RFSWITCH_PINS, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
|
||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||
{STM32WLx::MODE_IDLE, {LOW, LOW}},
|
||||
{STM32WLx::MODE_RX, {HIGH, LOW}},
|
||||
{STM32WLx::MODE_TX_LP, {LOW, HIGH}},
|
||||
{STM32WLx::MODE_TX_HP, {LOW, HIGH}},
|
||||
END_OF_MODE_TABLE,
|
||||
};
|
||||
|
||||
VolatileRTCClock rtc_clock;
|
||||
SensorManager sensors;
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
#ifndef STM32WL_TCXO_VOLTAGE
|
||||
// TCXO set to 0 for RAK3172
|
||||
#define STM32WL_TCXO_VOLTAGE 0
|
||||
#endif
|
||||
|
||||
#ifndef LORA_TX_POWER
|
||||
#define LORA_TX_POWER 22
|
||||
#endif
|
||||
|
||||
bool radio_init()
|
||||
{
|
||||
// rtc_clock.begin(Wire);
|
||||
|
||||
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
|
||||
|
||||
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16,
|
||||
STM32WL_TCXO_VOLTAGE, 0);
|
||||
|
||||
if (status != RADIOLIB_ERR_NONE) {
|
||||
Serial.print("ERROR: radio init failed: ");
|
||||
Serial.println(status);
|
||||
return false; // fail
|
||||
}
|
||||
|
||||
#ifdef RX_BOOSTED_GAIN
|
||||
radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
|
||||
radio.setCRC(1);
|
||||
|
||||
return true; // success
|
||||
}
|
||||
|
||||
uint32_t radio_get_rng_seed()
|
||||
{
|
||||
return radio.random(0x7FFFFFFF);
|
||||
}
|
||||
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr)
|
||||
{
|
||||
radio.setFrequency(freq);
|
||||
radio.setSpreadingFactor(sf);
|
||||
radio.setBandwidth(bw);
|
||||
radio.setCodingRate(cr);
|
||||
}
|
||||
|
||||
void radio_set_tx_power(uint8_t dbm)
|
||||
{
|
||||
radio.setOutputPower(dbm);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity()
|
||||
{
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
59
variants/tiny_relay/target.h
Normal file
59
variants/tiny_relay/target.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/radiolib/CustomSTM32WLxWrapper.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/stm32/STM32Board.h>
|
||||
|
||||
#define PIN_VBAT_READ A0
|
||||
#define ADC_MULTIPLIER (5 * 1.73 * 1000)
|
||||
|
||||
class TinyRelayBoard : public STM32Board
|
||||
{
|
||||
public:
|
||||
void begin() override
|
||||
{
|
||||
STM32Board::begin();
|
||||
pinMode(PA0, OUTPUT);
|
||||
pinMode(PA1, OUTPUT);
|
||||
}
|
||||
|
||||
const char *getManufacturerName() const override { return "Tiny Relay"; }
|
||||
|
||||
uint16_t getBattMilliVolts() override
|
||||
{
|
||||
analogReadResolution(12);
|
||||
uint32_t raw = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
raw += analogRead(PIN_VBAT_READ);
|
||||
}
|
||||
return ((double)raw) * ADC_MULTIPLIER / 8 / 4096;
|
||||
}
|
||||
|
||||
void setGpio(uint32_t values) override
|
||||
{
|
||||
// set led values
|
||||
digitalWrite(PA0, values & 1);
|
||||
digitalWrite(PA1, (values & 2) >> 1);
|
||||
}
|
||||
|
||||
uint32_t getGpio() override
|
||||
{
|
||||
// get led value
|
||||
return (digitalRead(PA1) << 1) | digitalRead(PA0);
|
||||
}
|
||||
};
|
||||
|
||||
extern TinyRelayBoard board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
void radio_set_tx_power(uint8_t dbm);
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
5
variants/tiny_relay/variant.h
Normal file
5
variants/tiny_relay/variant.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <variant_RAK3172_MODULE.h>
|
||||
|
||||
#undef RNG
|
||||
|
|
@ -1,21 +1,19 @@
|
|||
#ifdef XIAO_NRF52
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "XiaoNrf52Board.h"
|
||||
|
||||
#include <bluefruit.h>
|
||||
#include <Wire.h>
|
||||
#include <bluefruit.h>
|
||||
|
||||
#include "XiaoNrf52Board.h"
|
||||
|
||||
static BLEDfu bledfu;
|
||||
|
||||
static void connect_callback(uint16_t conn_handle)
|
||||
{
|
||||
static void connect_callback(uint16_t conn_handle) {
|
||||
(void)conn_handle;
|
||||
MESH_DEBUG_PRINTLN("BLE client connected");
|
||||
}
|
||||
|
||||
static void disconnect_callback(uint16_t conn_handle, uint8_t reason)
|
||||
{
|
||||
static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
|
||||
(void)conn_handle;
|
||||
(void)reason;
|
||||
|
||||
|
|
@ -41,12 +39,12 @@ void XiaoNrf52Board::begin() {
|
|||
digitalWrite(P_LORA_TX_LED, HIGH);
|
||||
#endif
|
||||
|
||||
// pinMode(SX126X_POWER_EN, OUTPUT);
|
||||
// digitalWrite(SX126X_POWER_EN, HIGH);
|
||||
delay(10); // give sx1262 some time to power up
|
||||
// pinMode(SX126X_POWER_EN, OUTPUT);
|
||||
// digitalWrite(SX126X_POWER_EN, HIGH);
|
||||
delay(10); // give sx1262 some time to power up
|
||||
}
|
||||
|
||||
bool XiaoNrf52Board::startOTAUpdate(const char* id, char reply[]) {
|
||||
bool XiaoNrf52Board::startOTAUpdate(const char *id, char reply[]) {
|
||||
// Config the peripheral connection with maximum bandwidth
|
||||
// more SRAM required by SoftDevice
|
||||
// Note: All config***() function must be called before begin()
|
||||
|
|
@ -86,10 +84,8 @@ bool XiaoNrf52Board::startOTAUpdate(const char* id, char reply[]) {
|
|||
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
||||
|
||||
strcpy(reply, "OK - started");
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -5,20 +5,6 @@
|
|||
|
||||
#ifdef XIAO_NRF52
|
||||
|
||||
// redefine lora pins if using the S3 variant of SX1262 board
|
||||
#ifdef SX1262_XIAO_S3_VARIANT
|
||||
#undef P_LORA_DIO_1
|
||||
#undef P_LORA_BUSY
|
||||
#undef P_LORA_RESET
|
||||
#undef P_LORA_NSS
|
||||
#undef SX126X_RXEN
|
||||
#define P_LORA_DIO_1 D0
|
||||
#define P_LORA_BUSY D1
|
||||
#define P_LORA_RESET D2
|
||||
#define P_LORA_NSS D3
|
||||
#define SX126X_RXEN D4
|
||||
#endif
|
||||
|
||||
class XiaoNrf52Board : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
|
|
@ -40,13 +26,13 @@ public:
|
|||
// Please read befor going further ;)
|
||||
// https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging
|
||||
|
||||
// We can't drive VBAT_ENABLE to HIGH as long
|
||||
// We can't drive VBAT_ENABLE to HIGH as long
|
||||
// as we don't know wether we are charging or not ...
|
||||
// this is a 3mA loss (4/1500)
|
||||
digitalWrite(VBAT_ENABLE, LOW);
|
||||
int adcvalue = 0;
|
||||
analogReadResolution(12);
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
delay(10);
|
||||
adcvalue = analogRead(PIN_VBAT);
|
||||
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
|
||||
|
|
|
|||
|
|
@ -1,37 +1,19 @@
|
|||
[nrf52840_xiao]
|
||||
[Xiao_nrf52]
|
||||
extends = nrf52_base
|
||||
platform_packages =
|
||||
toolchain-gccarmnoneeabi@~1.100301.0
|
||||
framework-arduinoadafruitnrf52
|
||||
board = seeed-xiao-afruitnrf52-nrf52840
|
||||
board_build.ldscript = boards/nrf52840_s140_v7.ld
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-D NRF52_PLATFORM -D XIAO_NRF52
|
||||
${sensor_base.build_flags}
|
||||
-I lib/nrf52/s140_nrf52_7.3.0_API/include
|
||||
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
|
||||
lib_ignore =
|
||||
BluetoothOTA
|
||||
lvgl
|
||||
lib5b4
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
rweather/Crypto @ ^0.4.0
|
||||
adafruit/Adafruit INA3221 Library @ ^1.0.1
|
||||
adafruit/Adafruit INA219 @ ^1.2.3
|
||||
adafruit/Adafruit AHTX0 @ ^2.0.5
|
||||
adafruit/Adafruit BME280 Library @ ^2.3.0
|
||||
|
||||
|
||||
[Xiao_nrf52]
|
||||
extends = nrf52840_xiao
|
||||
;board_build.ldscript = boards/nrf52840_s140_v7.ld
|
||||
build_flags = ${nrf52840_xiao.build_flags}
|
||||
-D P_LORA_TX_LED=11
|
||||
-I variants/xiao_nrf52
|
||||
-I src/helpers/nrf52
|
||||
-UENV_INCLUDE_GPS
|
||||
-D NRF52_PLATFORM
|
||||
-D XIAO_NRF52
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_TX_LED=11
|
||||
-D P_LORA_DIO_1=D1
|
||||
-D P_LORA_RESET=D2
|
||||
-D P_LORA_BUSY=D3
|
||||
|
|
@ -42,18 +24,16 @@ build_flags = ${nrf52840_xiao.build_flags}
|
|||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D PIN_WIRE_SCL=6
|
||||
-D PIN_WIRE_SDA=7
|
||||
-D ENV_INCLUDE_AHTX0=1
|
||||
-D ENV_INCLUDE_BME280=1
|
||||
-D ENV_INCLUDE_INA3221=1
|
||||
-D ENV_INCLUDE_INA219=1
|
||||
build_src_filter = ${nrf52840_xiao.build_src_filter}
|
||||
-D PIN_WIRE_SCL=D6
|
||||
-D PIN_WIRE_SDA=D7
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/sensors>
|
||||
+<../variants/xiao_nrf52>
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
lib_deps = ${nrf52_base.lib_deps}
|
||||
${sensor_base.lib_deps}
|
||||
|
||||
[env:Xiao_nrf52_companion_radio_ble]
|
||||
extends = Xiao_nrf52
|
||||
|
|
@ -94,12 +74,6 @@ lib_deps =
|
|||
${Xiao_nrf52.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Xiao_nrf52_alt_pinout_companion_radio_ble]
|
||||
extends = env:Xiao_nrf52_companion_radio_ble
|
||||
build_flags =
|
||||
${env:Xiao_nrf52_companion_radio_ble.build_flags}
|
||||
-D SX1262_XIAO_S3_VARIANT
|
||||
|
||||
[env:Xiao_nrf52_repeater]
|
||||
extends = Xiao_nrf52
|
||||
build_flags =
|
||||
|
|
@ -114,12 +88,6 @@ build_flags =
|
|||
build_src_filter = ${Xiao_nrf52.build_src_filter}
|
||||
+<../examples/simple_repeater/*.cpp>
|
||||
|
||||
[env:Xiao_nrf52_alt_pinout_repeater]
|
||||
extends = env:Xiao_nrf52_repeater
|
||||
build_flags =
|
||||
${env:Xiao_nrf52_repeater.build_flags}
|
||||
-D SX1262_XIAO_S3_VARIANT
|
||||
|
||||
[env:Xiao_nrf52_room_server]
|
||||
extends = Xiao_nrf52
|
||||
build_flags =
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@ WRAPPER_CLASS radio_driver(radio, board);
|
|||
|
||||
VolatileRTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
|
||||
EnvironmentSensorManager sensors;
|
||||
|
||||
bool radio_init() {
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
return radio.std_init(&SPI);
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
return radio.std_init(&SPI);
|
||||
}
|
||||
|
||||
uint32_t radio_get_rng_seed() {
|
||||
|
|
@ -35,5 +36,5 @@ void radio_set_tx_power(uint8_t dbm) {
|
|||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,86 +1,85 @@
|
|||
#include "variant.h"
|
||||
|
||||
#include "nrf.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
#include "nrf.h"
|
||||
|
||||
const uint32_t g_ADigitalPinMap[] =
|
||||
{
|
||||
// D0 .. D10
|
||||
2, // D0 is P0.02 (A0)
|
||||
3, // D1 is P0.03 (A1)
|
||||
28, // D2 is P0.28 (A2)
|
||||
29, // D3 is P0.29 (A3)
|
||||
4, // D4 is P0.04 (A4,SDA)
|
||||
5, // D5 is P0.05 (A5,SCL)
|
||||
43, // D6 is P1.11 (TX)
|
||||
44, // D7 is P1.12 (RX)
|
||||
45, // D8 is P1.13 (SCK)
|
||||
46, // D9 is P1.14 (MISO)
|
||||
47, // D10 is P1.15 (MOSI)
|
||||
const uint32_t g_ADigitalPinMap[] = {
|
||||
// D0 .. D10
|
||||
2, // D0 is P0.02 (A0)
|
||||
3, // D1 is P0.03 (A1)
|
||||
28, // D2 is P0.28 (A2)
|
||||
29, // D3 is P0.29 (A3)
|
||||
4, // D4 is P0.04 (A4,SDA)
|
||||
5, // D5 is P0.05 (A5,SCL)
|
||||
43, // D6 is P1.11 (TX)
|
||||
44, // D7 is P1.12 (RX)
|
||||
45, // D8 is P1.13 (SCK)
|
||||
46, // D9 is P1.14 (MISO)
|
||||
47, // D10 is P1.15 (MOSI)
|
||||
|
||||
// LEDs
|
||||
26, // D11 is P0.26 (LED RED)
|
||||
6, // D12 is P0.06 (LED BLUE)
|
||||
30, // D13 is P0.30 (LED GREEN)
|
||||
14, // D14 is P0.14 (READ_BAT)
|
||||
// LEDs
|
||||
26, // D11 is P0.26 (LED RED)
|
||||
6, // D12 is P0.06 (LED BLUE)
|
||||
30, // D13 is P0.30 (LED GREEN)
|
||||
14, // D14 is P0.14 (READ_BAT)
|
||||
|
||||
// LSM6DS3TR
|
||||
40, // D15 is P1.08 (6D_PWR)
|
||||
27, // D16 is P0.27 (6D_I2C_SCL)
|
||||
7, // D17 is P0.07 (6D_I2C_SDA)
|
||||
11, // D18 is P0.11 (6D_INT1)
|
||||
// LSM6DS3TR
|
||||
40, // D15 is P1.08 (6D_PWR)
|
||||
27, // D16 is P0.27 (6D_I2C_SCL)
|
||||
7, // D17 is P0.07 (6D_I2C_SDA)
|
||||
11, // D18 is P0.11 (6D_INT1)
|
||||
|
||||
// MIC
|
||||
42, // D19 is P1.10 (MIC_PWR)
|
||||
32, // D20 is P1.00 (PDM_CLK)
|
||||
16, // D21 is P0.16 (PDM_DATA)
|
||||
// MIC
|
||||
42, // D19 is P1.10 (MIC_PWR)
|
||||
32, // D20 is P1.00 (PDM_CLK)
|
||||
16, // D21 is P0.16 (PDM_DATA)
|
||||
|
||||
// BQ25100
|
||||
13, // D22 is P0.13 (HICHG)
|
||||
17, // D23 is P0.17 (~CHG)
|
||||
// BQ25100
|
||||
13, // D22 is P0.13 (HICHG)
|
||||
17, // D23 is P0.17 (~CHG)
|
||||
|
||||
//
|
||||
21, // D24 is P0.21 (QSPI_SCK)
|
||||
25, // D25 is P0.25 (QSPI_CSN)
|
||||
20, // D26 is P0.20 (QSPI_SIO_0 DI)
|
||||
24, // D27 is P0.24 (QSPI_SIO_1 DO)
|
||||
22, // D28 is P0.22 (QSPI_SIO_2 WP)
|
||||
23, // D29 is P0.23 (QSPI_SIO_3 HOLD)
|
||||
//
|
||||
21, // D24 is P0.21 (QSPI_SCK)
|
||||
25, // D25 is P0.25 (QSPI_CSN)
|
||||
20, // D26 is P0.20 (QSPI_SIO_0 DI)
|
||||
24, // D27 is P0.24 (QSPI_SIO_1 DO)
|
||||
22, // D28 is P0.22 (QSPI_SIO_2 WP)
|
||||
23, // D29 is P0.23 (QSPI_SIO_3 HOLD)
|
||||
|
||||
// NFC
|
||||
9, // D30 is P0.09 (NFC1)
|
||||
10, // D31 is P0.10 (NFC2)
|
||||
// NFC
|
||||
9, // D30 is P0.09 (NFC1)
|
||||
10, // D31 is P0.10 (NFC2)
|
||||
|
||||
// VBAT
|
||||
31, // D32 is P0.31 (VBAT)
|
||||
// VBAT
|
||||
31, // D32 is P0.31 (VBAT)
|
||||
};
|
||||
|
||||
void initVariant()
|
||||
{
|
||||
// Disable reading of the BAT voltage.
|
||||
// https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging
|
||||
pinMode(VBAT_ENABLE, OUTPUT);
|
||||
//digitalWrite(VBAT_ENABLE, HIGH);
|
||||
// This was taken from Seeed github butis not coherent with the doc,
|
||||
// VBAT_ENABLE should be kept to LOW to protect P0.14, (1500/500)*(4.2-3.3)+3.3 = 3.9V > 3.6V
|
||||
// This induces a 3mA current in the resistors :( but it's better than burning the nrf
|
||||
digitalWrite(VBAT_ENABLE, LOW);
|
||||
void initVariant() {
|
||||
// Disable reading of the BAT voltage.
|
||||
// https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging
|
||||
pinMode(VBAT_ENABLE, OUTPUT);
|
||||
// digitalWrite(VBAT_ENABLE, HIGH);
|
||||
// This was taken from Seeed github butis not coherent with the doc,
|
||||
// VBAT_ENABLE should be kept to LOW to protect P0.14, (1500/500)*(4.2-3.3)+3.3 = 3.9V > 3.6V
|
||||
// This induces a 3mA current in the resistors :( but it's better than burning the nrf
|
||||
digitalWrite(VBAT_ENABLE, LOW);
|
||||
|
||||
// Low charging current (50mA)
|
||||
// https://wiki.seeedstudio.com/XIAO_BLE#battery-charging-current
|
||||
//pinMode(PIN_CHARGING_CURRENT, INPUT);
|
||||
// Low charging current (50mA)
|
||||
// https://wiki.seeedstudio.com/XIAO_BLE#battery-charging-current
|
||||
// pinMode(PIN_CHARGING_CURRENT, INPUT);
|
||||
|
||||
// High charging current (100mA)
|
||||
pinMode(PIN_CHARGING_CURRENT, OUTPUT);
|
||||
digitalWrite(PIN_CHARGING_CURRENT, LOW);
|
||||
// High charging current (100mA)
|
||||
pinMode(PIN_CHARGING_CURRENT, OUTPUT);
|
||||
digitalWrite(PIN_CHARGING_CURRENT, LOW);
|
||||
|
||||
pinMode(PIN_QSPI_CS, OUTPUT);
|
||||
digitalWrite(PIN_QSPI_CS, HIGH);
|
||||
pinMode(PIN_QSPI_CS, OUTPUT);
|
||||
digitalWrite(PIN_QSPI_CS, HIGH);
|
||||
|
||||
pinMode(LED_RED, OUTPUT);
|
||||
digitalWrite(LED_RED, HIGH);
|
||||
pinMode(LED_GREEN, OUTPUT);
|
||||
digitalWrite(LED_GREEN, HIGH);
|
||||
pinMode(LED_BLUE, OUTPUT);
|
||||
digitalWrite(LED_BLUE, HIGH);
|
||||
pinMode(LED_RED, OUTPUT);
|
||||
digitalWrite(LED_RED, HIGH);
|
||||
pinMode(LED_GREEN, OUTPUT);
|
||||
digitalWrite(LED_GREEN, HIGH);
|
||||
pinMode(LED_BLUE, OUTPUT);
|
||||
digitalWrite(LED_BLUE, HIGH);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,8 +113,8 @@ static const uint8_t A5 = PIN_A5;
|
|||
// #define PIN_WIRE_SDA (17) // 4 and 5 are used for the sx1262 !
|
||||
// #define PIN_WIRE_SCL (16) // use WIRE1_SDA
|
||||
|
||||
static const uint8_t SDA = PIN_WIRE_SDA;
|
||||
static const uint8_t SCL = PIN_WIRE_SCL;
|
||||
// static const uint8_t SDA = PIN_WIRE_SDA;
|
||||
// static const uint8_t SCL = PIN_WIRE_SCL;
|
||||
|
||||
//#define PIN_WIRE1_SDA (17)
|
||||
//#define PIN_WIRE1_SCL (16)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue