mirror of https://github.com/meshcore-dev/MeshCore
110 changed files with 1918 additions and 974 deletions
@ -0,0 +1,53 @@ |
|||||
|
{ |
||||
|
"build": { |
||||
|
"arduino": { |
||||
|
"ldscript": "nrf52840_s140_v6.ld" |
||||
|
}, |
||||
|
"core": "nRF5", |
||||
|
"cpu": "cortex-m4", |
||||
|
"extra_flags": "-DNRF52840_XXAA", |
||||
|
"f_cpu": "64000000L", |
||||
|
"hwids": [ |
||||
|
["0x239A", "0x4405"], |
||||
|
["0x239A", "0x0029"], |
||||
|
["0x239A", "0x002A"] |
||||
|
], |
||||
|
"usb_product": "HT-n5262", |
||||
|
"mcu": "nrf52840", |
||||
|
"variant": "heltec_mesh_pocket", |
||||
|
"variants_dir": "variants", |
||||
|
"bsp": { |
||||
|
"name": "adafruit" |
||||
|
}, |
||||
|
"softdevice": { |
||||
|
"sd_flags": "-DS140", |
||||
|
"sd_name": "s140", |
||||
|
"sd_version": "6.1.1", |
||||
|
"sd_fwid": "0x00B6" |
||||
|
}, |
||||
|
"bootloader": { |
||||
|
"settings_addr": "0xFF000" |
||||
|
} |
||||
|
}, |
||||
|
"connectivity": ["bluetooth"], |
||||
|
"debug": { |
||||
|
"jlink_device": "nRF52840_xxAA", |
||||
|
"onboard_tools": ["jlink"], |
||||
|
"svd_path": "nrf52840.svd", |
||||
|
"openocd_target": "nrf52840-mdk-rs" |
||||
|
}, |
||||
|
"frameworks": ["arduino"], |
||||
|
"name": "Heltec nrf (Adafruit BSP)", |
||||
|
"upload": { |
||||
|
"maximum_ram_size": 248832, |
||||
|
"maximum_size": 815104, |
||||
|
"speed": 115200, |
||||
|
"protocol": "nrfutil", |
||||
|
"protocols": ["jlink", "nrfjprog", "nrfutil", "stlink"], |
||||
|
"use_1200bps_touch": true, |
||||
|
"require_upload_port": true, |
||||
|
"wait_for_upload_port": true |
||||
|
}, |
||||
|
"url": "https://heltec.org/project/meshpocket/", |
||||
|
"vendor": "Heltec" |
||||
|
} |
||||
@ -53,7 +53,7 @@ build_src_filter = |
|||||
|
|
||||
[esp32_base] |
[esp32_base] |
||||
extends = arduino_base |
extends = arduino_base |
||||
platform = platformio/espressif32@^6.11.0 |
platform = platformio/[email protected] |
||||
monitor_filters = esp32_exception_decoder |
monitor_filters = esp32_exception_decoder |
||||
extra_scripts = merge-bin.py |
extra_scripts = merge-bin.py |
||||
build_flags = ${arduino_base.build_flags} |
build_flags = ${arduino_base.build_flags} |
||||
@ -78,6 +78,10 @@ platform = nordicnrf52 |
|||||
build_flags = ${arduino_base.build_flags} |
build_flags = ${arduino_base.build_flags} |
||||
-D NRF52_PLATFORM |
-D NRF52_PLATFORM |
||||
-D LFS_NO_ASSERT=1 |
-D LFS_NO_ASSERT=1 |
||||
|
-D EXTRAFS=1 |
||||
|
lib_deps = |
||||
|
${arduino_base.lib_deps} |
||||
|
https://github.com/oltaco/CustomLFS @ 0.2 |
||||
|
|
||||
; ----------------- RP2040 --------------------- |
; ----------------- RP2040 --------------------- |
||||
|
|
||||
|
|||||
@ -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 |
||||
@ -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 |
||||
@ -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
|
||||
|
} |
||||
|
|
||||
@ -0,0 +1,31 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#define RADIOLIB_STATIC_ONLY 1 |
||||
|
#include <RadioLib.h> |
||||
|
#include <helpers/radiolib/RadioLibWrappers.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 |
||||
|
|
||||
|
extern TechoBoard board; |
||||
|
extern WRAPPER_CLASS radio_driver; |
||||
|
extern AutoDiscoverRTCClock rtc_clock; |
||||
|
extern EnvironmentSensorManager sensors; |
||||
|
|
||||
|
#ifdef DISPLAY_CLASS |
||||
|
extern DISPLAY_CLASS display; |
||||
|
extern MomentaryButton user_btn; |
||||
|
#endif |
||||
|
|
||||
|
bool radio_init(); |
||||
|
uint32_t radio_get_rng_seed(); |
||||
|
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr); |
||||
|
void radio_set_tx_power(uint8_t dbm); |
||||
|
mesh::LocalIdentity radio_new_identity(); |
||||
@ -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; |
||||
|
} |
||||
@ -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; |
||||
|
}; |
||||
@ -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
|
||||
|
} |
||||
@ -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; |
||||
|
|
||||
@ -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}; |
||||
@ -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 |
||||
@ -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
|
|
||||
} |
|
||||
@ -1,47 +0,0 @@ |
|||||
#pragma once |
|
||||
|
|
||||
#define RADIOLIB_STATIC_ONLY 1 |
|
||||
#include <RadioLib.h> |
|
||||
#include <helpers/radiolib/RadioLibWrappers.h> |
|
||||
#include <helpers/nrf52/TechoBoard.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/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; |
|
||||
|
|
||||
#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(); |
|
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue