mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
951d2dfdbb
109 changed files with 1891 additions and 947 deletions
|
|
@ -16,47 +16,15 @@ 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);
|
||||
|
||||
#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
|
||||
#if defined(P_LORA_SCLK)
|
||||
return radio.std_init(&spi);
|
||||
#else
|
||||
return radio.std_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t radio_get_rng_seed() {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ void HeltecE213Board::begin() {
|
|||
void HeltecE213Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
|
|
@ -44,8 +44,7 @@ void HeltecE213Board::begin() {
|
|||
}
|
||||
|
||||
void HeltecE213Board::powerOff() {
|
||||
// TODO: re-enable this when there is a definite wake-up source pin:
|
||||
// enterDeepSleep(0);
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t HeltecE213Board::getBattMilliVolts() {
|
||||
|
|
@ -66,4 +65,3 @@ void HeltecE213Board::begin() {
|
|||
const char* HeltecE213Board::getManufacturerName() const {
|
||||
return "Heltec E213";
|
||||
}
|
||||
|
||||
|
|
@ -5,15 +5,6 @@
|
|||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
// LoRa radio module pins for heltec_vision_master_e213
|
||||
#define P_LORA_DIO_1 14
|
||||
#define P_LORA_NSS 8
|
||||
#define P_LORA_RESET 12
|
||||
#define P_LORA_BUSY 13
|
||||
#define P_LORA_SCLK 9
|
||||
#define P_LORA_MISO 11
|
||||
#define P_LORA_MOSI 10
|
||||
|
||||
class HeltecE213Board : public ESP32Board {
|
||||
|
||||
public:
|
||||
|
|
@ -26,5 +17,4 @@ public:
|
|||
void powerOff() override;
|
||||
uint16_t getBattMilliVolts() override;
|
||||
const char* getManufacturerName() const override ;
|
||||
|
||||
};
|
||||
|
|
@ -1,14 +1,22 @@
|
|||
[Heltec_Vision_Master_E213_base]
|
||||
[Heltec_E213_base]
|
||||
extends = esp32_base
|
||||
board = heltec_vision_master_e213
|
||||
board = heltec_e213
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-I variants/heltec_vision_master_e213
|
||||
-D HELTEC_VISION_MASTER_E213
|
||||
-I variants/heltec_e213
|
||||
-D Vision_Master_E213
|
||||
-D ARDUINO_USB_CDC_ON_BOOT=1
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_DIO_1=14
|
||||
-D P_LORA_NSS=8
|
||||
-D P_LORA_RESET=12
|
||||
-D P_LORA_BUSY=13
|
||||
-D P_LORA_SCLK=9
|
||||
-D P_LORA_MISO=11
|
||||
-D P_LORA_MOSI=10
|
||||
-D P_LORA_TX_LED=45
|
||||
-D LORA_TX_POWER=22
|
||||
-D PIN_USER_BTN=0
|
||||
-D PIN_VEXT_EN=18
|
||||
-D PIN_VEXT_EN_ACTIVE=HIGH
|
||||
|
|
@ -26,17 +34,16 @@ build_flags =
|
|||
-D DISP_RST=3
|
||||
-D DISP_SCLK=4
|
||||
-D DISP_MOSI=6
|
||||
-D Vision_Master_E213
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/heltec_vision_master_e213>
|
||||
+<../variants/heltec_e213>
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
https://github.com/Quency-D/heltec-eink-modules/archive/563dd41fd850a1bc3039b8723da4f3a20fe1c800.zip
|
||||
|
||||
[env:Heltec_Vision_Master_E213_radio_ble]
|
||||
extends = Heltec_Vision_Master_E213_base
|
||||
[env:Heltec_E213_companion_radio_ble]
|
||||
extends = Heltec_E213_base
|
||||
build_flags =
|
||||
${Heltec_Vision_Master_E213_base.build_flags}
|
||||
${Heltec_E213_base.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
|
|
@ -44,43 +51,61 @@ build_flags =
|
|||
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${Heltec_Vision_Master_E213_base.build_src_filter}
|
||||
build_src_filter = ${Heltec_E213_base.build_src_filter}
|
||||
+<helpers/ui/E213Display.cpp>
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_Vision_Master_E213_base.lib_deps}
|
||||
${Heltec_E213_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_Vision_Master_E213_repeater]
|
||||
extends = Heltec_Vision_Master_E213_base
|
||||
[env:Heltec_E213_companion_radio_usb]
|
||||
extends = Heltec_E213_base
|
||||
build_flags =
|
||||
${Heltec_Vision_Master_E213_base.build_flags}
|
||||
${Heltec_E213_base.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D DISPLAY_CLASS=E213Display
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${Heltec_E213_base.build_src_filter}
|
||||
+<helpers/ui/E213Display.cpp>
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_E213_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_E213_repeater]
|
||||
extends = Heltec_E213_base
|
||||
build_flags =
|
||||
${Heltec_E213_base.build_flags}
|
||||
-D DISPLAY_CLASS=E213Display
|
||||
-D ADVERT_NAME='"Heltec E213 Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
build_src_filter = ${Heltec_Vision_Master_E213_base.build_src_filter}
|
||||
build_src_filter = ${Heltec_E213_base.build_src_filter}
|
||||
+<helpers/ui/E213Display.cpp>
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps =
|
||||
${Heltec_Vision_Master_E213_base.lib_deps}
|
||||
${Heltec_E213_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:Heltec_Vision_Master_E213_room_server]
|
||||
extends = Heltec_Vision_Master_E213_base
|
||||
[env:Heltec_E213_room_server]
|
||||
extends = Heltec_E213_base
|
||||
build_flags =
|
||||
${Heltec_Vision_Master_E213_base.build_flags}
|
||||
${Heltec_E213_base.build_flags}
|
||||
-D DISPLAY_CLASS=E213Display
|
||||
-D ADVERT_NAME='"Heltec E213 Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
build_src_filter = ${Heltec_Vision_Master_E213_base.build_src_filter}
|
||||
build_src_filter = ${Heltec_E213_base.build_src_filter}
|
||||
+<helpers/ui/E213Display.cpp>
|
||||
+<../examples/simple_room_server>
|
||||
lib_deps =
|
||||
${Heltec_Vision_Master_E213_base.lib_deps}
|
||||
${Heltec_E213_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
|
@ -23,7 +23,7 @@ void HeltecE290Board::begin() {
|
|||
void HeltecE290Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
|
|
@ -44,8 +44,7 @@ void HeltecE290Board::begin() {
|
|||
}
|
||||
|
||||
void HeltecE290Board::powerOff() {
|
||||
// TODO: re-enable this when there is a definite wake-up source pin:
|
||||
// enterDeepSleep(0);
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t HeltecE290Board::getBattMilliVolts() {
|
||||
|
|
@ -66,4 +65,3 @@ void HeltecE290Board::begin() {
|
|||
const char* HeltecE290Board::getManufacturerName() const {
|
||||
return "Heltec E290";
|
||||
}
|
||||
|
||||
|
|
@ -5,15 +5,6 @@
|
|||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
// LoRa radio module pins for heltec_vision_master_e290
|
||||
#define P_LORA_DIO_1 14
|
||||
#define P_LORA_NSS 8
|
||||
#define P_LORA_RESET 12
|
||||
#define P_LORA_BUSY 13
|
||||
#define P_LORA_SCLK 9
|
||||
#define P_LORA_MISO 11
|
||||
#define P_LORA_MOSI 10
|
||||
|
||||
class HeltecE290Board : public ESP32Board {
|
||||
|
||||
public:
|
||||
|
|
@ -1,13 +1,21 @@
|
|||
[Heltec_Vision_Master_E290_base]
|
||||
[Heltec_E290_base]
|
||||
extends = esp32_base
|
||||
board = heltec_vision_master_e290
|
||||
board = heltec_e290
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-I variants/heltec_vision_master_e290
|
||||
-D HELTEC_VISION_MASTER_E290
|
||||
-I variants/heltec_e290
|
||||
-D Vision_Master_E290
|
||||
-D ARDUINO_USB_CDC_ON_BOOT=1
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_DIO_1=14
|
||||
-D P_LORA_NSS=8
|
||||
-D P_LORA_RESET=12
|
||||
-D P_LORA_BUSY=13
|
||||
-D P_LORA_SCLK=9
|
||||
-D P_LORA_MISO=11
|
||||
-D P_LORA_MOSI=10
|
||||
-D P_LORA_TX_LED=45
|
||||
-D PIN_USER_BTN=0
|
||||
-D PIN_VEXT_EN=18
|
||||
|
|
@ -20,17 +28,16 @@ build_flags =
|
|||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D PIN_BOARD_SDA=39
|
||||
-D PIN_BOARD_SCL=38
|
||||
-D Vision_Master_E290
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/heltec_vision_master_e290>
|
||||
+<../variants/heltec_e290>
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
https://github.com/Quency-D/heltec-eink-modules/archive/563dd41fd850a1bc3039b8723da4f3a20fe1c800.zip
|
||||
|
||||
[env:Heltec_Vision_Master_E290_radio_ble]
|
||||
extends = Heltec_Vision_Master_E290_base
|
||||
[env:Heltec_E290_companion_radio_ble]
|
||||
extends = Heltec_E290_base
|
||||
build_flags =
|
||||
${Heltec_Vision_Master_E290_base.build_flags}
|
||||
${Heltec_E290_base.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
|
|
@ -38,43 +45,63 @@ build_flags =
|
|||
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${Heltec_Vision_Master_E290_base.build_src_filter}
|
||||
build_src_filter = ${Heltec_E290_base.build_src_filter}
|
||||
+<helpers/ui/E290Display.cpp>
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_Vision_Master_E290_base.lib_deps}
|
||||
${Heltec_E290_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_Vision_Master_E290_repeater]
|
||||
extends = Heltec_Vision_Master_E290_base
|
||||
[env:Heltec_E290_companion_radio_usb]
|
||||
extends = Heltec_E290_base
|
||||
build_flags =
|
||||
${Heltec_Vision_Master_E290_base.build_flags}
|
||||
${Heltec_E290_base.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D DISPLAY_CLASS=E290Display
|
||||
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${Heltec_E290_base.build_src_filter}
|
||||
+<helpers/ui/E290Display.cpp>
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_E290_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_E290_repeater]
|
||||
extends = Heltec_E290_base
|
||||
build_flags =
|
||||
${Heltec_E290_base.build_flags}
|
||||
-D DISPLAY_CLASS=E290Display
|
||||
-D ADVERT_NAME='"Heltec E290 Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
build_src_filter = ${Heltec_Vision_Master_E290_base.build_src_filter}
|
||||
build_src_filter = ${Heltec_E290_base.build_src_filter}
|
||||
+<helpers/ui/E290Display.cpp>
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps =
|
||||
${Heltec_Vision_Master_E290_base.lib_deps}
|
||||
${Heltec_E290_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:Heltec_Vision_Master_E290_room_server]
|
||||
extends = Heltec_Vision_Master_E290_base
|
||||
[env:Heltec_E290_room_server]
|
||||
extends = Heltec_E290_base
|
||||
build_flags =
|
||||
${Heltec_Vision_Master_E290_base.build_flags}
|
||||
${Heltec_E290_base.build_flags}
|
||||
-D DISPLAY_CLASS=E290Display
|
||||
-D ADVERT_NAME='"Heltec E290 Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
build_src_filter = ${Heltec_Vision_Master_E290_base.build_src_filter}
|
||||
build_src_filter = ${Heltec_E290_base.build_src_filter}
|
||||
+<helpers/ui/E290Display.cpp>
|
||||
+<../examples/simple_room_server>
|
||||
lib_deps =
|
||||
${Heltec_Vision_Master_E290_base.lib_deps}
|
||||
${Heltec_E290_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
|
@ -59,8 +59,8 @@ build_flags =
|
|||
extends = Heltec_mesh_solar
|
||||
build_flags =
|
||||
${Heltec_mesh_solar.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
|
|
@ -77,8 +77,8 @@ lib_deps =
|
|||
extends = Heltec_mesh_solar
|
||||
build_flags =
|
||||
${Heltec_mesh_solar.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
; -D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
|
|
|
|||
123
variants/heltec_t114/T114Board.cpp
Normal file
123
variants/heltec_t114/T114Board.cpp
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#include "T114Board.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <bluefruit.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 T114Board::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
|
||||
// Enable SoftDevice low-power mode
|
||||
sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
|
||||
|
||||
// Enable DC/DC converter for better efficiency (REG1 stage)
|
||||
NRF_POWER->DCDCEN = 1;
|
||||
|
||||
// Power down unused communication peripherals
|
||||
// UART1 - Not used on T114
|
||||
NRF_UARTE1->ENABLE = 0;
|
||||
|
||||
// SPIM2/SPIS2 - Not used (SPI is on SPIM0)
|
||||
NRF_SPIM2->ENABLE = 0;
|
||||
NRF_SPIS2->ENABLE = 0;
|
||||
|
||||
// TWI1 (I2C1) - Not used (I2C is on TWI0)
|
||||
NRF_TWIM1->ENABLE = 0;
|
||||
NRF_TWIS1->ENABLE = 0;
|
||||
|
||||
// PWM modules - Not used for standard T114 functions
|
||||
NRF_PWM1->ENABLE = 0;
|
||||
NRF_PWM2->ENABLE = 0;
|
||||
NRF_PWM3->ENABLE = 0;
|
||||
|
||||
// PDM (Digital Microphone Interface) - Not used
|
||||
NRF_PDM->ENABLE = 0;
|
||||
|
||||
// I2S - Not used
|
||||
NRF_I2S->ENABLE = 0;
|
||||
|
||||
// QSPI - Not used (no external flash)
|
||||
NRF_QSPI->ENABLE = 0;
|
||||
|
||||
// Disable unused analog peripherals
|
||||
// SAADC channels - only keep what's needed for battery monitoring
|
||||
NRF_SAADC->ENABLE = 0; // Re-enable only when needed for measurements
|
||||
|
||||
// COMP - Comparator not used
|
||||
NRF_COMP->ENABLE = 0;
|
||||
|
||||
#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, HIGH);
|
||||
#endif
|
||||
|
||||
pinMode(SX126X_POWER_EN, OUTPUT);
|
||||
digitalWrite(SX126X_POWER_EN, HIGH);
|
||||
delay(10); // give sx1262 some time to power up
|
||||
}
|
||||
|
||||
bool T114Board::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("T114_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;
|
||||
}
|
||||
60
variants/heltec_t114/T114Board.h
Normal file
60
variants/heltec_t114/T114Board.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#pragma once
|
||||
|
||||
#include <MeshCore.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
// built-ins
|
||||
#define PIN_VBAT_READ 4
|
||||
#define PIN_BAT_CTL 6
|
||||
#define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
|
||||
|
||||
class T114Board : 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, LOW); // turn TX LED on
|
||||
}
|
||||
void onAfterTransmit() override {
|
||||
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED off
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
int adcvalue = 0;
|
||||
|
||||
NRF_SAADC->ENABLE = 1;
|
||||
|
||||
analogReadResolution(12);
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
pinMode(PIN_BAT_CTL, OUTPUT); // battery adc can be read only ctrl pin 6 set to high
|
||||
digitalWrite(PIN_BAT_CTL, 1);
|
||||
|
||||
delay(10);
|
||||
adcvalue = analogRead(PIN_VBAT_READ);
|
||||
digitalWrite(6, 0);
|
||||
|
||||
NRF_SAADC->ENABLE = 0;
|
||||
|
||||
return (uint16_t)((float)adcvalue * MV_LSB * 4.9);
|
||||
}
|
||||
|
||||
const char* getManufacturerName() const override {
|
||||
return "Heltec T114";
|
||||
}
|
||||
|
||||
void reboot() override {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
sd_power_system_off();
|
||||
}
|
||||
|
||||
bool startOTAUpdate(const char* id, char reply[]) override;
|
||||
};
|
||||
196
variants/heltec_t114/platformio.ini
Normal file
196
variants/heltec_t114/platformio.ini
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
;
|
||||
; Heltec T114 without display
|
||||
;
|
||||
[Heltec_t114]
|
||||
extends = nrf52_base
|
||||
board = heltec_t114
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
-I variants/heltec_t114
|
||||
-I src/helpers/ui
|
||||
-D HELTEC_T114
|
||||
-D P_LORA_DIO_1=20
|
||||
-D P_LORA_NSS=24
|
||||
-D P_LORA_RESET=25
|
||||
-D P_LORA_BUSY=17
|
||||
-D P_LORA_SCLK=19
|
||||
-D P_LORA_MISO=23
|
||||
-D P_LORA_MOSI=22
|
||||
-D P_LORA_TX_LED=35
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_POWER_EN=37
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
-D ST7789
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<../variants/heltec_t114>
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
adafruit/Adafruit GFX Library @ ^1.12.1
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[env:Heltec_t114_without_display_repeater]
|
||||
extends = Heltec_t114
|
||||
build_src_filter = ${Heltec_t114.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
|
||||
build_flags =
|
||||
${Heltec_t114.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_T114 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
|
||||
|
||||
[env:Heltec_t114_without_display_room_server]
|
||||
extends = Heltec_t114
|
||||
build_src_filter = ${Heltec_t114.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
build_flags =
|
||||
${Heltec_t114.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_T114 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
|
||||
|
||||
[env:Heltec_t114_without_display_companion_radio_ble]
|
||||
extends = Heltec_t114
|
||||
build_flags =
|
||||
${Heltec_t114.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-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 = ${Heltec_t114.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_t114.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_t114_without_display_companion_radio_usb]
|
||||
extends = Heltec_t114
|
||||
build_flags =
|
||||
${Heltec_t114.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
; -D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Heltec_t114.build_src_filter}
|
||||
+<helpers/nrf52/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_t114.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
;
|
||||
; Heltec T114 with ST7789 display
|
||||
;
|
||||
[Heltec_t114_with_display]
|
||||
extends = Heltec_t114
|
||||
board = heltec_t114
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${Heltec_t114.build_flags}
|
||||
-D HELTEC_T114_WITH_DISPLAY
|
||||
-D DISPLAY_CLASS=ST7789Display
|
||||
build_src_filter = ${Heltec_t114.build_src_filter}
|
||||
+<helpers/ui/ST7789Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<helpers/ui/OLEDDisplay.cpp>
|
||||
+<helpers/ui/OLEDDisplayFonts.cpp>
|
||||
lib_deps =
|
||||
${Heltec_t114.lib_deps}
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[env:Heltec_t114_repeater]
|
||||
extends = Heltec_t114_with_display
|
||||
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
|
||||
build_flags =
|
||||
${Heltec_t114_with_display.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_T114 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
|
||||
|
||||
[env:Heltec_t114_room_server]
|
||||
extends = Heltec_t114_with_display
|
||||
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
build_flags =
|
||||
${Heltec_t114_with_display.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_T114 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
|
||||
|
||||
[env:Heltec_t114_companion_radio_ble]
|
||||
extends = Heltec_t114_with_display
|
||||
build_flags =
|
||||
${Heltec_t114_with_display.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-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 = ${Heltec_t114_with_display.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_t114_with_display.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_t114_companion_radio_usb]
|
||||
extends = Heltec_t114_with_display
|
||||
build_flags =
|
||||
${Heltec_t114_with_display.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-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
|
||||
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
|
||||
+<helpers/nrf52/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_t114_with_display.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
|
@ -3,14 +3,19 @@
|
|||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/nrf52/T114Board.h>
|
||||
#include <T114Board.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/ST7789Display.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#ifdef HELTEC_T114_WITH_DISPLAY
|
||||
#include <helpers/ui/ST7789Display.h>
|
||||
#else
|
||||
#include "helpers/ui/NullDisplayDriver.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class T114SensorManager : public SensorManager {
|
||||
|
|
@ -23,7 +23,7 @@ void HeltecT190Board::begin() {
|
|||
void HeltecT190Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
|
|
@ -44,8 +44,7 @@ void HeltecT190Board::begin() {
|
|||
}
|
||||
|
||||
void HeltecT190Board::powerOff() {
|
||||
// TODO: re-enable this when there is a definite wake-up source pin:
|
||||
// enterDeepSleep(0);
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t HeltecT190Board::getBattMilliVolts() {
|
||||
|
|
@ -66,4 +65,3 @@ void HeltecT190Board::begin() {
|
|||
const char* HeltecT190Board::getManufacturerName() const {
|
||||
return "Heltec T190";
|
||||
}
|
||||
|
||||
|
|
@ -5,15 +5,6 @@
|
|||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
// LoRa radio module pins for heltec_vision_master_e290
|
||||
#define P_LORA_DIO_1 14
|
||||
#define P_LORA_NSS 8
|
||||
#define P_LORA_RESET 12
|
||||
#define P_LORA_BUSY 13
|
||||
#define P_LORA_SCLK 9
|
||||
#define P_LORA_MISO 11
|
||||
#define P_LORA_MOSI 10
|
||||
|
||||
class HeltecT190Board : public ESP32Board {
|
||||
|
||||
public:
|
||||
|
|
@ -1,13 +1,20 @@
|
|||
[Heltec_Vision_Master_T190_base]
|
||||
[Heltec_T190_base]
|
||||
extends = esp32_base
|
||||
board = heltec_vision_master_t190
|
||||
board = heltec_t190
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-I variants/heltec_vision_master_t190
|
||||
-I variants/heltec_t190
|
||||
-I src/helpers/ui
|
||||
-D HELTEC_VISION_MASTER_T190
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D P_LORA_DIO_1=14
|
||||
-D P_LORA_NSS=8
|
||||
-D P_LORA_RESET=12
|
||||
-D P_LORA_BUSY=13
|
||||
-D P_LORA_SCLK=9
|
||||
-D P_LORA_MISO=11
|
||||
-D P_LORA_MOSI=10
|
||||
-D LORA_TX_POWER=22
|
||||
-D PIN_USER_BTN=0
|
||||
-D PIN_VEXT_EN=5
|
||||
|
|
@ -31,7 +38,7 @@ build_flags =
|
|||
-D ST7789
|
||||
-D DISPLAY_CLASS=ST7789Display
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/heltec_vision_master_t190>
|
||||
+<../variants/heltec_t190>
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/ui/ST7789Display.cpp>
|
||||
+<helpers/ui/OLEDDisplay.cpp>
|
||||
|
|
@ -40,48 +47,64 @@ lib_deps =
|
|||
${esp32_base.lib_deps}
|
||||
adafruit/Adafruit GFX Library @ ^1.12.1
|
||||
|
||||
[env:Heltec_Vision_Master_T190_radio_ble]
|
||||
extends = Heltec_Vision_Master_T190_base
|
||||
[env:Heltec_T190_companion_radio_ble]
|
||||
extends = Heltec_T190_base
|
||||
build_flags =
|
||||
${Heltec_Vision_Master_T190_base.build_flags}
|
||||
${Heltec_T190_base.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${Heltec_Vision_Master_T190_base.build_src_filter}
|
||||
build_src_filter = ${Heltec_T190_base.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_Vision_Master_T190_base.lib_deps}
|
||||
${Heltec_T190_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_Vision_Master_T190_repeater]
|
||||
extends = Heltec_Vision_Master_T190_base
|
||||
[env:Heltec_T190_companion_radio_usb]
|
||||
extends = Heltec_T190_base
|
||||
build_flags =
|
||||
${Heltec_Vision_Master_T190_base.build_flags}
|
||||
${Heltec_T190_base.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${Heltec_T190_base.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_T190_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_T190_repeater]
|
||||
extends = Heltec_T190_base
|
||||
build_flags =
|
||||
${Heltec_T190_base.build_flags}
|
||||
-D ADVERT_NAME='"Heltec T190 Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
build_src_filter = ${Heltec_Vision_Master_T190_base.build_src_filter}
|
||||
build_src_filter = ${Heltec_T190_base.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps =
|
||||
${Heltec_Vision_Master_T190_base.lib_deps}
|
||||
${Heltec_T190_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:Heltec_Vision_Master_T190_room_server]
|
||||
extends = Heltec_Vision_Master_T190_base
|
||||
[env:Heltec_T190_room_server]
|
||||
extends = Heltec_T190_base
|
||||
build_flags =
|
||||
${Heltec_Vision_Master_T190_base.build_flags}
|
||||
${Heltec_T190_base.build_flags}
|
||||
-D ADVERT_NAME='"Heltec T190 Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
build_src_filter = ${Heltec_Vision_Master_T190_base.build_src_filter}
|
||||
build_src_filter = ${Heltec_T190_base.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
lib_deps =
|
||||
${Heltec_Vision_Master_T190_base.lib_deps}
|
||||
${Heltec_T190_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
|
@ -64,7 +64,7 @@ lib_deps =
|
|||
extends = Heltec_lora32_v2
|
||||
build_flags =
|
||||
${Heltec_lora32_v2.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=170
|
||||
-D MAX_GROUP_CHANNELS=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
|
|
@ -80,7 +80,7 @@ build_flags =
|
|||
${Heltec_lora32_v2.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=170
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||
|
|
@ -100,7 +100,7 @@ build_flags =
|
|||
${Heltec_lora32_v2.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=170
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ build_flags =
|
|||
-D PIN_VEXT_EN=36
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=160
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D PIN_GPS_RX=47
|
||||
-D PIN_GPS_TX=48
|
||||
|
|
@ -87,7 +87,7 @@ extends = Heltec_lora32_v3
|
|||
build_flags =
|
||||
${Heltec_lora32_v3.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
|
|
@ -106,7 +106,7 @@ extends = Heltec_lora32_v3
|
|||
build_flags =
|
||||
${Heltec_lora32_v3.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=160
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
|
||||
|
|
@ -130,7 +130,7 @@ extends = Heltec_lora32_v3
|
|||
build_flags =
|
||||
${Heltec_lora32_v3.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D WIFI_DEBUG_LOGGING=1
|
||||
|
|
@ -207,7 +207,7 @@ lib_deps =
|
|||
extends = Heltec_lora32_v3
|
||||
build_flags =
|
||||
${Heltec_lora32_v3.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
|
|
|
|||
|
|
@ -106,8 +106,8 @@ build_src_filter = ${nrf52840_xiao.build_src_filter}
|
|||
extends = ikoka_stick_nrf_baseboard
|
||||
build_flags =
|
||||
${ikoka_stick_nrf_baseboard.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-I examples/companion_radio/ui-new
|
||||
|
|
@ -126,8 +126,8 @@ lib_deps =
|
|||
extends = ikoka_stick_nrf_baseboard
|
||||
build_flags =
|
||||
${ikoka_stick_nrf_baseboard.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-I examples/companion_radio/ui-new
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ build_src_filter = ${esp32_base.build_src_filter}
|
|||
+<../variants/lilygo_tbeam_SX1262>
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/esp32/TBeamBoard.cpp>
|
||||
+<helpers/sensors>
|
||||
+<helpers/sensors>
|
||||
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
|
|
@ -38,7 +38,7 @@ board_build.upload.maximum_ram_size=2000000
|
|||
build_flags =
|
||||
${LilyGo_TBeam_SX1262.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=160
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ build_src_filter = ${esp32_base.build_src_filter}
|
|||
+<../variants/lilygo_tbeam_SX1276>
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/esp32/TBeamBoard.cpp>
|
||||
+<helpers/sensors>
|
||||
+<helpers/sensors>
|
||||
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
|
|
@ -37,7 +37,7 @@ board_build.upload.maximum_ram_size=2000000
|
|||
build_flags =
|
||||
${LilyGo_TBeam_SX1276.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=160
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
|
|
|
|||
90
variants/lilygo_techo/TechoBoard.cpp
Normal file
90
variants/lilygo_techo/TechoBoard.cpp
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#include <Arduino.h>
|
||||
#include "TechoBoard.h"
|
||||
|
||||
#ifdef LILYGO_TECHO
|
||||
|
||||
#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 TechoBoard::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
|
||||
Wire.begin();
|
||||
|
||||
pinMode(SX126X_POWER_EN, OUTPUT);
|
||||
digitalWrite(SX126X_POWER_EN, HIGH);
|
||||
delay(10); // give sx1262 some time to power up
|
||||
}
|
||||
|
||||
uint16_t TechoBoard::getBattMilliVolts() {
|
||||
int adcvalue = 0;
|
||||
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReadResolution(12);
|
||||
delay(10);
|
||||
|
||||
// ADC range is 0..3000mV and resolution is 12-bit (0..4095)
|
||||
adcvalue = analogRead(PIN_VBAT_READ);
|
||||
// Convert the raw value to compensated mv, taking the resistor-
|
||||
// divider into account (providing the actual LIPO voltage)
|
||||
return (uint16_t)((float)adcvalue * REAL_VBAT_MV_PER_LSB);
|
||||
}
|
||||
|
||||
bool TechoBoard::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("TECHO_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;
|
||||
}
|
||||
#endif
|
||||
55
variants/lilygo_techo/TechoBoard.h
Normal file
55
variants/lilygo_techo/TechoBoard.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#pragma once
|
||||
|
||||
#include <MeshCore.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
// built-ins
|
||||
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
||||
|
||||
#define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT
|
||||
#define VBAT_DIVIDER_COMP (2.0F) // Compensation factor for the VBAT divider
|
||||
|
||||
#define PIN_VBAT_READ (4)
|
||||
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
||||
|
||||
class TechoBoard : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
|
||||
public:
|
||||
|
||||
void begin();
|
||||
uint16_t getBattMilliVolts() override;
|
||||
bool startOTAUpdate(const char* id, char reply[]) override;
|
||||
|
||||
uint8_t getStartupReason() const override {
|
||||
return startup_reason;
|
||||
}
|
||||
|
||||
const char* getManufacturerName() const override {
|
||||
return "LilyGo T-Echo";
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
#ifdef LED_RED
|
||||
digitalWrite(LED_RED, LOW);
|
||||
#endif
|
||||
#ifdef LED_GREEN
|
||||
digitalWrite(LED_GREEN, LOW);
|
||||
#endif
|
||||
#ifdef LED_BLUE
|
||||
digitalWrite(LED_BLUE, LOW);
|
||||
#endif
|
||||
#ifdef DISP_BACKLIGHT
|
||||
digitalWrite(DISP_BACKLIGHT, LOW);
|
||||
#endif
|
||||
#ifdef PIN_PWR_EN
|
||||
digitalWrite(PIN_PWR_EN, LOW);
|
||||
#endif
|
||||
sd_power_system_off();
|
||||
}
|
||||
|
||||
void reboot() override {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
};
|
||||
118
variants/lilygo_techo/platformio.ini
Normal file
118
variants/lilygo_techo/platformio.ini
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
[LilyGo_T-Echo]
|
||||
extends = nrf52_base
|
||||
board = t-echo
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I variants/lilygo_techo
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
-D LILYGO_TECHO
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_DIO_1=20
|
||||
-D P_LORA_NSS=24
|
||||
-D P_LORA_RESET=25
|
||||
-D P_LORA_BUSY=17
|
||||
-D P_LORA_SCLK=19
|
||||
-D P_LORA_MISO=23
|
||||
-D P_LORA_MOSI=22
|
||||
-D SX126X_POWER_EN=37
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D P_LORA_TX_LED=LED_GREEN
|
||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D ENV_INCLUDE_BME280=1
|
||||
-D GPS_BAUD_RATE=9600
|
||||
-D PIN_GPS_EN=GPS_EN
|
||||
-D TELEM_BME280_ADDRESS=0x77
|
||||
-D DISPLAY_CLASS=GxEPDDisplay
|
||||
-D BACKLIGHT_BTN=PIN_BUTTON2
|
||||
-D AUTO_OFF_MILLIS=0
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<TechoBoard.cpp>
|
||||
+<helpers/sensors/EnvironmentSensorManager.cpp>
|
||||
+<helpers/ui/GxEPDDisplay.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../variants/lilygo_techo>
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
adafruit/Adafruit BME280 Library @ ^2.3.0
|
||||
zinggjm/GxEPD2 @ 1.6.2
|
||||
bakercp/CRC32 @ ^2.0.0
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[env:LilyGo_T-Echo_repeater]
|
||||
extends = LilyGo_T-Echo
|
||||
build_src_filter = ${LilyGo_T-Echo.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
build_flags =
|
||||
${LilyGo_T-Echo.build_flags}
|
||||
-D ADVERT_NAME='"T-Echo 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
|
||||
|
||||
[env:LilyGo_T-Echo_room_server]
|
||||
extends = LilyGo_T-Echo
|
||||
build_src_filter = ${LilyGo_T-Echo.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
build_flags =
|
||||
${LilyGo_T-Echo.build_flags}
|
||||
-D ADVERT_NAME='"T-Echo Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
|
||||
[env:LilyGo_T-Echo_companion_radio_ble]
|
||||
extends = LilyGo_T-Echo
|
||||
build_flags =
|
||||
${LilyGo_T-Echo.build_flags}
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D QSPIFLASH=1
|
||||
-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||
build_src_filter = ${LilyGo_T-Echo.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${LilyGo_T-Echo.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:LilyGo_T-Echo_companion_radio_usb]
|
||||
extends = LilyGo_T-Echo
|
||||
build_flags =
|
||||
${LilyGo_T-Echo.build_flags}
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D UI_RECENT_LIST_SIZE=9
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||
build_src_filter = ${LilyGo_T-Echo.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${LilyGo_T-Echo.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
53
variants/lilygo_techo/target.cpp
Normal file
53
variants/lilygo_techo/target.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
|
||||
TechoBoard 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);
|
||||
|
||||
#ifdef ENV_INCLUDE_GPS
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||
#else
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager();
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
|
||||
#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);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
|
|
@ -3,37 +3,21 @@
|
|||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/nrf52/TechoBoard.h>
|
||||
#include <TechoBoard.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/GxEPDDisplay.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#endif
|
||||
|
||||
class TechoSensorManager : public SensorManager {
|
||||
bool gps_active = false;
|
||||
LocationProvider* _location;
|
||||
|
||||
void start_gps();
|
||||
void stop_gps();
|
||||
public:
|
||||
TechoSensorManager(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 TechoBoard board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern TechoSensorManager sensors;
|
||||
extern EnvironmentSensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
|
|
@ -16,49 +16,15 @@ 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);
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ lib_deps =
|
|||
extends = LilyGo_TLora_V2_1_1_6
|
||||
build_flags =
|
||||
${LilyGo_TLora_V2_1_1_6.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=160
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
|
|
@ -84,7 +84,7 @@ extends = LilyGo_TLora_V2_1_1_6
|
|||
build_flags =
|
||||
${LilyGo_TLora_V2_1_1_6.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=160
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||
|
|
@ -102,7 +102,7 @@ extends = LilyGo_TLora_V2_1_1_6
|
|||
build_flags =
|
||||
${LilyGo_TLora_V2_1_1_6.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_CONTACTS=160
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
|
|
@ -136,3 +136,23 @@ build_flags =
|
|||
lib_deps =
|
||||
${LilyGo_TLora_V2_1_1_6.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:LilyGo_TLora_V2_1_1_6_companion_radio_wifi]
|
||||
extends = LilyGo_TLora_V2_1_1_6
|
||||
build_flags =
|
||||
${LilyGo_TLora_V2_1_1_6.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=160
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D WIFI_SSID='"ssid"'
|
||||
-D WIFI_PWD='"password"'
|
||||
-D WIFI_DEBUG_LOGGING=1
|
||||
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${LilyGo_TLora_V2_1_1_6.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
|
|
|||
72
variants/mesh_pocket/MeshPocket.cpp
Normal file
72
variants/mesh_pocket/MeshPocket.cpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#include <Arduino.h>
|
||||
#include "MeshPocket.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 HeltecMeshPocket::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
Serial.begin(115200);
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
|
||||
pinMode(PIN_USER_BTN, INPUT);
|
||||
}
|
||||
|
||||
bool HeltecMeshPocket::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("MESH_POCKET_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;
|
||||
}
|
||||
45
variants/mesh_pocket/MeshPocket.h
Normal file
45
variants/mesh_pocket/MeshPocket.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <MeshCore.h>
|
||||
|
||||
// built-ins
|
||||
#define PIN_VBAT_READ 29
|
||||
#define PIN_BAT_CTL 34
|
||||
#define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
|
||||
|
||||
class HeltecMeshPocket : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
|
||||
public:
|
||||
void begin();
|
||||
uint8_t getStartupReason() const override { return startup_reason; }
|
||||
|
||||
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
int adcvalue = 0;
|
||||
analogReadResolution(12);
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
pinMode(PIN_BAT_CTL, OUTPUT); // battery adc can be read only ctrl pin set to high
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
digitalWrite(PIN_BAT_CTL, HIGH);
|
||||
|
||||
delay(10);
|
||||
adcvalue = analogRead(PIN_VBAT_READ);
|
||||
digitalWrite(PIN_BAT_CTL, LOW);
|
||||
|
||||
return (uint16_t)((float)adcvalue * MV_LSB * 4.9);
|
||||
}
|
||||
|
||||
const char* getManufacturerName() const override {
|
||||
return "Heltec MeshPocket";
|
||||
}
|
||||
|
||||
void reboot() override {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
bool startOTAUpdate(const char* id, char reply[]) override;
|
||||
};
|
||||
|
|
@ -1,53 +1,49 @@
|
|||
[nrf52840_t114]
|
||||
[Mesh_pocket]
|
||||
extends = nrf52_base
|
||||
board = heltec_mesh_pocket
|
||||
platform_packages = framework-arduinoadafruitnrf52
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
rweather/Crypto @ ^0.4.0
|
||||
|
||||
[Heltec_t114]
|
||||
extends = nrf52840_t114
|
||||
board = heltec_t114
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52840_t114.build_flags}
|
||||
-I variants/t114
|
||||
-I src/helpers/ui
|
||||
-DHELTEC_T114
|
||||
-D P_LORA_TX_LED=35
|
||||
-I variants/mesh_pocket
|
||||
-D HELTEC_MESH_POCKET
|
||||
-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 ST7789
|
||||
-D DISPLAY_CLASS=ST7789Display
|
||||
build_src_filter = ${nrf52840_t114.build_src_filter}
|
||||
-D EINK_DISPLAY_MODEL=GxEPD2_213_B74
|
||||
-D EINK_SCALE_X=1.953125f
|
||||
-D EINK_SCALE_Y=1.28f
|
||||
-D EINK_X_OFFSET=0
|
||||
-D EINK_Y_OFFSET=10
|
||||
-D DISPLAY_CLASS=GxEPDDisplay
|
||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/nrf52/T114Board.cpp>
|
||||
+<../variants/t114>
|
||||
+<helpers/ui/ST7789Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<helpers/ui/OLEDDisplay.cpp>
|
||||
+<helpers/ui/OLEDDisplayFonts.cpp>
|
||||
+<../variants/mesh_pocket>
|
||||
+<helpers/ui/GxEPDDisplay.cpp>
|
||||
lib_deps =
|
||||
${nrf52840_t114.lib_deps}
|
||||
${nrf52_base.lib_deps}
|
||||
adafruit/Adafruit EPD @ 4.6.1
|
||||
rweather/Crypto @ ^0.4.0
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
adafruit/Adafruit GFX Library @ ^1.12.1
|
||||
zinggjm/GxEPD2 @ 1.6.2
|
||||
bakercp/CRC32 @ ^2.0.0
|
||||
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[env:Heltec_t114_repeater]
|
||||
extends = Heltec_t114
|
||||
build_src_filter = ${Heltec_t114.build_src_filter}
|
||||
[env:Mesh_pocket_repeater]
|
||||
extends = Mesh_pocket
|
||||
build_src_filter = ${Mesh_pocket.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
|
||||
build_flags =
|
||||
${Heltec_t114.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_T114 Repeater"'
|
||||
${Mesh_pocket.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_Mesh_Pocket Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
|
|
@ -55,13 +51,13 @@ build_flags =
|
|||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
|
||||
[env:Heltec_t114_room_server]
|
||||
extends = Heltec_t114
|
||||
build_src_filter = ${Heltec_t114.build_src_filter}
|
||||
[env:Mesh_pocket_room_server]
|
||||
extends = Mesh_pocket
|
||||
build_src_filter = ${Mesh_pocket.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
build_flags =
|
||||
${Heltec_t114.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_T114 Room"'
|
||||
${Mesh_pocket.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_Mesh_Pocket Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
|
|
@ -69,41 +65,44 @@ build_flags =
|
|||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
|
||||
[env:Heltec_t114_companion_radio_ble]
|
||||
extends = Heltec_t114
|
||||
[env:Mesh_pocket_companion_radio_ble]
|
||||
extends = Mesh_pocket
|
||||
build_flags =
|
||||
${Heltec_t114.build_flags}
|
||||
${Mesh_pocket.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-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 AUTO_OFF_MILLIS=0
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Heltec_t114.build_src_filter}
|
||||
|
||||
build_src_filter = ${Mesh_pocket.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_t114.lib_deps}
|
||||
${Mesh_pocket.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_t114_companion_radio_usb]
|
||||
extends = Heltec_t114
|
||||
[env:Mesh_pocket_companion_radio_usb]
|
||||
extends = Mesh_pocket
|
||||
build_flags =
|
||||
${Heltec_t114.build_flags}
|
||||
${Mesh_pocket.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D AUTO_OFF_MILLIS=0
|
||||
; -D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Heltec_t114.build_src_filter}
|
||||
build_src_filter = ${Mesh_pocket.build_src_filter}
|
||||
+<helpers/nrf52/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_t114.lib_deps}
|
||||
${Mesh_pocket.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
44
variants/mesh_pocket/target.cpp
Normal file
44
variants/mesh_pocket/target.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
|
||||
HeltecMeshPocket 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);
|
||||
|
||||
SensorManager sensors = SensorManager();
|
||||
|
||||
VolatileRTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
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
|
||||
}
|
||||
33
variants/mesh_pocket/target.h
Normal file
33
variants/mesh_pocket/target.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#include "MeshPocket.h"
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/GxEPDDisplay.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#endif
|
||||
|
||||
extern HeltecMeshPocket board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
void radio_set_tx_power(uint8_t dbm);
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
|
||||
extern SensorManager sensors;
|
||||
|
||||
15
variants/mesh_pocket/variant.cpp
Normal file
15
variants/mesh_pocket/variant.cpp
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include "variant.h"
|
||||
#include "nrf.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
|
||||
const int MISO = PIN_SPI1_MISO;
|
||||
const int MOSI = PIN_SPI1_MOSI;
|
||||
const int SCK = PIN_SPI1_SCK;
|
||||
|
||||
const uint32_t g_ADigitalPinMap[] = {
|
||||
// P0 - pins 0 and 1 are hardwired for xtal and should never be enabled
|
||||
0xff, 0xff, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||
|
||||
// P1
|
||||
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47};
|
||||
124
variants/mesh_pocket/variant.h
Normal file
124
variants/mesh_pocket/variant.h
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* variant.h
|
||||
* MIT License
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Low frequency clock source
|
||||
|
||||
#define USE_LFXO // 32.768 kHz crystal oscillator
|
||||
#define VARIANT_MCK (64000000ul)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Power
|
||||
|
||||
#define BATTERY_PIN (0 + 29)
|
||||
#define PIN_BAT_CTRL (32 + 2)
|
||||
#define ADC_MULTIPLIER (4.90F)
|
||||
|
||||
#define ADC_RESOLUTION (14)
|
||||
#define BATTERY_SENSE_RES (12)
|
||||
|
||||
#define AREF_VOLTAGE (3.0)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Number of pins
|
||||
|
||||
#define PINS_COUNT (48)
|
||||
#define NUM_DIGITAL_PINS (48)
|
||||
#define NUM_ANALOG_INPUTS (1)
|
||||
#define NUM_ANALOG_OUTPUTS (0)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// UART pin definition
|
||||
|
||||
#define PIN_SERIAL1_RX (37)
|
||||
#define PIN_SERIAL1_TX (39)
|
||||
|
||||
#define PIN_SERIAL2_RX (7)
|
||||
#define PIN_SERIAL2_TX (8)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// I2C pin definition
|
||||
#define WIRE_INTERFACES_COUNT (1)
|
||||
|
||||
#define PIN_WIRE_SDA (32+15)
|
||||
#define PIN_WIRE_SCL (32+13)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Builtin LEDs
|
||||
|
||||
#define LED_BUILTIN (13)
|
||||
#define PIN_LED LED_BUILTIN
|
||||
#define LED_RED LED_BUILTIN
|
||||
#define LED_BLUE (-1) // No blue led, prevents Bluefruit flashing the green LED during advertising
|
||||
#define PIN_STATUS_LED LED_BUILTIN
|
||||
|
||||
#define LED_STATE_ON LOW
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Builtin buttons
|
||||
|
||||
#define PIN_BUTTON1 (32 + 10)
|
||||
#define BUTTON_PIN PIN_BUTTON1
|
||||
|
||||
// #define PIN_BUTTON2 (0 + 18)
|
||||
// #define BUTTON_PIN2 PIN_BUTTON2
|
||||
|
||||
#define PIN_USER_BTN BUTTON_PIN
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// SPI pin definition
|
||||
#define SPI_INTERFACES_COUNT (2)
|
||||
|
||||
// Lora
|
||||
#define USE_SX1262
|
||||
#define SX126X_CS (0 + 26)
|
||||
#define SX126X_DIO1 (0 + 16)
|
||||
#define SX126X_BUSY (0 + 15)
|
||||
#define SX126X_RESET (0 + 12)
|
||||
#define SX126X_DIO2_AS_RF_SWITCH true
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||
|
||||
#define PIN_SPI_MISO (32 + 9)
|
||||
#define PIN_SPI_MOSI (0 + 5)
|
||||
#define PIN_SPI_SCK (0 + 4)
|
||||
|
||||
#define LORA_CS SX126X_CS
|
||||
#define P_LORA_DIO_1 SX126X_DIO1
|
||||
#define P_LORA_NSS SX126X_CS
|
||||
#define P_LORA_RESET SX126X_RESET
|
||||
#define P_LORA_BUSY SX126X_BUSY
|
||||
#define P_LORA_SCLK PIN_SPI_SCK
|
||||
#define P_LORA_MISO PIN_SPI_MISO
|
||||
#define P_LORA_MOSI PIN_SPI_MOSI
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// EInk
|
||||
|
||||
#define PIN_DISPLAY_CS (24)
|
||||
#define PIN_DISPLAY_BUSY (32 + 6)
|
||||
#define PIN_DISPLAY_DC (31)
|
||||
#define PIN_DISPLAY_RST (32 + 4)
|
||||
|
||||
#define PIN_SPI1_MISO (-1)
|
||||
#define PIN_SPI1_MOSI (20)
|
||||
#define PIN_SPI1_SCK (22)
|
||||
|
||||
|
||||
// GxEPD2 needs that for a panel that is not even used !
|
||||
extern const int MISO;
|
||||
extern const int MOSI;
|
||||
extern const int SCK;
|
||||
|
||||
|
||||
#undef HAS_GPS
|
||||
#define HAS_GPS 0
|
||||
#define HAS_RTC 0
|
||||
|
|
@ -80,6 +80,8 @@ extends = Meshadventurer
|
|||
build_src_filter = ${Meshadventurer.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
build_flags =
|
||||
${Meshadventurer.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ lib_deps = ${nrf52840_me25ls01.lib_deps}
|
|||
extends = me25ls01
|
||||
build_flags = ${me25ls01.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D MESH_PACKET_LOGGING=1
|
||||
|
|
@ -149,8 +149,8 @@ lib_deps = ${me25ls01.lib_deps}
|
|||
extends = me25ls01
|
||||
build_flags = ${me25ls01.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
;-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D MESH_PACKET_LOGGING=1
|
||||
|
|
|
|||
|
|
@ -35,13 +35,14 @@ build_flags =
|
|||
${Nano_G2_Ultra.build_flags}
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=0
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=SH1106Display
|
||||
-D PIN_BUZZER=4
|
||||
-D QSPIFLASH=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Nano_G2_Ultra.build_src_filter}
|
||||
|
|
@ -65,8 +66,8 @@ build_flags =
|
|||
${Nano_G2_Ultra.build_flags}
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=SH1106Display
|
||||
-D PIN_BUZZER=4
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ public:
|
|||
void reboot() override {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
sd_power_system_off();
|
||||
}
|
||||
|
||||
bool startOTAUpdate(const char* id, char reply[]) override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ lib_deps = ${Faketec.lib_deps}
|
|||
extends = Faketec
|
||||
build_flags = ${Faketec.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||
|
|
@ -106,8 +106,8 @@ lib_deps = ${Faketec.lib_deps}
|
|||
extends = Faketec
|
||||
build_flags = ${Faketec.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ 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 MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||
build_src_filter = ${rak4631.build_src_filter}
|
||||
|
|
@ -89,8 +89,8 @@ 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 MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@ RAK4631Board board;
|
|||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true);
|
||||
|
||||
#if defined(PIN_USER_BTN_ANA)
|
||||
MomentaryButton analog_btn(PIN_USER_BTN_ANA, 1000, 20);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
extern DISPLAY_CLASS display;
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
extern MomentaryButton user_btn;
|
||||
#if defined(PIN_USER_BTN_ANA)
|
||||
extern MomentaryButton analog_btn;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern RAK4631Board board;
|
||||
|
|
|
|||
42
variants/rpi_picow/PicoWBoard.cpp
Normal file
42
variants/rpi_picow/PicoWBoard.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include <Arduino.h>
|
||||
#include "PicoWBoard.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 PicoWBoard::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
|
||||
|
||||
#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 PicoWBoard::startOTAUpdate(const char* id, char reply[]) {
|
||||
return false;
|
||||
}
|
||||
51
variants/rpi_picow/PicoWBoard.h
Normal file
51
variants/rpi_picow/PicoWBoard.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#pragma once
|
||||
|
||||
#include <MeshCore.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
// built-ins
|
||||
#define PIN_VBAT_READ 26
|
||||
#define ADC_MULTIPLIER (3.1 * 3.3 * 1000) // MT Uses 3.1
|
||||
#define PIN_LED_BUILTIN LED_BUILTIN
|
||||
|
||||
class PicoWBoard : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
|
||||
public:
|
||||
void begin();
|
||||
uint8_t getStartupReason() const override { return startup_reason; }
|
||||
|
||||
void onBeforeTransmit() override {
|
||||
digitalWrite(LED_BUILTIN, HIGH); // turn TX LED on
|
||||
}
|
||||
|
||||
void onAfterTransmit() override {
|
||||
digitalWrite(LED_BUILTIN, LOW); // turn TX LED off
|
||||
}
|
||||
|
||||
#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 "Pico W";
|
||||
}
|
||||
|
||||
void reboot() override {
|
||||
//NVIC_SystemReset();
|
||||
rp2040.reboot();
|
||||
}
|
||||
|
||||
bool startOTAUpdate(const char* id, char reply[]) override;
|
||||
};
|
||||
|
|
@ -1,26 +1,35 @@
|
|||
[picow]
|
||||
[rpi_picow]
|
||||
extends = rp2040_base
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
|
||||
board = rpipicow
|
||||
board_build.core = earlephilhower
|
||||
board_build.filesystem_size = 0.5m
|
||||
build_flags = ${rp2040_base.build_flags}
|
||||
-I variants/picow
|
||||
-I variants/rpi_picow
|
||||
; -D PICOW
|
||||
; -D HW_SPI1_DEVICE
|
||||
-D P_LORA_DIO_1=20
|
||||
-D P_LORA_NSS=3
|
||||
-D P_LORA_RESET=15
|
||||
-D P_LORA_BUSY=2
|
||||
-D P_LORA_SCLK=10
|
||||
-D P_LORA_MISO=12
|
||||
-D P_LORA_MOSI=11
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=130
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D LORA_TX_POWER=22
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
build_src_filter = ${rp2040_base.build_src_filter}
|
||||
+<helpers/rp2040/PicoWBoard.cpp>
|
||||
+<../variants/picow>
|
||||
+<PicoWBoard.cpp>
|
||||
+<../variants/rpi_picow>
|
||||
lib_deps = ${rp2040_base.lib_deps}
|
||||
|
||||
[env:PicoW_Repeater]
|
||||
extends = picow
|
||||
build_flags = ${picow.build_flags}
|
||||
extends = rpi_picow
|
||||
build_flags = ${rpi_picow.build_flags}
|
||||
-D ADVERT_NAME='"PicoW Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
|
|
@ -28,12 +37,12 @@ build_flags = ${picow.build_flags}
|
|||
-D MAX_NEIGHBOURS=8
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${picow.build_src_filter}
|
||||
build_src_filter = ${rpi_picow.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
|
||||
[env:PicoW_room_server]
|
||||
extends = picow
|
||||
build_flags = ${picow.build_flags}
|
||||
extends = rpi_picow
|
||||
build_flags = ${rpi_picow.build_flags}
|
||||
-D ADVERT_NAME='"Test Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
|
|
@ -41,38 +50,38 @@ build_flags = ${picow.build_flags}
|
|||
-D ROOM_PASSWORD='"hello"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${picow.build_src_filter}
|
||||
build_src_filter = ${rpi_picow.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
|
||||
[env:PicoW_companion_radio_usb]
|
||||
extends = picow
|
||||
build_flags = ${picow.build_flags}
|
||||
extends = rpi_picow
|
||||
build_flags = ${rpi_picow.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 = ${picow.build_src_filter}
|
||||
build_src_filter = ${rpi_picow.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
lib_deps = ${picow.lib_deps}
|
||||
lib_deps = ${rpi_picow.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
; [env:PicoW_companion_radio_ble]
|
||||
; extends = picow
|
||||
; build_flags = ${picow.build_flags}
|
||||
; extends = rpi_picow
|
||||
; build_flags = ${rpi_picow.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
|
||||
; build_src_filter = ${picow.build_src_filter}
|
||||
; build_src_filter = ${rpi_picow.build_src_filter}
|
||||
; +<../examples/companion_radio/*.cpp>
|
||||
; lib_deps = ${picow.lib_deps}
|
||||
; lib_deps = ${rpi_picow.lib_deps}
|
||||
; densaugeo/base64 @ ~1.4.0
|
||||
|
||||
; [env:PicoW_companion_radio_wifi]
|
||||
; extends = picow
|
||||
; build_flags = ${picow.build_flags}
|
||||
; extends = rpi_picow
|
||||
; build_flags = ${rpi_picow.build_flags}
|
||||
; -D MAX_CONTACTS=100
|
||||
; -D MAX_GROUP_CHANNELS=8
|
||||
; -D WIFI_DEBUG_LOGGING=1
|
||||
|
|
@ -80,19 +89,19 @@ lib_deps = ${picow.lib_deps}
|
|||
; -D WIFI_PWD='"mypwd"'
|
||||
; ; -D MESH_PACKET_LOGGING=1
|
||||
; ; -D MESH_DEBUG=1
|
||||
; build_src_filter = ${picow.build_src_filter}
|
||||
; build_src_filter = ${rpi_picow.build_src_filter}
|
||||
; +<../examples/companion_radio/*.cpp>
|
||||
; lib_deps = ${picow.lib_deps}
|
||||
; lib_deps = ${rpi_picow.lib_deps}
|
||||
; densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:PicoW_terminal_chat]
|
||||
extends = picow
|
||||
build_flags = ${picow.build_flags}
|
||||
extends = rpi_picow
|
||||
build_flags = ${rpi_picow.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${picow.build_src_filter}
|
||||
build_src_filter = ${rpi_picow.build_src_filter}
|
||||
+<../examples/simple_secure_chat/main.cpp>
|
||||
lib_deps = ${picow.lib_deps}
|
||||
lib_deps = ${rpi_picow.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/rp2040/PicoWBoard.h>
|
||||
#include <PicoWBoard.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
|
|
@ -76,8 +76,8 @@ build_src_filter = ${SenseCap_Solar.build_src_filter}
|
|||
extends = SenseCap_Solar
|
||||
build_flags =
|
||||
${SenseCap_Solar.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
|
|
@ -94,8 +94,8 @@ lib_deps =
|
|||
extends = SenseCap_Solar
|
||||
build_flags =
|
||||
${SenseCap_Solar.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${SenseCap_Solar.build_src_filter}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#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() { }
|
||||
};
|
||||
|
|
@ -3,22 +3,6 @@
|
|||
#include <MeshCore.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
// LoRa and SPI pins
|
||||
#define P_LORA_DIO_1 (32 + 1) // P1.1
|
||||
#define P_LORA_NSS (0 + 12) // P0.12
|
||||
#define P_LORA_RESET (32 + 10) // P1.10
|
||||
#define P_LORA_BUSY (0 + 7) // P0.7
|
||||
#define P_LORA_SCLK (0 + 11) // P0.11
|
||||
#define P_LORA_MISO (32 + 8) // P1.8
|
||||
#define P_LORA_MOSI (32 + 9) // P0.9
|
||||
|
||||
#define LR11X0_DIO_AS_RF_SWITCH true
|
||||
#define LR11X0_DIO3_TCXO_VOLTAGE 1.6
|
||||
|
||||
// built-ins
|
||||
//#define PIN_VBAT_READ 5
|
||||
//#define ADC_MULTIPLIER (3 * 1.73 * 1000)
|
||||
|
||||
class T1000eBoard : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
|
|
@ -75,11 +59,11 @@ public:
|
|||
pinMode(GPS_RESETB, OUTPUT);
|
||||
digitalWrite(GPS_RESETB, LOW);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BUZZER_EN
|
||||
digitalWrite(BUZZER_EN, LOW);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PIN_3V3_EN
|
||||
digitalWrite(PIN_3V3_EN, LOW);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,25 +1,13 @@
|
|||
; ----------------- NRF52 T1000e---------------------
|
||||
[nrf52840_t1000e]
|
||||
[t1000-e]
|
||||
extends = nrf52_base
|
||||
platform_packages = framework-arduinoadafruitnrf52
|
||||
board = tracker-t1000-e
|
||||
board_build.ldscript = boards/nrf52840_s140_v7.ld
|
||||
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
|
||||
lvgl
|
||||
lib5b4
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
rweather/Crypto @ ^0.4.0
|
||||
|
||||
[t1000-e]
|
||||
extends = nrf52840_t1000e
|
||||
board = tracker-t1000-e
|
||||
board_build.ldscript = boards/nrf52840_s140_v7.ld
|
||||
build_flags = ${nrf52840_t1000e.build_flags}
|
||||
-I variants/t1000-e
|
||||
-I src/helpers/ui
|
||||
-D T1000_E
|
||||
-D PIN_USER_BTN=6
|
||||
-D USER_BTN_PRESSED=HIGH
|
||||
|
|
@ -27,7 +15,18 @@ build_flags = ${nrf52840_t1000e.build_flags}
|
|||
-D RADIO_CLASS=CustomLR1110
|
||||
-D WRAPPER_CLASS=CustomLR1110Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
build_src_filter = ${nrf52840_t1000e.build_src_filter}
|
||||
-D RF_SWITCH_TABLE
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D P_LORA_BUSY=7 ; P0.7
|
||||
-D P_LORA_SCLK=11 ; P0.11
|
||||
-D P_LORA_NSS=12 ; P0.12
|
||||
-D P_LORA_DIO_1=33 ; P1.1
|
||||
-D P_LORA_MISO=40 ; P1.8
|
||||
-D P_LORA_MOSI=41 ; P0.9
|
||||
-D P_LORA_RESET=42 ; P1.10
|
||||
-D LR11X0_DIO_AS_RF_SWITCH=true
|
||||
-D LR11X0_DIO3_TCXO_VOLTAGE=1.6
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/nrf52/T1000eBoard.cpp>
|
||||
+<../variants/t1000-e>
|
||||
|
|
@ -45,8 +44,6 @@ build_flags = ${t1000-e.build_flags}
|
|||
-D MAX_NEIGHBOURS=8
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D RF_SWITCH_TABLE
|
||||
build_src_filter = ${t1000-e.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps = ${t1000-e.lib_deps}
|
||||
|
|
@ -63,7 +60,6 @@ build_flags = ${t1000-e.build_flags}
|
|||
-D ROOM_PASSWORD='"hello"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D RF_SWITCH_TABLE
|
||||
build_src_filter = ${t1000-e.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
|
|
@ -79,8 +75,6 @@ build_flags = ${t1000-e.build_flags}
|
|||
; -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 ; P1/5 - required for T1000-E
|
||||
|
|
@ -97,15 +91,13 @@ lib_deps = ${t1000-e.lib_deps}
|
|||
extends = t1000-e
|
||||
build_flags = ${t1000-e.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-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 ; P1/5 - required for T1000-E
|
||||
|
|
|
|||
|
|
@ -1,119 +1,99 @@
|
|||
#include <Arduino.h>
|
||||
#include "t1000e_sensors.h"
|
||||
|
||||
#define HEATER_NTC_BX 4250 // thermistor coefficient B
|
||||
#define HEATER_NTC_RP 8250 // ohm, series resistance to thermistor
|
||||
#define HEATER_NTC_KA 273.15 // 25 Celsius at Kelvin
|
||||
#define NTC_REF_VCC 3000 // mV, output voltage of LDO
|
||||
#define LIGHT_REF_VCC 2400 //
|
||||
|
||||
static unsigned int ntc_res2[136]={
|
||||
113347,107565,102116,96978,92132,87559,83242,79166,75316,71677,
|
||||
68237,64991,61919,59011,56258,53650,51178,48835,46613,44506,
|
||||
42506,40600,38791,37073,35442,33892,32420,31020,29689,28423,
|
||||
27219,26076,24988,23951,22963,22021,21123,20267,19450,18670,
|
||||
17926,17214,16534,15886,15266,14674,14108,13566,13049,12554,
|
||||
12081,11628,11195,10780,10382,10000,9634,9284,8947,8624,
|
||||
8315,8018,7734,7461,7199,6948,6707,6475,6253,6039,
|
||||
5834,5636,5445,5262,5086,4917,4754,4597,4446,4301,
|
||||
4161,4026,3896,3771,3651,3535,3423,3315,3211,3111,
|
||||
3014,2922,2834,2748,2666,2586,2509,2435,2364,2294,
|
||||
2228,2163,2100,2040,1981,1925,1870,1817,1766,1716,
|
||||
1669,1622,1578,1535,1493,1452,1413,1375,1338,1303,
|
||||
1268,1234,1202,1170,1139,1110,1081,1053,1026,999,
|
||||
974,949,925,902,880,858,
|
||||
};
|
||||
|
||||
static char ntc_temp2[136]=
|
||||
{
|
||||
-30,-29,-28,-27,-26,-25,-24,-23,-22,-21,
|
||||
-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,
|
||||
-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
|
||||
0,1,2,3,4,5,6,7,8,9,
|
||||
10,11,12,13,14,15,16,17,18,19,
|
||||
20,21,22,23,24,25,26,27,28,29,
|
||||
30,31,32,33,34,35,36,37,38,39,
|
||||
40,41,42,43,44,45,46,47,48,49,
|
||||
50,51,52,53,54,55,56,57,58,59,
|
||||
60,61,62,63,64,65,66,67,68,69,
|
||||
70,71,72,73,74,75,76,77,78,79,
|
||||
80,81,82,83,84,85,86,87,88,89,
|
||||
90,91,92,93,94,95,96,97,98,99,
|
||||
100,101,102,103,104,105,
|
||||
#include <Arduino.h>
|
||||
|
||||
#define HEATER_NTC_BX 4250 // thermistor coefficient B
|
||||
#define HEATER_NTC_RP 8250 // ohm, series resistance to thermistor
|
||||
#define HEATER_NTC_KA 273.15 // 25 Celsius at Kelvin
|
||||
#define NTC_REF_VCC 3000 // mV, output voltage of LDO
|
||||
#define LIGHT_REF_VCC 2400 //
|
||||
|
||||
static unsigned int ntc_res2[136] = {
|
||||
113347, 107565, 102116, 96978, 92132, 87559, 83242, 79166, 75316, 71677, 68237, 64991, 61919, 59011,
|
||||
56258, 53650, 51178, 48835, 46613, 44506, 42506, 40600, 38791, 37073, 35442, 33892, 32420, 31020,
|
||||
29689, 28423, 27219, 26076, 24988, 23951, 22963, 22021, 21123, 20267, 19450, 18670, 17926, 17214,
|
||||
16534, 15886, 15266, 14674, 14108, 13566, 13049, 12554, 12081, 11628, 11195, 10780, 10382, 10000,
|
||||
9634, 9284, 8947, 8624, 8315, 8018, 7734, 7461, 7199, 6948, 6707, 6475, 6253, 6039,
|
||||
5834, 5636, 5445, 5262, 5086, 4917, 4754, 4597, 4446, 4301, 4161, 4026, 3896, 3771,
|
||||
3651, 3535, 3423, 3315, 3211, 3111, 3014, 2922, 2834, 2748, 2666, 2586, 2509, 2435,
|
||||
2364, 2294, 2228, 2163, 2100, 2040, 1981, 1925, 1870, 1817, 1766, 1716, 1669, 1622,
|
||||
1578, 1535, 1493, 1452, 1413, 1375, 1338, 1303, 1268, 1234, 1202, 1170, 1139, 1110,
|
||||
1081, 1053, 1026, 999, 974, 949, 925, 902, 880, 858,
|
||||
};
|
||||
|
||||
static float get_heater_temperature( unsigned int vcc_volt, unsigned int ntc_volt )
|
||||
{
|
||||
int i = 0;
|
||||
float Vout = 0, Rt = 0, temp = 0;
|
||||
Vout = ntc_volt;
|
||||
|
||||
Rt = ( HEATER_NTC_RP * vcc_volt ) / Vout - HEATER_NTC_RP;
|
||||
|
||||
for( i = 0; i < 136; i++ )
|
||||
{
|
||||
if( Rt >= ntc_res2[i] )
|
||||
{
|
||||
break;
|
||||
}
|
||||
static char ntc_temp2[136] = {
|
||||
-30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11,
|
||||
-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
||||
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
|
||||
50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
|
||||
70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
|
||||
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
|
||||
};
|
||||
|
||||
static float get_heater_temperature(unsigned int vcc_volt, unsigned int ntc_volt) {
|
||||
int i = 0;
|
||||
float Vout = 0, Rt = 0, temp = 0;
|
||||
Vout = ntc_volt;
|
||||
|
||||
Rt = (HEATER_NTC_RP * vcc_volt) / Vout - HEATER_NTC_RP;
|
||||
|
||||
for (i = 0; i < 136; i++) {
|
||||
if (Rt >= ntc_res2[i]) {
|
||||
break;
|
||||
}
|
||||
|
||||
temp = ntc_temp2[i - 1] + 1 * ( ntc_res2[i - 1] - Rt ) / ( float )( ntc_res2[i - 1] - ntc_res2[i] );
|
||||
|
||||
temp = ( temp * 100 + 5 ) / 100;
|
||||
return temp;
|
||||
}
|
||||
|
||||
temp = ntc_temp2[i - 1] + 1 * (ntc_res2[i - 1] - Rt) / (float)(ntc_res2[i - 1] - ntc_res2[i]);
|
||||
|
||||
temp = (temp * 100 + 5) / 100;
|
||||
return temp;
|
||||
}
|
||||
|
||||
static int get_light_lv( unsigned int light_volt )
|
||||
{
|
||||
float Vout = 0, Vin = 0, Rt = 0, temp = 0;
|
||||
unsigned int light_level = 0;
|
||||
|
||||
if( light_volt <= 80 )
|
||||
{
|
||||
light_level = 0;
|
||||
return light_level;
|
||||
}
|
||||
else if( light_volt >= 2480 )
|
||||
{
|
||||
light_level = 100;
|
||||
return light_level;
|
||||
}
|
||||
Vout = light_volt;
|
||||
light_level = 100 * ( Vout - 80 ) / LIGHT_REF_VCC;
|
||||
|
||||
static int get_light_lv(unsigned int light_volt) {
|
||||
float Vout = 0, Vin = 0, Rt = 0, temp = 0;
|
||||
unsigned int light_level = 0;
|
||||
|
||||
if (light_volt <= 80) {
|
||||
light_level = 0;
|
||||
return light_level;
|
||||
}
|
||||
} else if (light_volt >= 2480) {
|
||||
light_level = 100;
|
||||
return light_level;
|
||||
}
|
||||
Vout = light_volt;
|
||||
light_level = 100 * (Vout - 80) / LIGHT_REF_VCC;
|
||||
|
||||
float t1000e_get_temperature( void )
|
||||
{
|
||||
unsigned int ntc_v, vcc_v;
|
||||
|
||||
digitalWrite(PIN_3V3_EN, HIGH);
|
||||
digitalWrite(SENSOR_EN, HIGH);
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReadResolution(12);
|
||||
delay(10);
|
||||
vcc_v = (1000.0*(analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE)) / 4096;
|
||||
ntc_v = (1000.0 * AREF_VOLTAGE * analogRead(TEMP_SENSOR)) / 4096;
|
||||
digitalWrite(PIN_3V3_EN, LOW);
|
||||
digitalWrite(SENSOR_EN, LOW);
|
||||
|
||||
return get_heater_temperature (vcc_v, ntc_v);
|
||||
return light_level;
|
||||
}
|
||||
|
||||
uint32_t t1000e_get_light( void )
|
||||
{
|
||||
int lux = 0;
|
||||
unsigned int lux_v = 0;
|
||||
|
||||
digitalWrite(SENSOR_EN, HIGH);
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReadResolution(12);
|
||||
delay(10);
|
||||
lux_v = 1000 * analogRead(LUX_SENSOR) * AREF_VOLTAGE / 4096;
|
||||
lux = get_light_lv( lux_v );
|
||||
digitalWrite(SENSOR_EN, LOW);
|
||||
|
||||
return lux;
|
||||
float t1000e_get_temperature(void) {
|
||||
unsigned int ntc_v, vcc_v;
|
||||
|
||||
digitalWrite(PIN_3V3_EN, HIGH);
|
||||
digitalWrite(SENSOR_EN, HIGH);
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReadResolution(12);
|
||||
delay(10);
|
||||
vcc_v = (1000.0 * (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE)) / 4096;
|
||||
ntc_v = (1000.0 * AREF_VOLTAGE * analogRead(TEMP_SENSOR)) / 4096;
|
||||
digitalWrite(PIN_3V3_EN, LOW);
|
||||
digitalWrite(SENSOR_EN, LOW);
|
||||
|
||||
return get_heater_temperature(vcc_v, ntc_v);
|
||||
}
|
||||
|
||||
uint32_t t1000e_get_light(void) {
|
||||
int lux = 0;
|
||||
unsigned int lux_v = 0;
|
||||
|
||||
digitalWrite(SENSOR_EN, HIGH);
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReadResolution(12);
|
||||
delay(10);
|
||||
lux_v = 1000 * analogRead(LUX_SENSOR) * AREF_VOLTAGE / 4096;
|
||||
lux = get_light_lv(lux_v);
|
||||
digitalWrite(SENSOR_EN, LOW);
|
||||
|
||||
return lux;
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
// Light and temperature sensors are on ADC ports
|
||||
// functions adapted from Seeed examples to get values
|
||||
// functions adapted from Seeed examples to get values
|
||||
// see : https://github.com/Seeed-Studio/Seeed-Tracker-T1000-E-for-LoRaWAN-dev-board
|
||||
|
||||
extern uint32_t t1000e_get_light();
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
[nrf52840_techo]
|
||||
extends = nrf52_base
|
||||
platform_packages = framework-arduinoadafruitnrf52
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
rweather/Crypto @ ^0.4.0
|
||||
|
||||
[LilyGo_Techo]
|
||||
extends = nrf52840_techo
|
||||
board = t-echo
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52840_techo.build_flags}
|
||||
-I variants/techo
|
||||
-DLILYGO_TECHO
|
||||
-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 P_LORA_TX_LED=LED_GREEN
|
||||
build_src_filter = ${nrf52840_techo.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/nrf52/TechoBoard.cpp>
|
||||
+<../variants/techo>
|
||||
lib_deps =
|
||||
${nrf52840_techo.lib_deps}
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[env:LilyGo_T-Echo_repeater]
|
||||
extends = LilyGo_Techo
|
||||
build_src_filter = ${LilyGo_Techo.build_src_filter} +<../examples/simple_repeater/main.cpp>
|
||||
build_flags =
|
||||
${LilyGo_Techo.build_flags}
|
||||
-D ADVERT_NAME='"T-Echo 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
|
||||
|
||||
[env:LilyGo_T-Echo_room_server]
|
||||
extends = LilyGo_Techo
|
||||
build_src_filter = ${LilyGo_Techo.build_src_filter} +<../examples/simple_room_server/main.cpp>
|
||||
build_flags =
|
||||
${LilyGo_Techo.build_flags}
|
||||
-D ADVERT_NAME='"T-Echo Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
|
||||
[env:LilyGo_T-Echo_companion_radio_ble]
|
||||
extends = LilyGo_Techo
|
||||
build_flags =
|
||||
${LilyGo_Techo.build_flags}
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D DISPLAY_CLASS=GxEPDDisplay
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D UI_RECENT_LIST_SIZE=9
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${LilyGo_Techo.build_src_filter}
|
||||
+<helpers/nrf52/TechoBoard.cpp>
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<helpers/ui/GxEPDDisplay.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${LilyGo_Techo.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
zinggjm/GxEPD2 @ 1.6.2
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
|
||||
TechoBoard 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);
|
||||
TechoSensorManager sensors = TechoSensorManager(nmea);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
|
||||
#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);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
void TechoSensorManager::start_gps() {
|
||||
if (!gps_active) {
|
||||
gps_active = true;
|
||||
_location->begin();
|
||||
}
|
||||
}
|
||||
|
||||
void TechoSensorManager::stop_gps() {
|
||||
if (gps_active) {
|
||||
gps_active = false;
|
||||
_location->stop();
|
||||
}
|
||||
}
|
||||
|
||||
bool TechoSensorManager::begin() {
|
||||
Serial1.begin(9600);
|
||||
|
||||
// GPS enabled pin
|
||||
pinMode(GPS_EN, OUTPUT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TechoSensorManager::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 TechoSensorManager::loop() {
|
||||
static long next_gps_update = 0;
|
||||
|
||||
if (!gps_active) {
|
||||
return; // GPS is not active, skip further processing
|
||||
}
|
||||
|
||||
_location->loop();
|
||||
|
||||
if (millis() > next_gps_update) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
int TechoSensorManager::getNumSettings() const {
|
||||
return 1; // always show GPS setting
|
||||
}
|
||||
|
||||
const char* TechoSensorManager::getSettingName(int i) const {
|
||||
return (i == 0) ? "gps" : NULL;
|
||||
}
|
||||
|
||||
const char* TechoSensorManager::getSettingValue(int i) const {
|
||||
if (i == 0) {
|
||||
return gps_active ? "1" : "0";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool TechoSensorManager::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
|
||||
}
|
||||
95
variants/thinknode_m1/ThinkNodeM1Board.cpp
Normal file
95
variants/thinknode_m1/ThinkNodeM1Board.cpp
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
#include "ThinkNodeM1Board.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#ifdef THINKNODE_M1
|
||||
|
||||
#include <Wire.h>
|
||||
#include <bluefruit.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 ThinkNodeM1Board::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
|
||||
Wire.begin();
|
||||
|
||||
#ifdef P_LORA_TX_LED
|
||||
pinMode(P_LORA_TX_LED, OUTPUT);
|
||||
digitalWrite(P_LORA_TX_LED, LOW);
|
||||
#endif
|
||||
|
||||
pinMode(SX126X_POWER_EN, OUTPUT);
|
||||
digitalWrite(SX126X_POWER_EN, HIGH);
|
||||
delay(10); // give sx1262 some time to power up
|
||||
}
|
||||
|
||||
uint16_t ThinkNodeM1Board::getBattMilliVolts() {
|
||||
int adcvalue = 0;
|
||||
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReadResolution(12);
|
||||
delay(10);
|
||||
|
||||
// ADC range is 0..3000mV and resolution is 12-bit (0..4095)
|
||||
adcvalue = analogRead(PIN_VBAT_READ);
|
||||
// Convert the raw value to compensated mv, taking the resistor-
|
||||
// divider into account (providing the actual LIPO voltage)
|
||||
return (uint16_t)((float)adcvalue * REAL_VBAT_MV_PER_LSB);
|
||||
}
|
||||
|
||||
bool ThinkNodeM1Board::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("THINKNODE_M1_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;
|
||||
}
|
||||
#endif
|
||||
57
variants/thinknode_m1/ThinkNodeM1Board.h
Normal file
57
variants/thinknode_m1/ThinkNodeM1Board.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include <MeshCore.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
// built-ins
|
||||
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
||||
|
||||
#define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT
|
||||
#define VBAT_DIVIDER_COMP (2.0F) // Compensation factor for the VBAT divider
|
||||
|
||||
#define PIN_VBAT_READ (4)
|
||||
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
||||
|
||||
class ThinkNodeM1Board : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
|
||||
public:
|
||||
|
||||
void begin();
|
||||
uint16_t getBattMilliVolts() override;
|
||||
bool startOTAUpdate(const char* id, char reply[]) override;
|
||||
|
||||
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
|
||||
|
||||
const char* getManufacturerName() const override {
|
||||
return "Elecrow ThinkNode-M1";
|
||||
}
|
||||
|
||||
void reboot() override {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
|
||||
// turn off all leds, sd_power_system_off will not do this for us
|
||||
#ifdef P_LORA_TX_LED
|
||||
digitalWrite(P_LORA_TX_LED, LOW);
|
||||
#endif
|
||||
|
||||
// power off board
|
||||
sd_power_system_off();
|
||||
|
||||
}
|
||||
};
|
||||
|
|
@ -1,33 +1,35 @@
|
|||
[nrf52840_thinknode_m1]
|
||||
[ThinkNode_M1]
|
||||
extends = nrf52_base
|
||||
platform_packages = framework-arduinoadafruitnrf52
|
||||
board = thinknode_m1
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
rweather/Crypto @ ^0.4.0
|
||||
|
||||
[ThinkNode_M1]
|
||||
extends = nrf52840_thinknode_m1
|
||||
board = thinknode_m1
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52840_thinknode_m1.build_flags}
|
||||
-I variants/thinknode_m1
|
||||
-D THINKNODE_M1=1
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_TX_LED=13
|
||||
-D P_LORA_DIO_1=20
|
||||
-D P_LORA_NSS=24
|
||||
-D P_LORA_RESET=25
|
||||
-D P_LORA_BUSY=17
|
||||
-D P_LORA_SCLK=19
|
||||
-D P_LORA_MISO=23
|
||||
-D P_LORA_MOSI=22
|
||||
-D SX126X_POWER_EN=37
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
build_src_filter = ${nrf52840_thinknode_m1.build_src_filter}
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_TX_LED=13
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/nrf52/ThinkNodeM1Board.cpp>
|
||||
+<ThinkNodeM1Board.cpp>
|
||||
+<../variants/thinknode_m1>
|
||||
lib_deps =
|
||||
${nrf52840_thinknode_m1.lib_deps}
|
||||
${nrf52_base.lib_deps}
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
|
@ -69,8 +71,8 @@ build_flags =
|
|||
${ThinkNode_M1.build_flags}
|
||||
-I src/helpers/ui
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D DISPLAY_ROTATION=4
|
||||
|
|
@ -78,10 +80,10 @@ build_flags =
|
|||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D PIN_BUZZER=6
|
||||
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||
-D QSPIFLASH=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${ThinkNode_M1.build_src_filter}
|
||||
+<helpers/nrf52/ThinkNodeM1.cpp>
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<helpers/ui/GxEPDDisplay.cpp>
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
|
|
@ -92,4 +94,5 @@ lib_deps =
|
|||
${ThinkNode_M1.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
zinggjm/GxEPD2 @ 1.6.2
|
||||
bakercp/CRC32 @ ^2.0.0
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/nrf52/ThinkNodeM1Board.h>
|
||||
#include <ThinkNodeM1Board.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
|
|
|
|||
|
|
@ -110,6 +110,15 @@ extern const int MISO;
|
|||
extern const int MOSI;
|
||||
extern const int SCK;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// QSPI
|
||||
#define PIN_QSPI_SCK (46)
|
||||
#define PIN_QSPI_CS (47)
|
||||
#define PIN_QSPI_IO0 (44) // MOSI if using two bit interface
|
||||
#define PIN_QSPI_IO1 (45) // MISO if using two bit interface
|
||||
#define PIN_QSPI_IO2 (7) // WP if using two bit interface (i.e. not used)
|
||||
#define PIN_QSPI_IO3 (5) // HOLD if using two bit interface (i.e. not used)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Display
|
||||
|
||||
|
|
|
|||
30
variants/waveshare_rp2040_lora/WaveshareBoard.cpp
Normal file
30
variants/waveshare_rp2040_lora/WaveshareBoard.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "WaveshareBoard.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
void WaveshareBoard::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
|
||||
#ifdef P_LORA_TX_LED
|
||||
pinMode(P_LORA_TX_LED, OUTPUT);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_VBAT_READ
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
#endif
|
||||
|
||||
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
|
||||
Wire.setSDA(PIN_BOARD_SDA);
|
||||
Wire.setSCL(PIN_BOARD_SCL);
|
||||
#endif
|
||||
|
||||
Wire.begin();
|
||||
|
||||
delay(10); // give sx1262 some time to power up
|
||||
}
|
||||
|
||||
bool WaveshareBoard::startOTAUpdate(const char *id, char reply[]) {
|
||||
return false;
|
||||
}
|
||||
61
variants/waveshare_rp2040_lora/WaveshareBoard.h
Normal file
61
variants/waveshare_rp2040_lora/WaveshareBoard.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <MeshCore.h>
|
||||
|
||||
// LoRa radio module pins for Waveshare RP2040-LoRa-HF/LF
|
||||
// https://files.waveshare.com/wiki/RP2040-LoRa/Rp2040-lora-sch.pdf
|
||||
|
||||
/*
|
||||
* This board has no built-in way to read battery voltage.
|
||||
* Nevertheless it's very easy to make it work, you only require two 1% resistors.
|
||||
*
|
||||
* BAT+ -----+
|
||||
* |
|
||||
* VSYS --+ -/\/\/\/\- --+
|
||||
* 200k |
|
||||
* +-- GPIO28
|
||||
* |
|
||||
* GND --+ -/\/\/\/\- --+
|
||||
* | 100k
|
||||
* BAT- -----+
|
||||
*/
|
||||
#define PIN_VBAT_READ 28
|
||||
#define BATTERY_SAMPLES 8
|
||||
#define ADC_MULTIPLIER (3.0f * 3.3f * 1000)
|
||||
|
||||
class WaveshareBoard : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
|
||||
public:
|
||||
void begin();
|
||||
uint8_t getStartupReason() const override { return startup_reason; }
|
||||
|
||||
#ifdef P_LORA_TX_LED
|
||||
void onBeforeTransmit() override { digitalWrite(P_LORA_TX_LED, HIGH); }
|
||||
void onAfterTransmit() override { digitalWrite(P_LORA_TX_LED, LOW); }
|
||||
#endif
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
#if defined(PIN_VBAT_READ) && defined(ADC_MULTIPLIER)
|
||||
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;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *getManufacturerName() const override { return "Waveshare RP2040-LoRa"; }
|
||||
|
||||
void reboot() override { rp2040.reboot(); }
|
||||
|
||||
bool startOTAUpdate(const char *id, char reply[]) override;
|
||||
};
|
||||
|
|
@ -3,28 +3,34 @@
|
|||
|
||||
[waveshare_rp2040_lora]
|
||||
extends = rp2040_base
|
||||
|
||||
board = pico
|
||||
board_build.filesystem_size = 0.5m
|
||||
|
||||
build_flags = ${rp2040_base.build_flags}
|
||||
-I variants/waveshare_rp2040_lora
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_DIO_1=16
|
||||
-D P_LORA_NSS=13 ; CS
|
||||
-D P_LORA_RESET=23
|
||||
-D P_LORA_BUSY=18
|
||||
-D P_LORA_SCLK=14
|
||||
-D P_LORA_MISO=24
|
||||
-D P_LORA_MOSI=15
|
||||
-D P_LORA_TX_LED=25
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=0
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D LORA_TX_POWER=22
|
||||
; Debug options
|
||||
; -D DEBUG_RP2040_WIRE=1
|
||||
; -D DEBUG_RP2040_SPI=1
|
||||
; -D DEBUG_RP2040_CORE=1
|
||||
; -D RADIOLIB_DEBUG_SPI=1
|
||||
; -D DEBUG_RP2040_PORT=Serial
|
||||
|
||||
build_src_filter = ${rp2040_base.build_src_filter}
|
||||
+<helpers/rp2040/WaveshareBoard.cpp>
|
||||
+<WaveshareBoard.cpp>
|
||||
+<../variants/waveshare_rp2040_lora>
|
||||
|
||||
lib_deps = ${rp2040_base.lib_deps}
|
||||
|
||||
[env:waveshare_rp2040_lora_Repeater]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/rp2040/WaveshareBoard.h>
|
||||
#include <WaveshareBoard.h>
|
||||
|
||||
extern WaveshareBoard board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ build_flags = ${WioTrackerL1.build_flags}
|
|||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D DISPLAY_CLASS=SH1106Display
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D PIN_BUZZER=12
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||
build_src_filter = ${WioTrackerL1.build_src_filter}
|
||||
|
|
@ -77,15 +79,16 @@ lib_deps = ${WioTrackerL1.lib_deps}
|
|||
extends = WioTrackerL1
|
||||
build_flags = ${WioTrackerL1.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-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
|
||||
-D QSPIFLASH=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${WioTrackerL1.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
|
|
|
|||
|
|
@ -59,13 +59,14 @@ upload_protocol = nrfutil
|
|||
extends = Xiao_nrf52
|
||||
build_flags =
|
||||
${Xiao_nrf52.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D MESH_DEBUG=1
|
||||
-D QSPIFLASH=1
|
||||
build_src_filter = ${Xiao_nrf52.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
|
|
@ -77,8 +78,8 @@ lib_deps =
|
|||
extends = Xiao_nrf52
|
||||
build_flags =
|
||||
${Xiao_nrf52.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Xiao_nrf52.build_src_filter}
|
||||
|
|
|
|||
30
variants/xiao_rp2040/XiaoRP2040Board.cpp
Normal file
30
variants/xiao_rp2040/XiaoRP2040Board.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "XiaoRP2040Board.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
void XiaoRP2040Board::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
|
||||
#ifdef P_LORA_TX_LED
|
||||
pinMode(P_LORA_TX_LED, OUTPUT);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_VBAT_READ
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
#endif
|
||||
|
||||
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
|
||||
Wire.setSDA(PIN_BOARD_SDA);
|
||||
Wire.setSCL(PIN_BOARD_SCL);
|
||||
#endif
|
||||
|
||||
Wire.begin();
|
||||
|
||||
delay(10); // give sx1262 some time to power up
|
||||
}
|
||||
|
||||
bool XiaoRP2040Board::startOTAUpdate(const char *id, char reply[]) {
|
||||
return false;
|
||||
}
|
||||
60
variants/xiao_rp2040/XiaoRP2040Board.h
Normal file
60
variants/xiao_rp2040/XiaoRP2040Board.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <MeshCore.h>
|
||||
|
||||
/*
|
||||
* This board has no built-in way to read battery voltage.
|
||||
* Nevertheless it's very easy to make it work, you only require two 1% resistors.
|
||||
* If your using the WIO SX1262 Addon for xaio, make sure you dont connect D0!
|
||||
*
|
||||
* BAT+ -----+
|
||||
* |
|
||||
* VSYS --+ -/\/\/\/\- --+
|
||||
* 200k |
|
||||
* +-- D0
|
||||
* |
|
||||
* GND --+ -/\/\/\/\- --+
|
||||
* | 100k
|
||||
* BAT- -----+
|
||||
*/
|
||||
#define PIN_VBAT_READ 26 // D0
|
||||
#define BATTERY_SAMPLES 8
|
||||
#define ADC_MULTIPLIER (3.0f * 3.3f * 1000)
|
||||
|
||||
class XiaoRP2040Board : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
|
||||
public:
|
||||
void begin();
|
||||
uint8_t getStartupReason() const override { return startup_reason; }
|
||||
|
||||
#ifdef P_LORA_TX_LED
|
||||
void onBeforeTransmit() override { digitalWrite(P_LORA_TX_LED, HIGH); }
|
||||
void onAfterTransmit() override { digitalWrite(P_LORA_TX_LED, LOW); }
|
||||
#endif
|
||||
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
#if defined(PIN_VBAT_READ) && defined(ADC_MULTIPLIER)
|
||||
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;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *getManufacturerName() const override { return "Xiao RP2040"; }
|
||||
|
||||
void reboot() override { rp2040.reboot(); }
|
||||
|
||||
bool startOTAUpdate(const char *id, char reply[]) override;
|
||||
};
|
||||
|
|
@ -1,27 +1,32 @@
|
|||
[Xiao_rp2040]
|
||||
extends = rp2040_base
|
||||
|
||||
board = seeed_xiao_rp2040
|
||||
board_build.filesystem_size = 0.5m
|
||||
|
||||
build_flags = ${rp2040_base.build_flags}
|
||||
-I variants/xiao_rp2040
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D P_LORA_DIO_1=27 ; D1
|
||||
-D P_LORA_NSS=6 ; D4
|
||||
-D P_LORA_RESET=28 ; D2
|
||||
-D P_LORA_BUSY=29 ; D3
|
||||
-D P_LORA_TX_LED=17
|
||||
-D SX126X_RXEN=7 ; D5
|
||||
-D SX126X_TXEN=RADIOLIB_NC
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D LORA_TX_POWER=22
|
||||
; Debug options
|
||||
; -D DEBUG_RP2040_WIRE=1
|
||||
; -D DEBUG_RP2040_SPI=1
|
||||
; -D DEBUG_RP2040_CORE=1
|
||||
; -D RADIOLIB_DEBUG_SPI=1
|
||||
; -D DEBUG_RP2040_PORT=Serial
|
||||
|
||||
build_src_filter = ${rp2040_base.build_src_filter}
|
||||
+<helpers/rp2040/XiaoRP2040Board.cpp>
|
||||
+<XiaoRP2040Board.cpp>
|
||||
+<../variants/xiao_rp2040>
|
||||
|
||||
lib_deps = ${rp2040_base.lib_deps}
|
||||
|
||||
[env:Xiao_rp2040_Repeater]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/rp2040/XiaoRP2040Board.h>
|
||||
#include <XiaoRP2040Board.h>
|
||||
|
||||
extern XiaoRP2040Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue