mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Merge branch 'dev' of https://github.com/ripplebiz/MeshCore into dev
This commit is contained in:
commit
0c3c162835
33 changed files with 4989 additions and 23 deletions
|
|
@ -58,7 +58,7 @@ extends = T_Beam_S3_Supreme_SX1262
|
|||
build_flags =
|
||||
${T_Beam_S3_Supreme_SX1262.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=1
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
; -D ENABLE_PRIVATE_KEY_IMPORT=1
|
||||
|
|
@ -70,4 +70,4 @@ build_src_filter = ${T_Beam_S3_Supreme_SX1262.build_src_filter}
|
|||
+<../examples/companion_radio>
|
||||
lib_deps =
|
||||
${T_Beam_S3_Supreme_SX1262.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ lib_deps =
|
|||
adafruit/Adafruit GFX Library @ ^1.12.1
|
||||
${Heltec_t114.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
|
||||
[env:Heltec_t114_companion_radio_usb]
|
||||
extends = Heltec_t114
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
|
||||
T114Board board;
|
||||
|
||||
|
|
@ -10,7 +11,8 @@ WRAPPER_CLASS radio_driver(radio, board);
|
|||
|
||||
VolatileRTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||
T114SensorManager sensors = T114SensorManager(nmea);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
|
|
@ -68,3 +70,90 @@ mesh::LocalIdentity radio_new_identity() {
|
|||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
void T114SensorManager::start_gps() {
|
||||
if (!gps_active) {
|
||||
gps_active = true;
|
||||
_location->begin();
|
||||
}
|
||||
}
|
||||
|
||||
void T114SensorManager::stop_gps() {
|
||||
if (gps_active) {
|
||||
gps_active = false;
|
||||
_location->stop();
|
||||
}
|
||||
}
|
||||
|
||||
bool T114SensorManager::begin() {
|
||||
Serial1.begin(9600);
|
||||
|
||||
// Try to detect if GPS is physically connected to determine if we should expose the setting
|
||||
pinMode(GPS_EN, OUTPUT);
|
||||
digitalWrite(GPS_EN, HIGH); // Power on GPS
|
||||
|
||||
// Give GPS a moment to power up and send data
|
||||
delay(500);
|
||||
|
||||
// We'll consider GPS detected if we see any data on Serial1
|
||||
gps_detected = (Serial1.available() > 0);
|
||||
|
||||
if (gps_detected) {
|
||||
MESH_DEBUG_PRINTLN("GPS detected");
|
||||
digitalWrite(GPS_EN, LOW); // Power off GPS until the setting is changed
|
||||
} else {
|
||||
MESH_DEBUG_PRINTLN("No GPS detected");
|
||||
digitalWrite(GPS_EN, LOW);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool T114SensorManager::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, 0.0f);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void T114SensorManager::loop() {
|
||||
static long next_gps_update = 0;
|
||||
|
||||
_location->loop();
|
||||
|
||||
if (millis() > next_gps_update) {
|
||||
if (_location->isValid()) {
|
||||
node_lat = ((double)_location->getLatitude())/1000000.;
|
||||
node_lon = ((double)_location->getLongitude())/1000000.;
|
||||
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
|
||||
}
|
||||
next_gps_update = millis() + 1000;
|
||||
}
|
||||
}
|
||||
|
||||
int T114SensorManager::getNumSettings() const {
|
||||
return gps_detected ? 1 : 0; // only show GPS setting if GPS is detected
|
||||
}
|
||||
|
||||
const char* T114SensorManager::getSettingName(int i) const {
|
||||
return (gps_detected && i == 0) ? "gps" : NULL;
|
||||
}
|
||||
|
||||
const char* T114SensorManager::getSettingValue(int i) const {
|
||||
if (gps_detected && i == 0) {
|
||||
return gps_active ? "1" : "0";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool T114SensorManager::setSettingValue(const char* name, const char* value) {
|
||||
if (gps_detected && strcmp(name, "gps") == 0) {
|
||||
if (strcmp(value, "0") == 0) {
|
||||
stop_gps();
|
||||
} else {
|
||||
start_gps();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false; // not supported
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,30 @@
|
|||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
|
||||
class T114SensorManager : public SensorManager {
|
||||
bool gps_active = false;
|
||||
bool gps_detected = false;
|
||||
LocationProvider* _location;
|
||||
|
||||
void start_gps();
|
||||
void stop_gps();
|
||||
public:
|
||||
T114SensorManager(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 T114Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
extern T114SensorManager sensors;
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// UART pin definition
|
||||
|
||||
#define PIN_SERIAL1_RX (39)
|
||||
#define PIN_SERIAL1_TX (37)
|
||||
#define PIN_SERIAL1_RX (37)
|
||||
#define PIN_SERIAL1_TX (39)
|
||||
|
||||
#define PIN_SERIAL2_RX (9)
|
||||
#define PIN_SERIAL2_TX (10)
|
||||
|
|
@ -69,7 +69,7 @@
|
|||
#define LED_BUILTIN (35)
|
||||
#define PIN_LED LED_BUILTIN
|
||||
#define LED_RED LED_BUILTIN
|
||||
#define LED_BLUE LED_BUILTIN
|
||||
#define LED_BLUE (-1) // No blue led, prevents Bluefruit flashing the green LED during advertising
|
||||
#define LED_PIN LED_BUILTIN
|
||||
|
||||
#define LED_STATE_ON HIGH
|
||||
|
|
@ -112,6 +112,12 @@
|
|||
#define PIN_BUZZER (46)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// GPS
|
||||
|
||||
#define GPS_EN (21)
|
||||
#define GPS_RESET (38)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TFT
|
||||
#define PIN_TFT_SCL (40)
|
||||
|
|
|
|||
31
variants/wio-e5/platformio.ini
Normal file
31
variants/wio-e5/platformio.ini
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
[lora_e5]
|
||||
extends = stm32_base
|
||||
board = lora_e5_dev_board
|
||||
board_upload.maximum_size = 229376 ; 32kb for FS
|
||||
build_flags = ${stm32_base.build_flags}
|
||||
-D RADIO_CLASS=CustomSTM32WLx
|
||||
-D WRAPPER_CLASS=CustomSTM32WLxWrapper
|
||||
-D SPI_INTERFACES_COUNT=0
|
||||
-I variants/wio-e5
|
||||
build_src_filter = ${stm32_base.build_src_filter}
|
||||
+<../variants/wio-e5>
|
||||
|
||||
[env:wio-e5-repeater]
|
||||
extends = lora_e5
|
||||
build_flags = ${lora_e5.build_flags}
|
||||
-D LORA_TX_POWER=20
|
||||
-D ADVERT_NAME='"WIO-E5 Repeater"'
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
build_src_filter = ${lora_e5.build_src_filter}
|
||||
+<../examples/simple_repeater/main.cpp>
|
||||
|
||||
[env:wio-e5_companion_radio_usb]
|
||||
extends = lora_e5
|
||||
build_flags = ${lora_e5.build_flags}
|
||||
-D LORA_TX_POWER=20
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
build_src_filter = ${lora_e5.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
lib_deps = ${lora_e5.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
69
variants/wio-e5/target.cpp
Normal file
69
variants/wio-e5/target.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
|
||||
STM32Board board;
|
||||
|
||||
RADIO_CLASS radio = new STM32WLx_Module();
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
static const uint32_t rfswitch_pins[] = {PA4, PA5, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
|
||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||
{STM32WLx::MODE_IDLE, {LOW, LOW}},
|
||||
{STM32WLx::MODE_RX, {HIGH, LOW}},
|
||||
{STM32WLx::MODE_TX_HP, {LOW, HIGH}}, // for LoRa-E5 mini
|
||||
// {STM32WLx::MODE_TX_LP, {HIGH, HIGH}}, // for LoRa-E5-LE mini
|
||||
END_OF_MODE_TABLE,
|
||||
};
|
||||
|
||||
VolatileRTCClock rtc_clock;
|
||||
SensorManager sensors;
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
// rtc_clock.begin(Wire);
|
||||
|
||||
// #ifdef SX126X_DIO3_TCXO_VOLTAGE
|
||||
// float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
|
||||
// #else
|
||||
// float tcxo = 1.6f;
|
||||
// #endif
|
||||
|
||||
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
|
||||
|
||||
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, 1.7, 0);
|
||||
|
||||
if (status != RADIOLIB_ERR_NONE) {
|
||||
Serial.print("ERROR: radio init failed: ");
|
||||
Serial.println(status);
|
||||
return false; // fail
|
||||
}
|
||||
|
||||
radio.setCRC(1);
|
||||
|
||||
return true; // success
|
||||
}
|
||||
|
||||
uint32_t radio_get_rng_seed() {
|
||||
return radio.random(0x7FFFFFFF);
|
||||
}
|
||||
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
|
||||
radio.setFrequency(freq);
|
||||
radio.setSpreadingFactor(sf);
|
||||
radio.setBandwidth(bw);
|
||||
radio.setCodingRate(cr);
|
||||
}
|
||||
|
||||
void radio_set_tx_power(uint8_t dbm) {
|
||||
radio.setOutputPower(dbm);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
20
variants/wio-e5/target.h
Normal file
20
variants/wio-e5/target.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/stm32/STM32Board.h>
|
||||
#include <helpers/CustomSTM32WLxWrapper.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
|
||||
extern STM32Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
void radio_set_tx_power(uint8_t dbm);
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
10
variants/wio-e5/variant.h
Normal file
10
variants/wio-e5/variant.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
// UART Definitions
|
||||
#ifndef SERIAL_UART_INSTANCE
|
||||
#define SERIAL_UART_INSTANCE 101
|
||||
#endif
|
||||
|
||||
#include <variant_LORA_E5_MINI.h>
|
||||
|
||||
#undef RNG
|
||||
Loading…
Add table
Add a link
Reference in a new issue