mirror of https://github.com/meshcore-dev/MeshCore
111 changed files with 2366 additions and 977 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" |
|||
} |
|||
@ -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 |
|||
@ -0,0 +1,81 @@ |
|||
#include <Arduino.h> |
|||
#include "RAKWismeshTagBoard.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 RAKWismeshTagBoard::begin() { |
|||
// for future use, sub-classes SHOULD call this from their begin()
|
|||
startup_reason = BD_STARTUP_NORMAL; |
|||
pinMode(PIN_VBAT_READ, INPUT); |
|||
pinMode(PIN_USER_BTN, INPUT_PULLUP); |
|||
|
|||
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL); |
|||
Wire.begin(); |
|||
|
|||
pinMode(SX126X_POWER_EN, OUTPUT); |
|||
digitalWrite(SX126X_POWER_EN, HIGH); |
|||
delay(10); // give sx1262 some time to power up
|
|||
} |
|||
|
|||
bool RAKWismeshTagBoard::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("WISMESHTAG_OTA"); |
|||
|
|||
Bluefruit.Periph.setConnectCallback(connect_callback); |
|||
Bluefruit.Periph.setDisconnectCallback(disconnect_callback); |
|||
|
|||
// To be consistent OTA DFU should be added first if it exists
|
|||
bledfu.begin(); |
|||
|
|||
// Set up and start advertising
|
|||
// Advertising packet
|
|||
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); |
|||
Bluefruit.Advertising.addTxPower(); |
|||
Bluefruit.Advertising.addName(); |
|||
|
|||
/* Start Advertising
|
|||
- Enable auto advertising if disconnected |
|||
- Interval: fast mode = 20 ms, slow mode = 152.5 ms |
|||
- Timeout for fast mode is 30 seconds |
|||
- Start(timeout) with timeout = 0 will advertise forever (until connected) |
|||
|
|||
For recommended advertising interval |
|||
https://developer.apple.com/library/content/qa/qa1931/_index.html
|
|||
*/ |
|||
Bluefruit.Advertising.restartOnDisconnect(true); |
|||
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
|
|||
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
|||
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
|||
|
|||
uint8_t mac_addr[6]; |
|||
memset(mac_addr, 0, sizeof(mac_addr)); |
|||
Bluefruit.getAddr(mac_addr); |
|||
sprintf(reply, "OK - mac: %02X:%02X:%02X:%02X:%02X:%02X", |
|||
mac_addr[5], mac_addr[4], mac_addr[3], mac_addr[2], mac_addr[1], mac_addr[0]); |
|||
|
|||
return true; |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
#pragma once |
|||
|
|||
#include <MeshCore.h> |
|||
#include <Arduino.h> |
|||
|
|||
// built-ins
|
|||
#define PIN_VBAT_READ 5 |
|||
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000) |
|||
|
|||
class RAKWismeshTagBoard : 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) && defined(LED_STATE_ON) |
|||
void onBeforeTransmit() override { |
|||
digitalWrite(P_LORA_TX_LED, LED_STATE_ON); // turn TX LED on
|
|||
} |
|||
void onAfterTransmit() override { |
|||
digitalWrite(P_LORA_TX_LED, !LED_STATE_ON); // turn TX LED off
|
|||
} |
|||
#endif |
|||
|
|||
#define BATTERY_SAMPLES 8 |
|||
|
|||
uint16_t getBattMilliVolts() override { |
|||
analogReadResolution(12); |
|||
|
|||
uint32_t raw = 0; |
|||
for (int i = 0; i < BATTERY_SAMPLES; i++) { |
|||
raw += analogRead(PIN_VBAT_READ); |
|||
} |
|||
raw = raw / BATTERY_SAMPLES; |
|||
|
|||
return (ADC_MULTIPLIER * raw) / 4096; |
|||
} |
|||
|
|||
const char* getManufacturerName() const override { |
|||
return "RAK WisMesh Tag"; |
|||
} |
|||
|
|||
void reboot() override { |
|||
NVIC_SystemReset(); |
|||
} |
|||
|
|||
bool startOTAUpdate(const char* id, char reply[]) override; |
|||
|
|||
void powerOff() override { |
|||
#ifdef BUZZER_EN |
|||
digitalWrite(BUZZER_EN, LOW); |
|||
#endif |
|||
|
|||
#ifdef PIN_GPS_EN |
|||
digitalWrite(PIN_GPS_EN, LOW); |
|||
#endif |
|||
|
|||
// set led on and wait for button release before poweroff
|
|||
#ifdef LED_PIN |
|||
digitalWrite(LED_PIN, HIGH); |
|||
#endif |
|||
#ifdef BUTTON_PIN |
|||
while(digitalRead(BUTTON_PIN)); |
|||
#endif |
|||
#ifdef LED_GREEN |
|||
digitalWrite(LED_GREEN, LOW); |
|||
#endif |
|||
#ifdef LED_BLUE |
|||
digitalWrite(LED_BLUE, LOW); |
|||
#endif |
|||
|
|||
#ifdef BUTTON_PIN |
|||
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(BUTTON_PIN), NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH); |
|||
#endif |
|||
|
|||
sd_power_system_off(); |
|||
} |
|||
}; |
|||
@ -0,0 +1,116 @@ |
|||
[rak_wismesh_tag] |
|||
extends = nrf52_base |
|||
platform = https://github.com/maxgerhardt/platform-nordicnrf52.git#rak |
|||
board = wiscore_rak4631 |
|||
board_check = true |
|||
build_flags = ${nrf52_base.build_flags} |
|||
${sensor_base.build_flags} |
|||
-I variants/rak_wismesh_tag |
|||
-I src/helpers/ui |
|||
-D RAK_WISMESH_TAG |
|||
-D RAK_BOARD |
|||
-D P_LORA_TX_LED=LED_GREEN |
|||
-D P_LORA_DIO_1=SX126X_DIO1 |
|||
-D P_LORA_NSS=PIN_SPI_NSS |
|||
-D P_LORA_RESET=SX126X_RESET |
|||
-D P_LORA_BUSY=SX126X_BUSY |
|||
-D P_LORA_SCLK=PIN_SPI_SCK |
|||
-D P_LORA_MISO=PIN_SPI_MISO |
|||
-D P_LORA_MOSI=PIN_SPI_MOSI |
|||
-D RADIO_CLASS=CustomSX1262 |
|||
-D WRAPPER_CLASS=CustomSX1262Wrapper |
|||
-D DISPLAY_CLASS=NullDisplayDriver |
|||
-D LORA_TX_POWER=22 |
|||
-D SX126X_CURRENT_LIMIT=140 |
|||
-D SX126X_RX_BOOSTED_GAIN=1 |
|||
-D PIN_BUZZER=21 |
|||
-D PIN_BOARD_SDA=PIN_WIRE_SDA |
|||
-D PIN_BOARD_SCL=PIN_WIRE_SCL |
|||
build_src_filter = ${nrf52_base.build_src_filter} |
|||
+<../variants/rak_wismesh_tag> |
|||
+<helpers/ui/buzzer.cpp> |
|||
+<helpers/ui/MomentaryButton.cpp> |
|||
+<helpers/ui/NullDisplayDriver.cpp> |
|||
+<helpers/sensors> |
|||
lib_deps = |
|||
${nrf52_base.lib_deps} |
|||
${sensor_base.lib_deps} |
|||
|
|||
[env:RAK_WisMesh_Tag_Repeater] |
|||
extends = rak_wismesh_tag |
|||
build_flags = |
|||
${rak_wismesh_tag.build_flags} |
|||
-D ADVERT_NAME='"RAK WM Repeater"' |
|||
-D ADVERT_LAT=0.0 |
|||
-D ADVERT_LON=0.0 |
|||
-D ADMIN_PASSWORD='"password"' |
|||
-D MAX_NEIGHBOURS=8 |
|||
; -D MESH_PACKET_LOGGING=1 |
|||
; -D MESH_DEBUG=1 |
|||
build_src_filter = ${rak_wismesh_tag.build_src_filter} |
|||
+<../examples/simple_repeater> |
|||
|
|||
[env:RAK_WisMesh_Tag_room_server] |
|||
extends = rak_wismesh_tag |
|||
build_flags = |
|||
${rak_wismesh_tag.build_flags} |
|||
-D ADVERT_NAME='"RAK WM Room"' |
|||
-D ADVERT_LAT=0.0 |
|||
-D ADVERT_LON=0.0 |
|||
-D ADMIN_PASSWORD='"password"' |
|||
-D ROOM_PASSWORD='"hello"' |
|||
; -D MESH_PACKET_LOGGING=1 |
|||
; -D MESH_DEBUG=1 |
|||
build_src_filter = ${rak_wismesh_tag.build_src_filter} |
|||
+<../examples/simple_room_server> |
|||
|
|||
[env:RAK_WisMesh_Tag_companion_radio_usb] |
|||
extends = rak_wismesh_tag |
|||
build_flags = |
|||
${rak_wismesh_tag.build_flags} |
|||
-I examples/companion_radio/ui-orig |
|||
-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 = ${rak_wismesh_tag.build_src_filter} |
|||
+<../examples/companion_radio/*.cpp> |
|||
+<../examples/companion_radio/ui-orig/*.cpp> |
|||
lib_deps = |
|||
${rak_wismesh_tag.lib_deps} |
|||
densaugeo/base64 @ ~1.4.0 |
|||
end2endzone/NonBlockingRTTTL@^1.3.0 |
|||
|
|||
[env:RAK_WisMesh_Tag_companion_radio_ble] |
|||
extends = rak_wismesh_tag |
|||
build_flags = |
|||
${rak_wismesh_tag.build_flags} |
|||
-I examples/companion_radio/ui-orig |
|||
-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 = ${rak_wismesh_tag.build_src_filter} |
|||
+<helpers/nrf52/SerialBLEInterface.cpp> |
|||
+<../examples/companion_radio/*.cpp> |
|||
+<../examples/companion_radio/ui-orig/*.cpp> |
|||
lib_deps = |
|||
${rak4631.lib_deps} |
|||
densaugeo/base64 @ ~1.4.0 |
|||
end2endzone/NonBlockingRTTTL@^1.3.0 |
|||
|
|||
[env:RAK_WisMesh_Tag_sensor] |
|||
extends = rak4631 |
|||
build_flags = |
|||
${rak4631.build_flags} |
|||
-D ADVERT_NAME='"RAK WM Sensor"' |
|||
-D ADVERT_LAT=0.0 |
|||
-D ADVERT_LON=0.0 |
|||
-D ADMIN_PASSWORD='"password"' |
|||
; -D MESH_PACKET_LOGGING=1 |
|||
-D MESH_DEBUG=1 |
|||
build_src_filter = ${rak4631.build_src_filter} |
|||
+<../examples/simple_sensor> |
|||
@ -0,0 +1,54 @@ |
|||
#include <Arduino.h> |
|||
#include "target.h" |
|||
#include <helpers/ArduinoHelpers.h> |
|||
|
|||
RAKWismeshTagBoard board; |
|||
|
|||
#ifndef PIN_USER_BTN |
|||
#define PIN_USER_BTN (-1) |
|||
#endif |
|||
|
|||
#ifdef DISPLAY_CLASS |
|||
DISPLAY_CLASS display; |
|||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true); |
|||
#endif |
|||
|
|||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); |
|||
|
|||
WRAPPER_CLASS radio_driver(radio, board); |
|||
|
|||
VolatileRTCClock fallback_clock; |
|||
AutoDiscoverRTCClock rtc_clock(fallback_clock); |
|||
|
|||
#if ENV_INCLUDE_GPS |
|||
#include <helpers/sensors/MicroNMEALocationProvider.h> |
|||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1); |
|||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea); |
|||
#else |
|||
EnvironmentSensorManager sensors; |
|||
#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,27 @@ |
|||
#pragma once |
|||
|
|||
#define RADIOLIB_STATIC_ONLY 1 |
|||
#include <RadioLib.h> |
|||
#include <helpers/radiolib/RadioLibWrappers.h> |
|||
#include <RAKWismeshTagBoard.h> |
|||
#include <helpers/radiolib/CustomSX1262Wrapper.h> |
|||
#include <helpers/AutoDiscoverRTCClock.h> |
|||
#include <helpers/sensors/EnvironmentSensorManager.h> |
|||
|
|||
#ifdef DISPLAY_CLASS |
|||
#include <helpers/ui/NullDisplayDriver.h> |
|||
extern DISPLAY_CLASS display; |
|||
#include <helpers/ui/MomentaryButton.h> |
|||
extern MomentaryButton user_btn; |
|||
#endif |
|||
|
|||
extern RAKWismeshTagBoard board; |
|||
extern WRAPPER_CLASS radio_driver; |
|||
extern AutoDiscoverRTCClock rtc_clock; |
|||
extern EnvironmentSensorManager sensors; |
|||
|
|||
bool radio_init(); |
|||
uint32_t radio_get_rng_seed(); |
|||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr); |
|||
void radio_set_tx_power(uint8_t dbm); |
|||
mesh::LocalIdentity radio_new_identity(); |
|||
@ -0,0 +1,21 @@ |
|||
#include "variant.h" |
|||
#include "nrf.h" |
|||
#include "wiring_constants.h" |
|||
#include "wiring_digital.h" |
|||
|
|||
const uint32_t g_ADigitalPinMap[] = { |
|||
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 |
|||
}; |
|||
|
|||
void initVariant() { |
|||
// LEDs
|
|||
pinMode(LED_BLUE, OUTPUT); |
|||
pinMode(LED_GREEN, OUTPUT); |
|||
digitalWrite(LED_BLUE, LOW); |
|||
digitalWrite(LED_GREEN, LOW); |
|||
|
|||
// GPS
|
|||
pinMode(PIN_GPS_EN, OUTPUT); |
|||
digitalWrite(PIN_GPS_EN, HIGH); |
|||
} |
|||
@ -0,0 +1,121 @@ |
|||
/*
|
|||
* variant.h |
|||
* Copyright (C) 2023 Seeed K.K. |
|||
* MIT License |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include "WVariant.h" |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Low frequency clock source
|
|||
|
|||
#define USE_LFXO // 32.768 kHz crystal oscillator
|
|||
#define VARIANT_MCK (64000000ul) |
|||
|
|||
#define WIRE_INTERFACES_COUNT (1) |
|||
#define PIN_TXCO (21) |
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Power
|
|||
|
|||
#define PIN_PWR_EN (12) |
|||
|
|||
#define BATTERY_PIN (5) |
|||
#define ADC_MULTIPLIER (1.73F) |
|||
|
|||
#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 (6) |
|||
#define NUM_ANALOG_OUTPUTS (0) |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// UART pin definition
|
|||
|
|||
#define PIN_SERIAL1_RX (15) |
|||
#define PIN_SERIAL1_TX (16) |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// I2C pin definition
|
|||
#define WIRE_INTERFACES_COUNT (1) |
|||
#define PIN_WIRE_SDA (25) |
|||
#define PIN_WIRE_SCL (24) |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// SPI pin definition
|
|||
|
|||
#define SPI_INTERFACES_COUNT (2) |
|||
|
|||
#define PIN_SPI_MISO (45) |
|||
#define PIN_SPI_MOSI (44) |
|||
#define PIN_SPI_SCK (43) |
|||
#define PIN_SPI_NSS (42) |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Builtin LEDs
|
|||
|
|||
#define LED_RED (-1) |
|||
#define LED_BLUE (36) |
|||
#define LED_GREEN (35) |
|||
|
|||
//#define PIN_STATUS_LED LED_BLUE
|
|||
#define LED_BUILTIN LED_GREEN |
|||
#define LED_PIN LED_GREEN |
|||
#define LED_STATE_ON HIGH |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Builtin buttons
|
|||
|
|||
#define PIN_BUTTON1 (9) |
|||
#define BUTTON_PIN PIN_BUTTON1 |
|||
#define PIN_USER_BTN BUTTON_PIN |
|||
|
|||
#define PIN_BUTTON2 (12) |
|||
#define BUTTON_PIN2 PIN_BUTTON2 |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Lora
|
|||
|
|||
#define USE_SX1262 |
|||
#define LORA_CS (42) |
|||
#define SX126X_DIO1 (47) |
|||
#define SX126X_BUSY (46) |
|||
#define SX126X_RESET (38) |
|||
#define SX126X_POWER_EN (37) |
|||
#define SX126X_DIO2_AS_RF_SWITCH |
|||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8 |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// SPI1
|
|||
|
|||
#define PIN_SPI1_MISO (29) |
|||
#define PIN_SPI1_MOSI (30) |
|||
#define PIN_SPI1_SCK (3) |
|||
|
|||
// GxEPD2 needs that for a panel that is not even used !
|
|||
extern const int MISO; |
|||
extern const int MOSI; |
|||
extern const int SCK; |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// GPS
|
|||
|
|||
#define PIN_GPS_RX (PIN_SERIAL1_TX) |
|||
#define PIN_GPS_TX (PIN_SERIAL1_RX) |
|||
#define PIN_GPS_PPS (17) |
|||
#define PIN_GPS_EN (34) |
|||
|
|||
///////////////////////////////////////////////////////////////////////////////
|
|||
// OTHER PINS
|
|||
#define PIN_AREF (2) |
|||
#define PIN_NFC1 (9) |
|||
#define PIN_NFC2 (10) |
|||
#define PIN_BUZZER (21) |
|||
@ -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, |
|||
#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 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 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; |
|||
} |
|||
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; |
|||
} |
|||
|
|||
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); |
|||
} |
|||
Vout = light_volt; |
|||
light_level = 100 * (Vout - 80) / LIGHT_REF_VCC; |
|||
|
|||
return light_level; |
|||
} |
|||
|
|||
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; |
|||
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
|
|||
} |
|||
@ -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