Merge remote-tracking branch 'origin/dev' into jbrazio/2025_3f11ad35

This commit is contained in:
João Brázio 2025-07-29 00:31:52 +01:00
commit 85273a6dc6
No known key found for this signature in database
GPG key ID: 56A1490716A324DD
122 changed files with 4575 additions and 1059 deletions

View file

@ -2,10 +2,10 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomSX1268Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1268Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>

View file

@ -10,43 +10,10 @@ ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
SensorManager sensors;
#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);
#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
rtc_clock.begin(Wire);
return radio.std_init(&SPI);
}
uint32_t radio_get_rng_seed() {

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include "HT-CT62Board.h"
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/HeltecV3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/HeltecV2Board.h>
#include <helpers/CustomSX1276Wrapper.h>
#include <helpers/radiolib/CustomSX1276Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#ifdef DISPLAY_CLASS

View file

@ -169,6 +169,30 @@ lib_deps =
${Heltec_lora32_v3.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Heltec_v3_sensor]
extends = Heltec_lora32_v3
build_flags =
${Heltec_lora32_v3.build_flags}
-D ADVERT_NAME='"Heltec v3 Sensor"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ENV_PIN_SDA=33
-D ENV_PIN_SCL=34
-D ENV_INCLUDE_MLX90614=1
-D ENV_INCLUDE_VL53L0X=1
-D DISPLAY_CLASS=SSD1306Display
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v3.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_sensor>
lib_deps =
${Heltec_lora32_v3.lib_deps}
${esp32_ota.lib_deps}
adafruit/Adafruit MLX90614 Library @ ^2.1.5
adafruit/Adafruit_VL53L0X @ ^1.2.4
[env:Heltec_WSL3_repeater]
extends = Heltec_lora32_v3
build_flags =
@ -220,3 +244,19 @@ build_src_filter = ${Heltec_lora32_v3.build_src_filter}
lib_deps =
${Heltec_lora32_v3.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:Heltec_WSL3_sensor]
extends = Heltec_lora32_v3
build_flags =
${Heltec_lora32_v3.build_flags}
-D ADVERT_NAME='"Heltec Sensor"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Heltec_lora32_v3.build_src_filter}
+<../examples/simple_sensor>
lib_deps =
${Heltec_lora32_v3.lib_deps}
${esp32_ota.lib_deps}

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/HeltecV3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/EnvironmentSensorManager.h>

View file

@ -1,11 +1,14 @@
#include "target.h"
#include <Arduino.h>
HeltecV3Board board;
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#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);
@ -21,7 +24,11 @@ DISPLAY_CLASS display;
bool radio_init() {
fallback_clock.begin();
rtc_clock.begin(Wire);
#if defined(P_LORA_SCLK)
return radio.std_init(&spi);
#else
return radio.std_init();
#endif
}
uint32_t radio_get_rng_seed() {
@ -42,4 +49,4 @@ void radio_set_tx_power(uint8_t dbm) {
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
}

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/HeltecV3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#ifdef DISPLAY_CLASS

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#ifdef DISPLAY_CLASS

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1276Wrapper.h>
#include <helpers/radiolib/CustomSX1276Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#ifdef DISPLAY_CLASS

View file

@ -69,4 +69,21 @@ build_src_filter = ${LilyGo_TBeam_SX1262.build_src_filter}
+<../examples/simple_repeater>
lib_deps =
${LilyGo_TBeam_SX1262.lib_deps}
${esp32_ota.lib_deps}
${esp32_ota.lib_deps}
[env:Tbeam_SX1262_room_server]
extends = LilyGo_TBeam_SX1262
build_flags =
${LilyGo_TBeam_SX1262.build_flags}
-D ADVERT_NAME='"Tbeam SX1262 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 = ${LilyGo_TBeam_SX1262.build_src_filter}
+<../examples/simple_room_server>
lib_deps =
${LilyGo_TBeam_SX1262.lib_deps}
${esp32_ota.lib_deps}

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/esp32/TBeamBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#ifdef DISPLAY_CLASS

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
//#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/esp32/TBeamBoard.h>
#include <helpers/CustomSX1276Wrapper.h>
#include <helpers/radiolib/CustomSX1276Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#ifdef DISPLAY_CLASS

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/esp32/TBeamBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/sensors/EnvironmentSensorManager.h>

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/LilyGoTLoraBoard.h>
#include <helpers/CustomSX1276Wrapper.h>
#include <helpers/radiolib/CustomSX1276Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/EnvironmentSensorManager.h>

View file

@ -5,13 +5,8 @@
MeshadventurerBoard 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
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
@ -30,40 +25,12 @@ MASensorManager sensors = MASensorManager(nmea);
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);
return radio.std_init(&spi);
#else
return radio.std_init();
#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() {

View file

@ -2,10 +2,10 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/MeshadventurerBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomSX1268Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1268Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>

View file

@ -0,0 +1,91 @@
#include <Arduino.h>
#include "MinewsemiME25LS01Board.h"
#include <Wire.h>
#include <bluefruit.h>
void MinewsemiME25LS01Board::begin() {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL;
btn_prev_state = HIGH;
pinMode(PIN_VBAT_READ, INPUT);
sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
#ifdef BUTTON_PIN
pinMode(BUTTON_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
#endif
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
#endif
Wire.begin();
#ifdef P_LORA_TX_LED
pinMode(P_LORA_TX_LED, OUTPUT);
digitalWrite(P_LORA_TX_LED, LOW);
#endif
delay(10); // give sx1262 some time to power up
}
static BLEDfu bledfu;
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) {
(void)conn_handle;
(void)reason;
MESH_DEBUG_PRINTLN("BLE client disconnected");
}
bool MinewsemiME25LS01Board::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()
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
Bluefruit.begin(1, 0);
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
Bluefruit.setTxPower(4);
// Set the BLE device name
Bluefruit.setName("Minewsemi_OTA");
Bluefruit.Periph.setConnectCallback(connect_callback);
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
// To be consistent OTA DFU should be added first if it exists
bledfu.begin();
// Set up and start advertising
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
Bluefruit.Advertising.addName();
/* Start Advertising
- Enable auto advertising if disconnected
- Interval: fast mode = 20 ms, slow mode = 152.5 ms
- Timeout for fast mode is 30 seconds
- Start(timeout) with timeout = 0 will advertise forever (until connected)
For recommended advertising interval
https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
strcpy(reply, "OK - started");
return true;
}

View file

@ -0,0 +1,88 @@
#pragma once
#include <MeshCore.h>
#include <Arduino.h>
// LoRa and SPI pins
#define P_LORA_DIO_1 (32 + 12) // P1.12
#define P_LORA_NSS (32 + 13) // P1.13
#define P_LORA_RESET (32 + 11) // P1.11
#define P_LORA_BUSY (32 + 10) // P1.10
#define P_LORA_SCLK (32 + 15) // P1.15
#define P_LORA_MISO (0 + 29) // P0.29
#define P_LORA_MOSI (0 + 2) // P0.2
#define LR11X0_DIO_AS_RF_SWITCH true
#define LR11X0_DIO3_TCXO_VOLTAGE 1.6
#define PIN_VBAT_READ BATTERY_PIN
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
class MinewsemiME25LS01Board : public mesh::MainBoard {
protected:
uint8_t startup_reason;
uint8_t btn_prev_state;
public:
void begin();
#define BATTERY_SAMPLES 8
uint16_t getBattMilliVolts() override {
analogReadResolution(12);
uint32_t raw = 0;
for (int i = 0; i < BATTERY_SAMPLES; i++) {
raw += analogRead(PIN_VBAT_READ);
}
raw = raw / BATTERY_SAMPLES;
return (ADC_MULTIPLIER * raw);
}
uint8_t getStartupReason() const override { return startup_reason; }
const char* getManufacturerName() const override {
return "Minewsemi";
}
void powerOff() override {
#ifdef HAS_GPS
digitalWrite(GPS_VRTC_EN, LOW);
digitalWrite(GPS_RESET, LOW);
digitalWrite(GPS_SLEEP_INT, LOW);
digitalWrite(GPS_RTC_INT, LOW);
pinMode(GPS_RESETB, OUTPUT);
digitalWrite(GPS_RESETB, LOW);
#endif
#ifdef BUZZER_EN
digitalWrite(BUZZER_EN, LOW);
#endif
#ifdef LED_PIN
digitalWrite(LED_PIN, LOW);
#endif
#ifdef BUTTON_PIN
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(BUTTON_PIN), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_HIGH);
#endif
sd_power_system_off();
}
#if defined(P_LORA_TX_LED)
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH);// turn TX LED on
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
}
#endif
void reboot() override {
NVIC_SystemReset();
}
bool startOTAUpdate(const char* id, char reply[]) override;
};

View file

@ -0,0 +1,24 @@
#pragma once
#include <helpers/ui/DisplayDriver.h>
class NullDisplayDriver : public DisplayDriver {
public:
NullDisplayDriver() : DisplayDriver(128, 64) { }
bool begin() { return false; } // not present
bool isOn() override { return false; }
void turnOn() override { }
void turnOff() override { }
void clear() override { }
void startFrame(Color bkg = DARK) override { }
void setTextSize(int sz) override { }
void setColor(Color c) override { }
void setCursor(int x, int y) override { }
void print(const char* str) override { }
void fillRect(int x, int y, int w, int h) override { }
void drawRect(int x, int y, int w, int h) override { }
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override { }
uint16_t getTextWidth(const char* str) override { return 0; }
void endFrame() { }
};

View file

@ -0,0 +1,164 @@
; ----------------- NRF52 me25ls01---------------------
[nrf52840_me25ls01]
extends = nrf52_base
platform_packages = framework-arduinoadafruitnrf52
build_flags = ${nrf52_base.build_flags}
-I src/helpers/nrf52
-I lib/nrf52/s140_nrf52_7.3.0_API/include
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
lib_ignore =
BluetoothOTA
lib5b4
lib_deps =
${nrf52_base.lib_deps}
rweather/Crypto @ ^0.4.0
[me25ls01]
extends = nrf52840_me25ls01
board = minewsemi_me25ls01
board_build.ldscript = boards/nrf52840_s140_v7.ld
build_flags = ${nrf52840_me25ls01.build_flags}
-I variants/minewsemi_me25ls01
-D me25ls01
-D PIN_USER_BTN=27
-D USER_BTN_PRESSED=HIGH
-D PIN_STATUS_LED=39
-D P_LORA_TX_LED=22
-D RADIO_CLASS=CustomLR1110
-D WRAPPER_CLASS=CustomLR1110Wrapper
-D LORA_TX_POWER=22
-D ENV_INCLUDE_GPS=0
-D ENV_INCLUDE_AHTX0=1
-D ENV_INCLUDE_BME280=1
-D ENV_INCLUDE_INA3221=1
-D ENV_INCLUDE_INA219=1
build_src_filter = ${nrf52840_me25ls01.build_src_filter}
+<helpers/*.cpp>
+<../variants/minewsemi_me25ls01>
+<helpers/sensors>
debug_tool = jlink
upload_protocol = nrfutil
lib_deps = ${nrf52840_me25ls01.lib_deps}
densaugeo/base64 @ ~1.4.0
stevemarple/MicroNMEA @ ^2.0.6
end2endzone/NonBlockingRTTTL@^1.3.0
adafruit/Adafruit SSD1306 @ ^2.5.13
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
[env:Minewsemi_me25ls01_companion_radio_ble]
extends = me25ls01
build_flags = ${me25ls01.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
-D MESH_PACKET_LOGGING=1
-D MESH_DEBUG=1
-D OFFLINE_QUEUE_SIZE=256
-D RX_BOOSTED_GAIN=true
-D RF_SWITCH_TABLE
-D DISPLAY_CLASS=NullDisplayDriver
;-D PIN_BUZZER=25
;-D PIN_BUZZER_EN=37
build_src_filter = ${me25ls01.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
lib_deps = ${me25ls01.lib_deps}
adafruit/RTClib @ ^2.1.3
[env:Minewsemi_me25ls01_repeater]
extends = me25ls01
build_flags = ${me25ls01.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
-D MESH_PACKET_LOGGING=1
-D MESH_DEBUG=1
-D OFFLINE_QUEUE_SIZE=256
-D RX_BOOSTED_GAIN=true
-D RF_SWITCH_TABLE
-D ADVERT_NAME='"ME25LS01 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=8
-D DISPLAY_CLASS=NullDisplayDriver
build_src_filter = ${me25ls01.build_src_filter}
+<../examples/simple_repeater>
lib_deps = ${me25ls01.lib_deps}
adafruit/RTClib @ ^2.1.3
[env:Minewsemi_me25ls01_room_server]
extends = me25ls01
build_flags = ${me25ls01.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
; -D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
-D OFFLINE_QUEUE_SIZE=256
-D RX_BOOSTED_GAIN=true
-D RF_SWITCH_TABLE
-D ADVERT_NAME='"ME25LS01 Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
-D MAX_NEIGHBOURS=8
-D DISPLAY_CLASS=NullDisplayDriver
build_src_filter = ${me25ls01.build_src_filter}
+<../examples/simple_room_server>
lib_deps = ${me25ls01.lib_deps}
adafruit/RTClib @ ^2.1.3
[env:Minewsemi_me25ls01_terminal_chat]
extends = me25ls01
build_flags = ${me25ls01.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
-D MESH_PACKET_LOGGING=1
-D MESH_DEBUG=1
-D OFFLINE_QUEUE_SIZE=256
-D RX_BOOSTED_GAIN=true
-D RF_SWITCH_TABLE
-D ADVERT_NAME='"ME25LS01 Chat"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
-D MAX_NEIGHBOURS=8
-D DISPLAY_CLASS=NullDisplayDriver
build_src_filter = ${me25ls01.build_src_filter}
+<../examples/simple_secure_chat/main.cpp>
lib_deps = ${me25ls01.lib_deps}
adafruit/RTClib @ ^2.1.3
[env:Minewsemi_me25ls01_companion_radio_usb]
extends = me25ls01
build_flags = ${me25ls01.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
;-D BLE_PIN_CODE=123456
; -D BLE_DEBUG_LOGGING=1
-D MESH_PACKET_LOGGING=1
-D MESH_DEBUG=1
-D OFFLINE_QUEUE_SIZE=256
-D RX_BOOSTED_GAIN=true
-D RF_SWITCH_TABLE
-D DISPLAY_CLASS=NullDisplayDriver
build_src_filter = ${me25ls01.build_src_filter}
+<helpers/nrf52/*.cpp>
+<../examples/companion_radio>
lib_deps = ${me25ls01.lib_deps}
adafruit/RTClib @ ^2.1.3

View file

@ -0,0 +1,98 @@
#include <Arduino.h>
#include "target.h"
MinewsemiME25LS01Board board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
#endif
#ifdef DISPLAY_CLASS
NullDisplayDriver display;
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
#ifdef RF_SWITCH_TABLE
static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_PINS] = {
RADIOLIB_LR11X0_DIO5,
RADIOLIB_LR11X0_DIO6,
RADIOLIB_LR11X0_DIO7,
RADIOLIB_LR11X0_DIO8,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{ LR11x0::MODE_STBY, {LOW, LOW, LOW, LOW }},
{ LR11x0::MODE_RX, {HIGH, LOW, LOW, HIGH }},
{ LR11x0::MODE_TX, {HIGH, HIGH, LOW, HIGH }},
{ LR11x0::MODE_TX_HP, {LOW, HIGH, LOW, HIGH }},
{ LR11x0::MODE_TX_HF, {LOW, LOW, LOW, LOW }},
{ LR11x0::MODE_GNSS, {LOW, LOW, HIGH, LOW }},
{ LR11x0::MODE_WIFI, {LOW, LOW, LOW, LOW }},
END_OF_MODE_TABLE,
};
#endif
bool radio_init() {
//rtc_clock.begin(Wire);
#ifdef LR11X0_DIO3_TCXO_VOLTAGE
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef RF_SWITCH_TABLE
radio.setRfSwitchTable(rfswitch_dios, rfswitch_table);
#endif
#ifdef RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(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
}

View file

@ -0,0 +1,29 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <MinewsemiME25LS01Board.h>
#include <helpers/radiolib/CustomLR1110Wrapper.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#ifdef DISPLAY_CLASS
#include "NullDisplayDriver.h"
#endif
#ifdef DISPLAY_CLASS
extern NullDisplayDriver display;
#endif
extern MinewsemiME25LS01Board board;
extern WRAPPER_CLASS radio_driver;
extern VolatileRTCClock rtc_clock;
extern EnvironmentSensorManager 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();

View file

@ -0,0 +1,70 @@
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
const uint32_t g_ADigitalPinMap[PINS_COUNT + 1] =
{
0, // P0.00
1, // P0.01
2, // P0.02
3, // P0.03
4, // P0.04
5, // P0.05
6, // P0.06
7, // P0.07
8, // P0.08
9, // P0.09
10, // P0.10
11, // P0.11
12, // P0.12
13, // P0.13, PIN_SERIAL1_TX
14, // P0.14, PIN_SERIAL1_RX
15, // P0.15, PIN_SERIAL2_RX
16, // P0.16, PIN_WIRE_SCL
17, // P0.17, PIN_SERIAL2_TX
18, // P0.18
19, // P0.19
20, // P0.20
21, // P0.21, PIN_WIRE_SDA
22, // P0.22
23, // P0.23
24, // P0.24,
25, // P0.25,
26, // P0.26,
27, // P0.27,
28, // P0.28
29, // P0.29,
30, // P0.30
31, // P0.31, BATTERY_PIN
32, // P1.00
33, // P1.01, LORA_DIO_1
34, // P1.02
35, // P1.03,
36, // P1.04
37, // P1.05, LR1110_EN
38, // P1.06,
39, // P1.07,
40, // P1.08, PIN_SPI_MISO
41, // P1.09, PIN_SPI_MOSI
42, // P1.10, LORA_RESET
43, // P1.11, GPS_EN
44, // P1.12, GPS_SLEEP_INT
45, // P1.13
46, // P1.14, GPS_RESETB
47, // P1.15, PIN_GPS_RESET
255, // NRFX_SPIM_PIN_NOT_USED
};
void initVariant()
{
pinMode(BATTERY_PIN, INPUT);
pinMode(PIN_BUTTON1, INPUT);
// pinMode(PIN_3V3_EN, OUTPUT);
// pinMode(PIN_3V3_ACC_EN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
pinMode(P_LORA_TX_LED, OUTPUT);
digitalWrite(LED_PIN, HIGH);
digitalWrite(P_LORA_TX_LED, LOW);
}

View file

@ -0,0 +1,94 @@
#pragma once
#include "WVariant.h"
// Low frequency clock source
#define USE_LFXO // 32.768 kHz crystal oscillator
#define VARIANT_MCK (64000000ul)
// #define USE_LFRC // 32.768 kHz RC oscillator
// Power
#define BATTERY_PIN (31)
#define BATTERY_IMMUTABLE
#define ADC_MULTIPLIER (2.0F)
#define ADC_RESOLUTION (14)
#define BATTERY_SENSE_RES (12)
// Number of pins
#define PINS_COUNT (48)
#define NUM_DIGITAL_PINS (48)
#define NUM_ANALOG_INPUTS (6)
#define NUM_ANALOG_OUTPUTS (0)
// UART pin definition
#define PIN_SERIAL1_RX (14) // P0.14
#define PIN_SERIAL1_TX (13) // P0.13
#define PIN_SERIAL2_RX (15) // P0.15
#define PIN_SERIAL2_TX (17) // P0.17
// I2C pin definition
#define HAS_WIRE (1)
#define WIRE_INTERFACES_COUNT (1)
#define PIN_WIRE_SDA (21) // P0.21
#define PIN_WIRE_SCL (16) // P0.16
#define I2C_NO_RESCAN
// SPI pin definition
#define SPI_INTERFACES_COUNT (1)
#define PIN_SPI_MISO (0 + 29) // P0.29
#define PIN_SPI_MOSI (0 + 2) // P0.2
#define PIN_SPI_SCK (32 + 15) // P1.15
#define PIN_SPI_NSS (32 + 13) // P1.13
// Builtin LEDs
#define LED_BUILTIN (-1)
#define LED_RED (32 + 5) // P1.5
#define LED_BLUE (32 + 7) // P1.7
#define LED_PIN LED_BLUE
#define P_LORA_TX_LED LED_RED
#define LED_STATE_ON HIGH
// Builtin buttons
#define PIN_BUTTON1 (0 + 27) // P0.6
#define BUTTON_PIN PIN_BUTTON1
// LR1110
#define LORA_DIO_1 (32 + 12) // P1.12
#define LORA_DIO_2 (32 + 10) // P1.10
#define LORA_NSS (PIN_SPI_NSS) // P1.13
#define LORA_RESET (32 + 11) // P1.11
#define LORA_BUSY (32 + 10) // P1.10
#define LORA_SCLK (PIN_SPI_SCK) // P1.15
#define LORA_MISO (PIN_SPI_MISO) // P0.29
#define LORA_MOSI (PIN_SPI_MOSI) // P0.2
#define LORA_CS PIN_SPI_NSS // P1.13
#define LR11X0_DIO_AS_RF_SWITCH true
#define LR11X0_DIO3_TCXO_VOLTAGE 1.6
#define LR1110_IRQ_PIN LORA_DIO_1
#define LR1110_NRESET_PIN LORA_RESET
#define LR1110_BUSY_PIN LORA_DIO_2
#define LR1110_SPI_NSS_PIN LORA_CS
#define LR1110_SPI_SCK_PIN LORA_SCLK
#define LR1110_SPI_MOSI_PIN LORA_MOSI
#define LR1110_SPI_MISO_PIN LORA_MISO
// GPS
#define HAS_GPS 0
#define GPS_RX_PIN PIN_SERIAL1_RX
#define GPS_TX_PIN PIN_SERIAL1_TX
#define GPS_EN (-1) // P1.11
#define GPS_RESET (-1) // P1.15
#define GPS_VRTC_EN (-1) // P0.8
#define GPS_SLEEP_INT (-1) // P1.12
#define GPS_RTC_INT (-1) // P0.15
#define GPS_RESETB (-1) // P1.14

View file

@ -3,8 +3,8 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include "nano-g2.h"
#include <helpers/RadioLibWrappers.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#ifdef DISPLAY_CLASS
@ -12,8 +12,7 @@
#endif
#include <helpers/sensors/LocationProvider.h>
class NanoG2UltraSensorManager : public SensorManager
{
class NanoG2UltraSensorManager : public SensorManager {
bool gps_active = false;
LocationProvider *_location;

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/rp2040/PicoWBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>

View file

@ -0,0 +1,83 @@
#include <Arduino.h>
#include "PromicroBoard.h"
#include <bluefruit.h>
#include <Wire.h>
static BLEDfu bledfu;
void PromicroBoard::begin() {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL;
btn_prev_state = HIGH;
pinMode(PIN_VBAT_READ, INPUT);
#ifdef BUTTON_PIN
pinMode(BUTTON_PIN, INPUT_PULLUP);
#endif
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
#endif
Wire.begin();
pinMode(SX126X_POWER_EN, OUTPUT);
digitalWrite(SX126X_POWER_EN, HIGH);
delay(10); // give sx1262 some time to power up
}
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) {
(void)conn_handle;
(void)reason;
MESH_DEBUG_PRINTLN("BLE client disconnected");
}
bool PromicroBoard::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()
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
Bluefruit.begin(1, 0);
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
Bluefruit.setTxPower(4);
// Set the BLE device name
Bluefruit.setName("ProMicro_OTA");
Bluefruit.Periph.setConnectCallback(connect_callback);
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
// To be consistent OTA DFU should be added first if it exists
bledfu.begin();
// Set up and start advertising
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
Bluefruit.Advertising.addName();
/* Start Advertising
- Enable auto advertising if disconnected
- Interval: fast mode = 20 ms, slow mode = 152.5 ms
- Timeout for fast mode is 30 seconds
- Start(timeout) with timeout = 0 will advertise forever (until connected)
For recommended advertising interval
https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
strcpy(reply, "OK - started");
return true;
}

View file

@ -0,0 +1,65 @@
#pragma once
#include <MeshCore.h>
#include <Arduino.h>
#define P_LORA_NSS 13 //P1.13 45
#define P_LORA_DIO_1 11 //P0.10 10
#define P_LORA_RESET 10 //P0.09 9
#define P_LORA_BUSY 16 //P0.29 29
#define P_LORA_MISO 15 //P0.02 2
#define P_LORA_SCLK 12 //P1.11 43
#define P_LORA_MOSI 14 //P1.15 47
#define SX126X_POWER_EN 21 //P0.13 13
#define SX126X_RXEN 2 //P0.17
#define SX126X_TXEN RADIOLIB_NC
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO3_TCXO_VOLTAGE (1.8f)
#define PIN_VBAT_READ 17
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
class PromicroBoard : public mesh::MainBoard {
protected:
uint8_t startup_reason;
uint8_t btn_prev_state;
public:
void begin();
uint8_t getStartupReason() const override { return startup_reason; }
#define BATTERY_SAMPLES 8
uint16_t getBattMilliVolts() override {
analogReadResolution(12);
uint32_t raw = 0;
for (int i = 0; i < BATTERY_SAMPLES; i++) {
raw += analogRead(PIN_VBAT_READ);
}
raw = raw / BATTERY_SAMPLES;
return (ADC_MULTIPLIER * raw);
}
const char* getManufacturerName() const override {
return "ProMicro DIY";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == LOW) ? 1 : -1;
}
#endif
return 0;
}
void reboot() override {
NVIC_SystemReset();
}
bool startOTAUpdate(const char* id, char reply[]) override;
};

View file

@ -23,7 +23,6 @@ build_flags = ${nrf52_base.build_flags}
-D ENV_INCLUDE_INA3221=1
-D ENV_INCLUDE_INA219=1
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/nrf52/PromicroBoard.cpp>
+<helpers/sensors>
+<../variants/promicro>
lib_deps= ${nrf52_base.lib_deps}
@ -117,93 +116,19 @@ lib_deps = ${Faketec.lib_deps}
adafruit/RTClib @ ^2.1.3
densaugeo/base64 @ ~1.4.0
[ProMicroLLCC68]
extends = nrf52_base
board = promicro_nrf52840
build_flags = ${nrf52_base.build_flags}
-I variants/promicro
-D PROMICROLLCC68
-D RADIO_CLASS=CustomLLCC68
-D WRAPPER_CLASS=CustomLLCC68Wrapper
-D LORA_TX_POWER=22
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
build_src_filter =
${nrf52_base.build_src_filter}
+<helpers/nrf52/PromicroBoard.cpp>
+<helpers/sensors>
+<../variants/promicro>
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
[env:ProMicroLLCC68_Repeater]
extends = ProMicroLLCC68
build_src_filter = ${ProMicroLLCC68.build_src_filter}
+<../examples/simple_repeater/main.cpp>
build_flags = ${ProMicroLLCC68.build_flags}
-D ADVERT_NAME='"ProMicroLLCC68 Repeater"'
[env:Faketec_sensor]
extends = Faketec
build_flags =
${Faketec.build_flags}
-D ADVERT_NAME='"Faketec Sensor"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=8
-D DISPLAY_CLASS=SSD1306Display
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
lib_deps = ${ProMicroLLCC68.lib_deps}
adafruit/RTClib @ ^2.1.3
[env:ProMicroLLCC68_room_server]
extends = ProMicroLLCC68
build_src_filter = ${ProMicroLLCC68.build_src_filter}
+<../examples/simple_room_server/main.cpp>
build_flags = ${ProMicroLLCC68.build_flags}
-D ADVERT_NAME='"ProMicroLLCC68 Room"'
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
lib_deps = ${ProMicroLLCC68.lib_deps}
adafruit/RTClib @ ^2.1.3
[env:ProMicroLLCC68_terminal_chat]
extends = ProMicroLLCC68
build_flags = ${ProMicroLLCC68.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${ProMicroLLCC68.build_src_filter}
+<../examples/simple_secure_chat/main.cpp>
lib_deps = ${ProMicroLLCC68.lib_deps}
densaugeo/base64 @ ~1.4.0
adafruit/RTClib @ ^2.1.3
[env:ProMicroLLCC68_companion_radio_usb]
extends = ProMicroLLCC68
build_flags = ${ProMicroLLCC68.build_flags}
-D MAX_CONTACTS=100
-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 = ${ProMicroLLCC68.build_src_filter}
+<../examples/companion_radio>
lib_deps = ${ProMicroLLCC68.lib_deps}
adafruit/RTClib @ ^2.1.3
densaugeo/base64 @ ~1.4.0
[env:ProMicroLLCC68_companion_radio_ble]
extends = ProMicroLLCC68
build_flags = ${ProMicroLLCC68.build_flags}
-D MAX_CONTACTS=100
-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 = ${ProMicroLLCC68.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio>
lib_deps = ${ProMicroLLCC68.lib_deps}
adafruit/RTClib @ ^2.1.3
densaugeo/base64 @ ~1.4.0
build_src_filter = ${Faketec.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_sensor>
lib_deps =
${Faketec.lib_deps}

View file

@ -2,10 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/nrf52/PromicroBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomLLCC68Wrapper.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <PromicroBoard.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
@ -27,4 +26,3 @@ 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();

View file

@ -21,6 +21,14 @@ build_flags = ${rak3x72.build_flags}
build_src_filter = ${rak3x72.build_src_filter}
+<../examples/simple_repeater/main.cpp>
[env:rak3x72-sensor]
extends = rak3x72
build_flags = ${rak3x72.build_flags}
-D ADVERT_NAME='"RAK3x72 Sensor"'
-D ADMIN_PASSWORD='"password"'
build_src_filter = ${rak3x72.build_src_filter}
+<../examples/simple_sensor>
[env:rak3x72_companion_radio_usb]
extends = rak3x72
build_flags = ${rak3x72.build_flags}

View file

@ -38,7 +38,7 @@ bool radio_init() {
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, 8, STM32WL_TCXO_VOLTAGE, 0);
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: ");

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/stm32/STM32Board.h>
#include <helpers/CustomSTM32WLxWrapper.h>
#include <helpers/radiolib/CustomSTM32WLxWrapper.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/SensorManager.h>
@ -22,7 +22,7 @@ public:
uint32_t raw = 0;
for (int i=0; i<8;i++) {
raw += analogRead(PIN_VBAT_READ);
}
}
return ((double)raw) * ADC_MULTIPLIER / 8 / 4096;
}
};

View file

@ -0,0 +1,90 @@
#include <Arduino.h>
#include "RAK4631Board.h"
#include <bluefruit.h>
#include <Wire.h>
static BLEDfu bledfu;
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) {
(void)conn_handle;
(void)reason;
MESH_DEBUG_PRINTLN("BLE client disconnected");
}
void RAK4631Board::begin() {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL;
pinMode(PIN_VBAT_READ, INPUT);
#ifdef PIN_USER_BTN
pinMode(PIN_USER_BTN, INPUT_PULLUP);
#endif
#ifdef PIN_USER_BTN_ANA
pinMode(PIN_USER_BTN_ANA, INPUT_PULLUP);
#endif
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
#endif
Wire.begin();
pinMode(SX126X_POWER_EN, OUTPUT);
digitalWrite(SX126X_POWER_EN, HIGH);
delay(10); // give sx1262 some time to power up
}
bool RAK4631Board::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()
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
Bluefruit.begin(1, 0);
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
Bluefruit.setTxPower(4);
// Set the BLE device name
Bluefruit.setName("RAK4631_OTA");
Bluefruit.Periph.setConnectCallback(connect_callback);
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
// To be consistent OTA DFU should be added first if it exists
bledfu.begin();
// Set up and start advertising
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
Bluefruit.Advertising.addName();
/* Start Advertising
- Enable auto advertising if disconnected
- Interval: fast mode = 20 ms, slow mode = 152.5 ms
- Timeout for fast mode is 30 seconds
- Start(timeout) with timeout = 0 will advertise forever (until connected)
For recommended advertising interval
https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
uint8_t mac_addr[6];
memset(mac_addr, 0, sizeof(mac_addr));
Bluefruit.getAddr(mac_addr);
sprintf(reply, "OK - mac: %02X:%02X:%02X:%02X:%02X:%02X",
mac_addr[5], mac_addr[4], mac_addr[3], mac_addr[2], mac_addr[1], mac_addr[0]);
return true;
}

View file

@ -0,0 +1,62 @@
#pragma once
#include <MeshCore.h>
#include <Arduino.h>
// LoRa radio module pins for RAK4631
#define P_LORA_DIO_1 47
#define P_LORA_NSS 42
#define P_LORA_RESET RADIOLIB_NC // 38
#define P_LORA_BUSY 46
#define P_LORA_SCLK 43
#define P_LORA_MISO 45
#define P_LORA_MOSI 44
#define SX126X_POWER_EN 37
//#define PIN_GPS_SDA 13 //GPS SDA pin (output option)
//#define PIN_GPS_SCL 14 //GPS SCL pin (output option)
//#define PIN_GPS_TX 16 //GPS TX pin
//#define PIN_GPS_RX 15 //GPS RX pin
#define PIN_GPS_1PPS 17 //GPS PPS pin
#define GPS_BAUD_RATE 9600
#define GPS_ADDRESS 0x42 //i2c address for GPS
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
// built-ins
#define PIN_VBAT_READ 5
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
class RAK4631Board : public mesh::MainBoard {
protected:
uint8_t startup_reason;
public:
void begin();
uint8_t getStartupReason() const override { return startup_reason; }
#define BATTERY_SAMPLES 8
uint16_t getBattMilliVolts() override {
analogReadResolution(12);
uint32_t raw = 0;
for (int i = 0; i < BATTERY_SAMPLES; i++) {
raw += analogRead(PIN_VBAT_READ);
}
raw = raw / BATTERY_SAMPLES;
return (ADC_MULTIPLIER * raw) / 4096;
}
const char* getManufacturerName() const override {
return "RAK 4631";
}
void reboot() override {
NVIC_SystemReset();
}
bool startOTAUpdate(const char* id, char reply[]) override;
};

View file

@ -1,26 +1,50 @@
[rak4631]
extends = nrf52840_base
extends = nrf52_base
platform = https://github.com/maxgerhardt/platform-nordicnrf52.git#rak
board = wiscore_rak4631
board_check = true
build_flags = ${nrf52840_base.build_flags}
build_flags = ${nrf52_base.build_flags}
-I variants/rak4631
-D RAK_4631
-D RAK_BOARD
-D PIN_BOARD_SCL=14
-D PIN_BOARD_SDA=13
-D PIN_GPS_TX=16
-D PIN_GPS_RX=15
-D PIN_GPS_EN=-1
-D PIN_OLED_RESET=-1
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
build_src_filter = ${nrf52840_base.build_src_filter}
+<helpers/nrf52/RAK4631Board.cpp>
-D ENV_INCLUDE_GPS=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
-D ENV_INCLUDE_INA260=1
-D ENV_INCLUDE_SHT4X=1
build_src_filter = ${nrf52_base.build_src_filter}
+<../variants/rak4631>
+<helpers/sensors>
lib_deps =
${nrf52840_base.lib_deps}
${nrf52_base.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13
stevemarple/MicroNMEA @ ^2.0.6
arduino-libraries/Arduino_LPS22HB@^1.0.2
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
adafruit/Adafruit INA260 Library @ ^1.5.3
sparkfun/SparkFun u-blox GNSS Arduino Library @ ^2.2.27
sensirion/Sensirion I2C SHT4x @ ^1.1.2
[env:RAK_4631_Repeater]
extends = rak4631
@ -38,30 +62,6 @@ build_src_filter = ${rak4631.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_repeater>
[env:RAK_4631_GPS_Repeater]
extends = rak4631
build_flags =
${rak4631.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D ADVERT_NAME='"RAK4631 GPS Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=8
-D FORCE_GPS_ALIVE=1
-D ENV_INCLUDE_GPS=1
-D ENV_INCLUDE_BME680=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${rak4631.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_repeater>
lib_deps =
${rak4631.lib_deps}
sparkfun/SparkFun u-blox GNSS Arduino Library @ ^2.2.27
https://github.com/boschsensortec/Bosch-BSEC2-Library
https://github.com/boschsensortec/Bosch-BME68x-Library
[env:RAK_4631_room_server]
extends = rak4631
build_flags =
@ -118,33 +118,6 @@ lib_deps =
${rak4631.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:RAK_4631_GPS_companion_radio_ble]
extends = rak4631
build_flags =
${rak4631.build_flags}
-D PIN_USER_BTN=9
-D PIN_USER_BTN_ANA=31
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456
-D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
-D ENV_INCLUDE_GPS=1
-D ENV_INCLUDE_BME680=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${rak4631.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio>
lib_deps =
${rak4631.lib_deps}
sparkfun/SparkFun u-blox GNSS Arduino Library @ ^2.2.27
https://github.com/boschsensortec/Bosch-BSEC2-Library
https://github.com/boschsensortec/Bosch-BME68x-Library
densaugeo/base64 @ ~1.4.0
[env:RAK_4631_terminal_chat]
extends = rak4631
build_flags =

View file

@ -1,10 +1,13 @@
#include <Arduino.h>
#include "target.h"
#include <helpers/ArduinoHelpers.h>
#include <helpers/sensors/MicroNMEALocationProvider.h>
RAK4631Board board;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
#endif
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
WRAPPER_CLASS radio_driver(radio, board);
@ -13,80 +16,11 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Wire);
RAK4631SensorManager sensors = RAK4631SensorManager(nmea);
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
RAK4631SensorManager sensors;
#endif
#if ENV_INCLUDE_BME680
#ifndef TELEM_BME680_ADDRESS
#define TELEM_BME680_ADDRESS 0x76 // BME680 environmental sensor I2C address
#endif
#include <bsec2.h>
static Bsec2 BME680;
static float rawPressure = 0;
static float rawTemperature = 0;
static float compTemperature = 0;
static float rawHumidity = 0;
static float compHumidity = 0;
static float readIAQ = 0;
static float readStaticIAQ = 0;
static float readCO2 = 0;
#endif
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
#endif
#ifdef MESH_DEBUG
uint32_t deviceOnline = 0x00;
static void scanDevices(TwoWire *w)
{
uint8_t err, addr;
int nDevices = 0;
uint32_t start = 0;
Serial.println("Scanning I2C for Devices");
for (addr = 1; addr < 127; addr++) {
start = millis();
w->beginTransmission(addr); delay(2);
err = w->endTransmission();
if (err == 0) {
nDevices++;
switch (addr) {
case 0x42:
Serial.println("\tFound RAK12500 GPS Sensor");
deviceOnline |= RAK12500_ONLINE;
break;
case 0x76:
Serial.println("\tFound RAK1906 Environment Sensor");
deviceOnline |= BME680_ONLINE;
break;
default:
Serial.print("\tI2C device found at address 0x");
if (addr < 16) {
Serial.print("0");
}
Serial.print(addr, HEX);
Serial.println(" !");
break;
}
} else if (err == 4) {
Serial.print("Unknow error at address 0x");
if (addr < 16) {
Serial.print("0");
}
Serial.println(addr, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
Serial.println("Scan for devices is complete.");
Serial.println("\n");
}
EnvironmentSensorManager sensors;
#endif
bool radio_init() {
@ -109,324 +43,6 @@ void radio_set_tx_power(uint8_t dbm) {
radio.setOutputPower(dbm);
}
#if ENV_INCLUDE_GPS
void RAK4631SensorManager::start_gps()
{
//function currently not used
gps_active = true;
pinMode(disStandbyPin, OUTPUT);
digitalWrite(disStandbyPin, 1);
MESH_DEBUG_PRINTLN("GPS should be on now");
}
void RAK4631SensorManager::stop_gps()
{
//function currently not used
gps_active = false;
pinMode(disStandbyPin, OUTPUT);
digitalWrite(disStandbyPin, 0);
MESH_DEBUG_PRINTLN("GPS should be off now");
}
void RAK4631SensorManager::sleep_gps() {
gps_active = false;
ublox_GNSS.powerSaveMode();
MESH_DEBUG_PRINTLN("GPS should be sleeping now");
}
void RAK4631SensorManager::wake_gps() {
gps_active = true;
ublox_GNSS.powerSaveMode(false);
MESH_DEBUG_PRINTLN("GPS should be waking now");
}
bool RAK4631SensorManager::gpsIsAwake(uint32_t ioPin){
int pinInitialState = 0;
//set initial waking state
pinMode(ioPin,OUTPUT);
digitalWrite(ioPin,0);
delay(1000);
digitalWrite(ioPin,1);
delay(1000);
if (ublox_GNSS.begin(Wire) == true){
MESH_DEBUG_PRINTLN("GPS init correctly and GPS is turned on");
ublox_GNSS.setI2COutput(COM_TYPE_NMEA);
ublox_GNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT);
disStandbyPin = ioPin;
gps_active = true;
gps_detected = true;
return true;
}
else
MESH_DEBUG_PRINTLN("GPS failed to init on this IO pin... try the next");
//digitalWrite(ioPin,pinInitialState); //reset the IO pin to initial state
return false;
}
#endif
#if ENV_INCLUDE_BME680
static void checkBMEStatus(Bsec2 bsec) {
if (bsec.status < BSEC_OK)
{
MESH_DEBUG_PRINTLN("BSEC error code : %f", float(bsec.status));
}
else if (bsec.status > BSEC_OK)
{
MESH_DEBUG_PRINTLN("BSEC warning code : %f", float(bsec.status));
}
if (bsec.sensor.status < BME68X_OK)
{
MESH_DEBUG_PRINTLN("BME68X error code : %f", bsec.sensor.status);
}
else if (bsec.sensor.status > BME68X_OK)
{
MESH_DEBUG_PRINTLN("BME68X warning code : %f", bsec.sensor.status);
}
}
static void newDataCallback(const bme68xData data, const bsecOutputs outputs, Bsec2 bsec) {
if (!outputs.nOutputs) {
MESH_DEBUG_PRINTLN("No new data to report out");
return;
}
MESH_DEBUG_PRINTLN("BSEC outputs:\n\tTime stamp = %f", (int) (outputs.output[0].time_stamp / INT64_C(1000000)));
for (uint8_t i = 0; i < outputs.nOutputs; i++) {
const bsecData output = outputs.output[i];
switch (output.sensor_id)
{
case BSEC_OUTPUT_IAQ:
readIAQ = output.signal;
MESH_DEBUG_PRINTLN("\tIAQ = %f", output.signal);
MESH_DEBUG_PRINTLN("\tIAQ accuracy = %f", output.accuracy);
break;
case BSEC_OUTPUT_RAW_TEMPERATURE:
rawTemperature = output.signal;
MESH_DEBUG_PRINTLN("\tTemperature = %f", output.signal);
break;
case BSEC_OUTPUT_RAW_PRESSURE:
rawPressure = output.signal;
MESH_DEBUG_PRINTLN("\tPressure = %f", output.signal);
break;
case BSEC_OUTPUT_RAW_HUMIDITY:
rawHumidity = output.signal;
MESH_DEBUG_PRINTLN("\tHumidity = %f", output.signal);
break;
case BSEC_OUTPUT_RAW_GAS:
MESH_DEBUG_PRINTLN("\tGas resistance = %f", output.signal);
break;
case BSEC_OUTPUT_STABILIZATION_STATUS:
MESH_DEBUG_PRINTLN("\tStabilization status = %f", output.signal);
break;
case BSEC_OUTPUT_RUN_IN_STATUS:
MESH_DEBUG_PRINTLN("\tRun in status = %f", output.signal);
break;
case BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE:
compTemperature = output.signal;
MESH_DEBUG_PRINTLN("\tCompensated temperature = %f", output.signal);
break;
case BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY:
compHumidity = output.signal;
MESH_DEBUG_PRINTLN("\tCompensated humidity = %f", output.signal);
break;
case BSEC_OUTPUT_STATIC_IAQ:
readStaticIAQ = output.signal;
MESH_DEBUG_PRINTLN("\tStatic IAQ = %f", output.signal);
break;
case BSEC_OUTPUT_CO2_EQUIVALENT:
readCO2 = output.signal;
MESH_DEBUG_PRINTLN("\tCO2 Equivalent = %f", output.signal);
break;
case BSEC_OUTPUT_BREATH_VOC_EQUIVALENT:
MESH_DEBUG_PRINTLN("\tbVOC equivalent = %f", output.signal);
break;
case BSEC_OUTPUT_GAS_PERCENTAGE:
MESH_DEBUG_PRINTLN("\tGas percentage = %f", output.signal);
break;
case BSEC_OUTPUT_COMPENSATED_GAS:
MESH_DEBUG_PRINTLN("\tCompensated gas = %f", output.signal);
break;
default:
break;
}
}
}
#endif
bool RAK4631SensorManager::begin() {
#ifdef MESH_DEBUG
scanDevices(&Wire);
#endif
#if ENV_INCLUDE_GPS
//search for the correct IO standby pin depending on socket used
if(gpsIsAwake(P_GPS_STANDBY_A)){
MESH_DEBUG_PRINTLN("GPS is on socket A");
}
else if(gpsIsAwake(P_GPS_STANDBY_C)){
MESH_DEBUG_PRINTLN("GPS is on socket C");
}
else if(gpsIsAwake(P_GPS_STANDBY_F)){
MESH_DEBUG_PRINTLN("GPS is on socket F");
}
else{
MESH_DEBUG_PRINTLN("Error: No GPS found on sockets A, C or F");
gps_active = false;
gps_detected = false;
return false;
}
#ifndef FORCE_GPS_ALIVE
//Now that GPS is found and set up, set to sleep for initial state
stop_gps();
#endif
#endif
#if ENV_INCLUDE_BME680
bsecSensor sensorList[5] = {
BSEC_OUTPUT_IAQ,
// BSEC_OUTPUT_RAW_TEMPERATURE,
BSEC_OUTPUT_RAW_PRESSURE,
// BSEC_OUTPUT_RAW_HUMIDITY,
// BSEC_OUTPUT_RAW_GAS,
// BSEC_OUTPUT_STABILIZATION_STATUS,
// BSEC_OUTPUT_RUN_IN_STATUS,
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE,
BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY,
BSEC_OUTPUT_STATIC_IAQ,
// BSEC_OUTPUT_CO2_EQUIVALENT,
// BSEC_OUTPUT_BREATH_VOC_EQUIVALENT,
// BSEC_OUTPUT_GAS_PERCENTAGE,
// BSEC_OUTPUT_COMPENSATED_GAS
};
if(!BME680.begin(TELEM_BME680_ADDRESS, Wire)){
checkBMEStatus(BME680);
bme680_present = false;
bme680_active = false;
return false;
}
MESH_DEBUG_PRINTLN("Found BME680 at address: %02X", TELEM_BME680_ADDRESS);
bme680_present = true;
bme680_active = true;
if (SAMPLING_RATE == BSEC_SAMPLE_RATE_ULP)
{
BME680.setTemperatureOffset(BSEC_SAMPLE_RATE_ULP);
}
else if (SAMPLING_RATE == BSEC_SAMPLE_RATE_LP)
{
BME680.setTemperatureOffset(TEMP_OFFSET_LP);
}
if (!BME680.updateSubscription(sensorList, ARRAY_LEN(sensorList), SAMPLING_RATE))
{
checkBMEStatus(BME680);
}
BME680.attachCallback(newDataCallback);
#endif
}
bool RAK4631SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
#ifdef ENV_INCLUDE_GPS
if (requester_permissions & TELEM_PERM_LOCATION && gps_active) { // does requester have permission?
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
}
#endif
if (requester_permissions & TELEM_PERM_ENVIRONMENT) {
#if ENV_INCLUDE_BME680
if (bme680_active) {
telemetry.addTemperature(TELEM_CHANNEL_SELF, compTemperature);
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF, compHumidity);
telemetry.addBarometricPressure(TELEM_CHANNEL_SELF, rawPressure);
telemetry.addTemperature(TELEM_CHANNEL_SELF+1, readIAQ);
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF+1, readStaticIAQ);
}
#endif
}
return true;
}
void RAK4631SensorManager::loop() {
static long next_update = 0;
#ifdef ENV_INCLUDE_GPS
_nmea->loop();
#endif
if (millis() > next_update) {
#ifdef ENV_INCLUDE_GPS
if(gps_active){
node_lat = (double)ublox_GNSS.getLatitude()/10000000.;
node_lon = (double)ublox_GNSS.getLongitude()/10000000.;
node_altitude = (double)ublox_GNSS.getAltitude()/1000.;
MESH_DEBUG_PRINT("lat %f lon %f alt %f\r\n", node_lat, node_lon, node_altitude);
}
#endif
#ifdef ENV_INCLUDE_BME680
if(bme680_active){
if (!BME680.run()){
checkBMEStatus(BME680);
}
}
#endif
next_update = millis() + 1000;
}
}
int RAK4631SensorManager::getNumSettings() const {
#if ENV_INCLUDE_GPS
return gps_detected ? 1 : 0; // only show GPS setting if GPS is detected
#else
return 0;
#endif
}
const char* RAK4631SensorManager::getSettingName(int i) const {
#if ENV_INCLUDE_GPS
return (gps_detected && i == 0) ? "gps" : NULL;
#else
return NULL;
#endif
}
const char* RAK4631SensorManager::getSettingValue(int i) const {
#if ENV_INCLUDE_GPS
if (gps_detected && i == 0) {
return gps_active ? "1" : "0";
}
#endif
return NULL;
}
bool RAK4631SensorManager::setSettingValue(const char* name, const char* value) {
#if ENV_INCLUDE_GPS
if (gps_detected && strcmp(name, "gps") == 0) {
if (strcmp(value, "0") == 0) {
stop_gps();
} else {
start_gps();
}
return true;
}
#endif
return false; // not supported
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity

View file

@ -2,84 +2,21 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/nrf52/RAK4631Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <RAK4631Board.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#if ENV_INCLUDE_GPS
#include <helpers/sensors/LocationProvider.h>
#include <SparkFun_u-blox_GNSS_Arduino_Library.h>
#endif
#include <helpers/sensors/EnvironmentSensorManager.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/SSD1306Display.h>
extern DISPLAY_CLASS display;
#endif
#define _BV(x) (1 << x)
class RAK4631SensorManager: public SensorManager {
#if ENV_INCLUDE_GPS
bool gps_active = false;
bool gps_detected = false;
LocationProvider * _nmea;
SFE_UBLOX_GNSS ublox_GNSS;
uint32_t disStandbyPin = 0;
void start_gps();
void stop_gps();
void sleep_gps();
void wake_gps();
bool gpsIsAwake(uint32_t ioPin);
#endif
#if ENV_INCLUDE_BME680
bool bme680_active = false;
bool bme680_present = false;
#define SAMPLING_RATE BSEC_SAMPLE_RATE_ULP
#endif
public:
#if ENV_INCLUDE_GPS
RAK4631SensorManager(LocationProvider &nmea): _nmea(&nmea) { }
#else
RAK4631SensorManager() { }
#endif
void loop() override;
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
int getNumSettings() const override;
const char* getSettingName(int i) const override;
const char* getSettingValue(int i) const override;
bool setSettingValue(const char* name, const char* value) override;
bool begin() override;
};
extern RAK4631Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern RAK4631SensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
#endif
enum {
POWERMANAGE_ONLINE = _BV(0),
DISPLAY_ONLINE = _BV(1),
RADIO_ONLINE = _BV(2),
GPS_ONLINE = _BV(3),
PSRAM_ONLINE = _BV(4),
SDCARD_ONLINE = _BV(5),
AXDL345_ONLINE = _BV(6),
BME280_ONLINE = _BV(7),
BMP280_ONLINE = _BV(8),
BME680_ONLINE = _BV(9),
QMC6310_ONLINE = _BV(10),
QMI8658_ONLINE = _BV(11),
PCF8563_ONLINE = _BV(12),
OSC32768_ONLINE = _BV(13),
RAK12500_ONLINE = _BV(14),
};
extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();

View file

@ -0,0 +1,81 @@
#include <Arduino.h>
#include "SenseCapSolarBoard.h"
#include <bluefruit.h>
#include <Wire.h>
static BLEDfu bledfu;
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) {
(void)conn_handle;
(void)reason;
MESH_DEBUG_PRINTLN("BLE client disconnected");
}
void SenseCapSolarBoard::begin() {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL;
#if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
#endif
Wire.begin();
#ifdef P_LORA_TX_LED
pinMode(P_LORA_TX_LED, OUTPUT);
digitalWrite(P_LORA_TX_LED, LOW);
#endif
delay(10); // give sx1262 some time to power up
}
bool SenseCapSolarBoard::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()
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
Bluefruit.begin(1, 0);
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
Bluefruit.setTxPower(4);
// Set the BLE device name
Bluefruit.setName("SENSECAP_SOLAR_OTA");
Bluefruit.Periph.setConnectCallback(connect_callback);
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
// To be consistent OTA DFU should be added first if it exists
bledfu.begin();
// Set up and start advertising
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
Bluefruit.Advertising.addName();
/* Start Advertising
- Enable auto advertising if disconnected
- Interval: fast mode = 20 ms, slow mode = 152.5 ms
- Timeout for fast mode is 30 seconds
- Start(timeout) with timeout = 0 will advertise forever (until connected)
For recommended advertising interval
https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
strcpy(reply, "OK - started");
return true;
}

View file

@ -0,0 +1,42 @@
#pragma once
#include <MeshCore.h>
#include <Arduino.h>
class SenseCapSolarBoard : public mesh::MainBoard {
protected:
uint8_t startup_reason;
public:
void begin();
uint8_t getStartupReason() const override { return startup_reason; }
#if defined(P_LORA_TX_LED)
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
}
#endif
uint16_t getBattMilliVolts() override {
digitalWrite(VBAT_ENABLE, LOW);
int adcvalue = 0;
analogReadResolution(12);
analogReference(AR_INTERNAL_3_0);
delay(10);
adcvalue = analogRead(BATTERY_PIN);
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
}
const char* getManufacturerName() const override {
return "Seeed SenseCap Solar";
}
void reboot() override {
NVIC_SystemReset();
}
bool startOTAUpdate(const char* id, char reply[]) override;
};

View file

@ -0,0 +1,106 @@
[SenseCap_Solar]
extends = nrf52_base
board = seeed_sensecap_solar
board_build.ldscript = boards/nrf52840_s140_v7.ld
build_flags = ${nrf52_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
-D NRF52_PLATFORM=1
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D P_LORA_TX_LED=12
-D P_LORA_DIO_1=1
-D P_LORA_RESET=2
-D P_LORA_BUSY=3
-D P_LORA_NSS=4
-D LORA_TX_POWER=22
-D SX126X_RXEN=5
-D SX126X_TXEN=RADIOLIB_NC
-D SX126X_DIO2_AS_RF_SWITCH=1
-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>
+<../variants/sensecap_solar>
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
[env:SenseCap_Solar_repeater]
extends = SenseCap_Solar
build_flags =
${SenseCap_Solar.build_flags}
-D ADVERT_NAME='"SenseCap_Solar 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 = ${SenseCap_Solar.build_src_filter}
+<../examples/simple_repeater/main.cpp>
[env:SenseCap_Solar_room_server]
extends = SenseCap_Solar
build_flags =
${SenseCap_Solar.build_flags}
-D ADVERT_NAME='"SenseCap_Solar Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${SenseCap_Solar.build_src_filter}
+<../examples/simple_room_server/main.cpp>
[env:SenseCap_Solar_companion_radio_ble]
extends = SenseCap_Solar
build_flags =
${SenseCap_Solar.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${SenseCap_Solar.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio>
lib_deps =
${SenseCap_Solar.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:SenseCap_Solar_companion_radio_usb]
extends = SenseCap_Solar
build_flags =
${SenseCap_Solar.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${SenseCap_Solar.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio>
lib_deps =
${SenseCap_Solar.lib_deps}
densaugeo/base64 @ ~1.4.0

View file

@ -0,0 +1,39 @@
#include <Arduino.h>
#include "target.h"
#include <helpers/ArduinoHelpers.h>
SenseCapSolarBoard board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
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);
}
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
}

View file

@ -0,0 +1,21 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <SenseCapSolarBoard.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
extern SenseCapSolarBoard board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager 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();

View file

@ -0,0 +1,71 @@
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include "nrf.h"
const uint32_t g_ADigitalPinMap[] = {
// D0 .. D10 - Peripheral control pins
2, // D0 P0.02 (A0) GNSS_WAKEUP
3, // D1 P0.03 (A1) LORA_DIO1
28, // D2 P0.28 (A2) LORA_RESET
29, // D3 P0.29 (A3) LORA_BUSY
4, // D4 P0.04 (A4/SDA) LORA_CS
5, // D5 P0.05 (A5/SCL) LORA_SW
43, // D6 P1.11 (UART_TX) GNSS_TX
44, // D7 P1.12 (UART_RX) GNSS_RX
45, // D8 P1.13 (SPI_SCK) LORA_SCK
46, // D9 P1.14 (SPI_MISO) LORA_MISO
47, // D10 P1.15 (SPI_MOSI) LORA_MOSI
// D11-D12 - LED outputs
15, // D11 P0.15 User LED
19, // D12 P0.19 Breathing LED
// D13 - User input
33, // D13 P1.01 User Button
// D14-D15 - Grove/NFC interface
9, // D14 P0.09 NFC1/GROVE_D1
10, // D15 P0.10 NFC2/GROVE_D0
// D16 - Power management
// 31, // D16 P0.31 VBAT_ADC (Battery voltage)
31, // D16 P0.31 VBAT_ADC (Battery voltage)
// D17 - GNSS control
35, // D17 P1.03 GNSS_RESET
37, // D18 P1.05 GNSS_ENABLE
14, // D19 P0.14 BAT_READ
39, // D20 P1.07 USER_BUTTON
//
21, // D21 P0.21 (QSPI_SCK)
25, // D22 P0.25 (QSPI_CSN)
20, // D23 P0.20 (QSPI_SIO_0 DI)
24, // D24 P0.24 (QSPI_SIO_1 DO)
22, // D25 P0.22 (QSPI_SIO_2 WP)
23, // D26 P0.23 (QSPI_SIO_3 HOLD)
};
void initVariant() {
pinMode(GPS_EN, OUTPUT);
digitalWrite(GPS_EN, LOW);
pinMode(BATTERY_PIN, INPUT);
pinMode(VBAT_ENABLE, OUTPUT);
digitalWrite(VBAT_ENABLE, LOW);
pinMode(PIN_QSPI_CS, OUTPUT);
digitalWrite(PIN_QSPI_CS, HIGH);
pinMode(LED_GREEN, OUTPUT);
digitalWrite(LED_GREEN, LOW);
pinMode(LED_BLUE, OUTPUT);
digitalWrite(LED_BLUE, LOW);
/* disable gps until we actually support it.
pinMode(GPS_EN, OUTPUT);
digitalWrite(GPS_EN, HIGH);
*/
}

View file

@ -0,0 +1,85 @@
#ifndef _SEEED_SENSECAP_SOLAR_H_
#define _SEEED_SENSECAP_SOLAR_H_
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#define PINS_COUNT (33)
#define NUM_DIGITAL_PINS (33)
#define NUM_ANALOG_INPUTS (8)
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED (12)
#define LED_PWR (PINS_COUNT)
#define LED_BUILTIN (PIN_LED)
#define LED_RED (PINS_COUNT)
#define LED_GREEN (12)
#define LED_BLUE (11)
#define LED_STATE_ON (1) // State when LED is litted
// Buttons
#define PIN_BUTTON1 (13)
#define PIN_BUTTON2 (20)
#define VBAT_ENABLE (19) // Output LOW to enable reading of the BAT voltage.
// Analog pins
#define BATTERY_PIN (16) // Read the BAT voltage.
#define AREF_VOLTAGE (3.0F)
#define ADC_MULTIPLIER (3.0F) // 1M, 512k divider bridge
#define ADC_RESOLUTION (12)
// Serial interfaces
#define PIN_SERIAL1_RX (7)
#define PIN_SERIAL1_TX (6)
// SPI Interfaces
#define SPI_INTERFACES_COUNT (1)
#define PIN_SPI_MISO (9)
#define PIN_SPI_MOSI (10)
#define PIN_SPI_SCK (8)
// Lora SPI is on SPI0
#define P_LORA_SCLK PIN_SPI_SCK
#define P_LORA_MISO PIN_SPI_MISO
#define P_LORA_MOSI PIN_SPI_MOSI
// Wire Interfaces
#define WIRE_INTERFACES_COUNT (1)
#define PIN_WIRE_SDA (14)
#define PIN_WIRE_SCL (15)
// GPS L76KB
#define GPS_BAUDRATE 9600
#define GPS_THREAD_INTERVAL 50
#define PIN_GPS_TX PIN_SERIAL1_RX
#define PIN_GPS_RX PIN_SERIAL1_TX
#define PIN_GPS_STANDBY (0)
#define GPS_EN (18)
// QSPI Pins
#define PIN_QSPI_SCK (21)
#define PIN_QSPI_CS (22)
#define PIN_QSPI_IO0 (23)
#define PIN_QSPI_IO1 (24)
#define PIN_QSPI_IO2 (25)
#define PIN_QSPI_IO3 (26)
#define EXTERNAL_FLASH_DEVICES P25Q16H
#define EXTERNAL_FLASH_USE_QSPI
#endif

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/StationG2Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>

View file

@ -61,7 +61,8 @@ bool radio_init() {
return false; // fail
}
radio.setCRC(1);
radio.setCRC(2);
radio.explicitHeader();
#ifdef RF_SWITCH_TABLE
radio.setRfSwitchTable(rfswitch_dios, rfswitch_table);

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include "T1000eBoard.h"
#include <helpers/CustomLR1110Wrapper.h>
#include <helpers/radiolib/CustomLR1110Wrapper.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/nrf52/T114Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/nrf52/TechoBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>

View file

@ -2,10 +2,10 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/XiaoC3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomSX1268Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1268Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/nrf52/ThinkNodeM1Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>

View file

@ -4,8 +4,8 @@
#include <RadioLib.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/SensorManager.h>
#include <helpers/rp2040/WaveshareBoard.h>

View file

@ -35,7 +35,7 @@ bool radio_init() {
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, 8, 1.7, 0);
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, 1.7, 0);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/stm32/STM32Board.h>
#include <helpers/CustomSTM32WLxWrapper.h>
#include <helpers/radiolib/CustomSTM32WLxWrapper.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/SensorManager.h>
@ -16,7 +16,7 @@ public:
// Just returns ADC value for now to test adc
uint16_t getBattMilliVolts() override {
uint32_t raw = analogRead(PIN_A3);
uint32_t raw = analogRead(PIN_A3);
return raw;
}
};

View file

@ -25,6 +25,15 @@ build_flags = ${lora_e5_mini.build_flags}
build_src_filter = ${lora_e5_mini.build_src_filter}
+<../examples/simple_repeater/main.cpp>
[env:wio-e5-mini-sensor]
extends = lora_e5_mini
build_flags = ${lora_e5_mini.build_flags}
-D LORA_TX_POWER=22
-D ADVERT_NAME='"wio-e5-mini Sensor"'
-D ADMIN_PASSWORD='"password"'
build_src_filter = ${lora_e5_mini.build_src_filter}
+<../examples/simple_sensor>
[env:wio-e5-mini_companion_radio_usb]
extends = lora_e5_mini
build_flags = ${lora_e5_mini.build_flags}

View file

@ -33,7 +33,7 @@ bool radio_init() {
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, 8, 1.7, 0);
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, 1.7, 0);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/stm32/STM32Board.h>
#include <helpers/CustomSTM32WLxWrapper.h>
#include <helpers/radiolib/CustomSTM32WLxWrapper.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/SensorManager.h>
#ifdef DISPLAY_CLASS
@ -37,14 +37,14 @@ public:
uint32_t raw = 0;
for (int i=0; i<8;i++) {
raw += analogRead(PIN_A3);
}
}
return ((double)raw) * 1.73 * 5 * 1000 / 8 / 4096;
}
};
class WIOE5SensorManager : public SensorManager {
BME280I2C bme;
bool has_bme = false;
bool has_bme = false;
public:
WIOE5SensorManager() {}

View file

@ -0,0 +1,96 @@
#include <Arduino.h>
#include "WioTrackerL1Board.h"
#include <bluefruit.h>
#include <Wire.h>
static BLEDfu bledfu;
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) {
(void)conn_handle;
(void)reason;
MESH_DEBUG_PRINTLN("BLE client disconnected");
}
void WioTrackerL1Board::begin() {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL;
btn_prev_state = HIGH;
pinMode(PIN_VBAT_READ, INPUT); // VBAT ADC input
// Set all button pins to INPUT_PULLUP
pinMode(PIN_BUTTON1, INPUT_PULLUP);
pinMode(PIN_BUTTON2, INPUT_PULLUP);
pinMode(PIN_BUTTON3, INPUT_PULLUP);
pinMode(PIN_BUTTON4, INPUT_PULLUP);
pinMode(PIN_BUTTON5, INPUT_PULLUP);
pinMode(PIN_BUTTON6, INPUT_PULLUP);
#if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
#endif
Wire.begin();
#ifdef P_LORA_TX_LED
pinMode(P_LORA_TX_LED, OUTPUT);
digitalWrite(P_LORA_TX_LED, LOW);
#endif
delay(10); // give sx1262 some time to power up
}
bool WioTrackerL1Board::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()
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
Bluefruit.begin(1, 0);
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
Bluefruit.setTxPower(4);
// Set the BLE device name
Bluefruit.setName("WioTrackerL1 OTA");
Bluefruit.Periph.setConnectCallback(connect_callback);
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
// To be consistent OTA DFU should be added first if it exists
bledfu.begin();
// Set up and start advertising
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
Bluefruit.Advertising.addName();
/* Start Advertising
- Enable auto advertising if disconnected
- Interval: fast mode = 20 ms, slow mode = 152.5 ms
- Timeout for fast mode is 30 seconds
- Start(timeout) with timeout = 0 will advertise forever (until connected)
For recommended advertising interval
https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
uint8_t mac_addr[6];
memset(mac_addr, 0, sizeof(mac_addr));
Bluefruit.getAddr(mac_addr);
sprintf(reply, "OK - mac: %02X:%02X:%02X:%02X:%02X:%02X",
mac_addr[5], mac_addr[4], mac_addr[3], mac_addr[2], mac_addr[1], mac_addr[0]);
return true;
}

View file

@ -0,0 +1,42 @@
#pragma once
#include <MeshCore.h>
#include <Arduino.h>
class WioTrackerL1Board : public mesh::MainBoard {
protected:
uint8_t startup_reason;
uint8_t btn_prev_state;
public:
void begin();
uint8_t getStartupReason() const override { return startup_reason; }
#if defined(P_LORA_TX_LED)
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
}
#endif
uint16_t getBattMilliVolts() override {
int adcvalue = 0;
analogReadResolution(12);
analogReference(AR_INTERNAL);
delay(10);
adcvalue = analogRead(PIN_VBAT_READ);
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
}
const char* getManufacturerName() const override {
return "Seeed Wio Tracker L1";
}
void reboot() override {
NVIC_SystemReset();
}
bool startOTAUpdate(const char* id, char reply[]) override;
};

View file

@ -0,0 +1,92 @@
[WioTrackerL1]
extends = nrf52_base
board = seeed-wio-tracker-l1
board_build.ldscript = boards/nrf52840_s140_v7.ld
build_flags = ${nrf52_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/wio-tracker-l1
-D WIO_TRACKER_L1
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D PIN_OLED_RESET=-1
; -D MESH_DEBUG=1
build_src_filter = ${nrf52_base.build_src_filter}
+<WioTrackerL1Board.cpp>
+<../variants/wio-tracker-l1>
+<helpers/ui/SH1106Display.cpp>
+<helpers/sensors>
lib_deps= ${nrf52_base.lib_deps}
adafruit/Adafruit SH110X @ ^2.1.13
adafruit/Adafruit GFX Library @ ^1.12.1
stevemarple/MicroNMEA @ ^2.0.6
[env:WioTrackerL1_Repeater]
extends = WioTrackerL1
build_src_filter = ${WioTrackerL1.build_src_filter}
+<../examples/simple_repeater>
build_flags =
${WioTrackerL1.build_flags}
-D ADVERT_NAME='"WioTrackerL1 Repeater"'
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=8
-D DISPLAY_CLASS=SH1106Display
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
lib_deps = ${WioTrackerL1.lib_deps}
adafruit/RTClib @ ^2.1.3
[env:WioTrackerL1_room_server]
extends = WioTrackerL1
build_src_filter = ${WioTrackerL1.build_src_filter}
+<../examples/simple_room_server>
build_flags = ${WioTrackerL1.build_flags}
-D ADVERT_NAME='"WioTrackerL1 Room"'
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
-D DISPLAY_CLASS=SH1106Display
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
lib_deps = ${WioTrackerL1.lib_deps}
adafruit/RTClib @ ^2.1.3
[env:WioTrackerL1_companion_radio_usb]
extends = WioTrackerL1
build_flags = ${WioTrackerL1.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D DISPLAY_CLASS=SH1106Display
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
build_src_filter = ${WioTrackerL1.build_src_filter}
+<../examples/companion_radio>
+<helpers/ui/SH1106Display.cpp>
+<helpers/ui/buzzer.cpp>
lib_deps = ${WioTrackerL1.lib_deps}
adafruit/RTClib @ ^2.1.3
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:WioTrackerL1_companion_radio_ble]
extends = WioTrackerL1
build_flags = ${WioTrackerL1.build_flags}
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456
-D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
-D DISPLAY_CLASS=SH1106Display
; -D MESH_PACKET_LOGGING=1
-D MESH_DEBUG=1
-D PIN_BUZZER=12
build_src_filter = ${WioTrackerL1.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio>
+<helpers/ui/buzzer.cpp>
lib_deps = ${WioTrackerL1.lib_deps}
adafruit/RTClib @ ^2.1.3
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0

View file

@ -0,0 +1,146 @@
#include <Arduino.h>
#include "target.h"
#include <helpers/ArduinoHelpers.h>
#include <helpers/sensors/MicroNMEALocationProvider.h>
WioTrackerL1Board board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
WioTrackerL1SensorManager sensors = WioTrackerL1SensorManager(nmea);
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
#endif
bool radio_init() {
rtc_clock.begin(Wire);
return radio.std_init(&SPI);
}
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);
}
void WioTrackerL1SensorManager::start_gps()
{
if (!gps_active)
{
MESH_DEBUG_PRINTLN("starting GPS");
digitalWrite(PIN_GPS_STANDBY, HIGH);
gps_active = true;
}
}
void WioTrackerL1SensorManager::stop_gps()
{
if (gps_active)
{
MESH_DEBUG_PRINTLN("stopping GPS");
digitalWrite(PIN_GPS_STANDBY, LOW);
gps_active = false;
}
}
bool WioTrackerL1SensorManager::begin()
{
Serial1.setPins(PIN_GPS_TX, PIN_GPS_RX); // be sure to tx into rx and rx into tx
Serial1.begin(GPS_BAUDRATE);
pinMode(PIN_GPS_STANDBY, OUTPUT);
digitalWrite(PIN_GPS_STANDBY, HIGH); // Wake GPS from standby
delay(500);
// We'll consider GPS detected if we see any data on Serial1
if (Serial1.available() > 0)
{
MESH_DEBUG_PRINTLN("GPS detected");
}
else
{
MESH_DEBUG_PRINTLN("No GPS detected");
}
digitalWrite(PIN_GPS_STANDBY, LOW); // Put GPS back into standby mode
return true;
}
bool WioTrackerL1SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP &telemetry)
{
if (requester_permissions & TELEM_PERM_LOCATION)
{ // does requester have permission?
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
}
return true;
}
void WioTrackerL1SensorManager::loop()
{
static long next_gps_update = 0;
_location->loop();
if (millis() > next_gps_update && gps_active) // don't bother if gps position is not enabled
{
if (_location->isValid())
{
node_lat = ((double)_location->getLatitude()) / 1000000.;
node_lon = ((double)_location->getLongitude()) / 1000000.;
node_altitude = ((double)_location->getAltitude()) / 1000.0;
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
}
next_gps_update = millis() + (1000 * 60); // after initial update, only check every minute TODO: should be configurable
}
}
int WioTrackerL1SensorManager::getNumSettings() const { return 1; } // just one supported: "gps" (power switch)
const char *WioTrackerL1SensorManager::getSettingName(int i) const
{
return i == 0 ? "gps" : NULL;
}
const char *WioTrackerL1SensorManager::getSettingValue(int i) const
{
if (i == 0)
{
return gps_active ? "1" : "0";
}
return NULL;
}
bool WioTrackerL1SensorManager::setSettingValue(const char *name, const char *value)
{
if (strcmp(name, "gps") == 0)
{
if (strcmp(value, "0") == 0)
{
stop_gps();
}
else
{
start_gps();
}
return true;
}
return false; // not supported
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}

View file

@ -0,0 +1,47 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <WioTrackerL1Board.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/ArduinoHelpers.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/SH1106Display.h>
#endif
#include <helpers/sensors/EnvironmentSensorManager.h>
class WioTrackerL1SensorManager : public SensorManager
{
bool gps_active = false;
LocationProvider *_location;
void start_gps();
void stop_gps();
public:
WioTrackerL1SensorManager(LocationProvider &location) : _location(&location) {}
bool begin() override;
bool querySensors(uint8_t requester_permissions, CayenneLPP &telemetry) override;
void loop() override;
int getNumSettings() const override;
const char *getSettingName(int i) const override;
const char *getSettingValue(int i) const override;
bool setSettingValue(const char *name, const char *value) override;
};
extern WioTrackerL1Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern WioTrackerL1SensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
#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();

View file

@ -0,0 +1,73 @@
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include "nrf.h"
const uint32_t g_ADigitalPinMap[] = {
// D0 .. D10 - Peripheral control pins
41, // D0 P1.09 GNSS_WAKEUP
7, // D1 P0.07 LORA_DIO1
39, // D2 P1,07 LORA_RESET
42, // D3 P1.10 LORA_BUSY
46, // D4 P1.14 (A4/SDA) LORA_CS
40, // D5 P1.08 (A5/SCL) LORA_SW
27, // D6 P0.27 (UART_TX) GNSS_TX
26, // D7 P0.26 (UART_RX) GNSS_RX
30, // D8 P0.30 (SPI_SCK) LORA_SCK
3, // D9 P0.3 (SPI_MISO) LORA_MISO
28, // D10 P0.28 (SPI_MOSI) LORA_MOSI
// D11-D12 - LED outputs
33, // D11 P1.1 User LED
// Buzzzer
32, // D12 P1.0 Buzzer
// D13 - User input
8, // D13 P0.08 User Button
// D14-D15 - OLED
6, // D14 P0.06 OLED SDA
5, // D15 P0.05 OLED SCL
// D16 - Battery voltage ADC input
31, // D16 P0.31 VBAT_ADC
// GROVE
43, // D17 P0.00 GROVE SDA
44, // D18 P0.01 GROVE SCL
// FLASH
21, // D19 P0.21 (QSPI_SCK)
25, // D20 P0.25 (QSPI_CSN)
20, // D21 P0.20 (QSPI_SIO_0 DI)
24, // D22 P0.24 (QSPI_SIO_1 DO)
22, // D23 P0.22 (QSPI_SIO_2 WP)
23, // D24 P0.23 (QSPI_SIO_3 HOLD)
// JOYSTICK
36, // D25 TB_UP
12, // D26 TB_DOWN
11, // D27 TB_LEFT
35, // D28 TB_RIGHT
37, // D29 TB_PRESS
// VBAT ENABLE
4, // D30 BAT_CTL
};
void initVariant() {
pinMode(PIN_QSPI_CS, OUTPUT);
digitalWrite(PIN_QSPI_CS, HIGH);
// VBAT_ENABLE
pinMode(VBAT_ENABLE, OUTPUT);
digitalWrite(VBAT_ENABLE, HIGH);
// set LED pin as output and set it low
pinMode(PIN_LED, OUTPUT);
digitalWrite(PIN_LED, LOW);
// set buzzer pin as output and set it low
pinMode(12, OUTPUT);
digitalWrite(12, LOW);
pinMode(12, OUTPUT);
}

View file

@ -0,0 +1,104 @@
#ifndef _SEEED_WIO_TRACKER_L1_H_
#define _SEEED_WIO_TRACKER_L1_H_
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#define PINS_COUNT (33)
#define NUM_DIGITAL_PINS (33)
#define NUM_ANALOG_INPUTS (8)
#define NUM_ANALOG_OUTPUTS (0)
// LEDs
#define PIN_LED (11)
#define LED_BLUE (-1) // Disable annoying flashing caused by Bluefruit
#define LED_BUILTIN PIN_LED
#define P_LORA_TX_LED PIN_LED
#define LED_STATE_ON 1
// Buttons
#define PIN_BUTTON1 (13) // Menu / User Button
#define PIN_BUTTON2 (25) // Joystick Up
#define PIN_BUTTON3 (26) // Joystick Down
#define PIN_BUTTON4 (27) // Joystick Left
#define PIN_BUTTON5 (28) // Joystick Right
#define PIN_BUTTON6 (29) // Joystick Press
#define PIN_USER_BTN PIN_BUTTON1
#define JOYSTICK_UP PIN_BUTTON2
#define JOYSTICK_DOWN PIN_BUTTON3
#define JOYSTICK_LEFT PIN_BUTTON4
#define JOYSTICK_RIGHT PIN_BUTTON5
#define JOYSTICK_PRESS PIN_BUTTON6
// Buzzer
// #define PIN_BUZZER (12) // Buzzer pin (defined per firmware type)
#define VBAT_ENABLE (30)
// Analog pins
#define PIN_VBAT_READ (16)
#define AREF_VOLTAGE (3.6F)
#define ADC_MULTIPLIER (2.0F)
#define ADC_RESOLUTION (12)
// Serial interfaces
#define PIN_SERIAL1_RX (7)
#define PIN_SERIAL1_TX (6)
// SPI Interfaces
#define SPI_INTERFACES_COUNT (1)
#define PIN_SPI_MISO (9)
#define PIN_SPI_MOSI (10)
#define PIN_SPI_SCK (8)
// Lora Pins
#define P_LORA_SCLK PIN_SPI_SCK
#define P_LORA_MISO PIN_SPI_MISO
#define P_LORA_MOSI PIN_SPI_MOSI
#define P_LORA_DIO_1 (1)
#define P_LORA_RESET (2)
#define P_LORA_BUSY (3)
#define P_LORA_NSS (4)
#define SX126X_RXEN (5)
#define SX126X_TXEN RADIOLIB_NC
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO3_TCXO_VOLTAGE (1.8f)
// Wire Interfaces
#define WIRE_INTERFACES_COUNT (2)
#define PIN_WIRE_SDA (14)
#define PIN_WIRE_SCL (15)
#define PIN_WIRE1_SDA (17)
#define PIN_WIRE1_SCL (18)
#define I2C_NO_RESCAN
#define DISPLAY_ADDRESS 0x3D // SH1106 OLED I2C address
// GPS L76KB
#define GPS_BAUDRATE 9600
#define PIN_GPS_TX PIN_SERIAL1_RX
#define PIN_GPS_RX PIN_SERIAL1_TX
#define PIN_GPS_STANDBY (0)
#define PIN_GPS_EN (18)
// QSPI Pins
#define PIN_QSPI_SCK (21)
#define PIN_QSPI_CS (22)
#define PIN_QSPI_IO0 (23)
#define PIN_QSPI_IO1 (24)
#define PIN_QSPI_IO2 (25)
#define PIN_QSPI_IO3 (26)
#define EXTERNAL_FLASH_DEVICES P25Q16H
#define EXTERNAL_FLASH_USE_QSPI
#endif

View file

@ -1,6 +1,27 @@
[Xiao_esp32_C3]
extends = esp32_base
board = seeed_xiao_esp32c3
build_flags =
${esp32_base.build_flags}
-I variants/xiao_c3
-D ESP32_CPU_FREQ=80
-D PIN_VBAT_READ=D0
-D P_LORA_DIO_1=D1
-D P_LORA_NSS=D4
-D P_LORA_RESET=D2
-D P_LORA_BUSY=D3
-D PIN_BOARD_SDA=D6
-D PIN_BOARD_SCL=D7
-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>
[Xiao_esp32_C3_custom]
extends = esp32_base
board = seeed_xiao_esp32c3
build_flags =
${esp32_base.build_flags}
-I variants/xiao_c3
@ -30,7 +51,7 @@ build_flags =
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D SX126X_RX_BOOSTED_GAIN=1
-D LORA_TX_POWER=22
-D ADVERT_NAME='"Xiao Repeater"'
-D ADVERT_NAME='"Xiao C3 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
@ -41,12 +62,78 @@ lib_deps =
${Xiao_esp32_C3.lib_deps}
${esp32_ota.lib_deps}
[env:Xiao_C3_Repeater_sx1268]
[env:Xiao_C3_companion_radio_ble]
extends = Xiao_esp32_C3
build_src_filter = ${Xiao_esp32_C3.build_src_filter}
+<../examples/simple_repeater/main.cpp>
+<../examples/companion_radio>
+<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=100
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
; -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
[env:Xiao_C3_companion_radio_usb]
extends = Xiao_esp32_C3
build_src_filter = ${Xiao_esp32_C3.build_src_filter}
+<../examples/companion_radio>
+<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=100
-D MAX_GROUP_CHANNELS=8
-D OFFLINE_QUEUE_SIZE=256
; -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
[env:Xiao_C3_Repeater_sx1262_custom]
extends = Xiao_esp32_C3_custom
build_src_filter = ${Xiao_esp32_C3_custom.build_src_filter}
+<../examples/simple_repeater/main.cpp>
build_flags =
${Xiao_esp32_C3_custom.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 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
lib_deps =
${Xiao_esp32_C3_custom.lib_deps}
${esp32_ota.lib_deps}
[env:Xiao_C3_Repeater_sx1268_custom]
extends = Xiao_esp32_C3_custom
build_src_filter = ${Xiao_esp32_C3_custom.build_src_filter}
+<../examples/simple_repeater/main.cpp>
build_flags =
${Xiao_esp32_C3_custom.build_flags}
-D RADIO_CLASS=CustomSX1268
-D WRAPPER_CLASS=CustomSX1268Wrapper
-D LORA_TX_POWER=22
@ -58,5 +145,5 @@ build_flags =
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
lib_deps =
${Xiao_esp32_C3.lib_deps}
${esp32_ota.lib_deps}
${Xiao_esp32_C3_custom.lib_deps}
${esp32_ota.lib_deps}

View file

@ -2,10 +2,10 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/XiaoC3Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/CustomSX1268Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1268Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <XiaoNrf52Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/sensors/EnvironmentSensorManager.h>

View file

@ -4,8 +4,8 @@
#include <RadioLib.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/SensorManager.h>
#include <helpers/rp2040/XiaoRP2040Board.h>

View file

@ -2,9 +2,9 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/ESP32Board.h>
#include <helpers/CustomSX1262Wrapper.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#ifdef DISPLAY_CLASS