Merge branch 'dev' of https://github.com/ripplebiz/MeshCore into mymesh-refactor2
This commit is contained in:
@@ -545,7 +545,8 @@ void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packe
|
|||||||
out_frame[i++] = RESP_CODE_CHANNEL_MSG_RECV;
|
out_frame[i++] = RESP_CODE_CHANNEL_MSG_RECV;
|
||||||
}
|
}
|
||||||
|
|
||||||
out_frame[i++] = findChannelIdx(channel);
|
uint8_t channel_idx = findChannelIdx(channel);
|
||||||
|
out_frame[i++] = channel_idx;
|
||||||
uint8_t path_len = out_frame[i++] = pkt->isRouteFlood() ? pkt->path_len : 0xFF;
|
uint8_t path_len = out_frame[i++] = pkt->isRouteFlood() ? pkt->path_len : 0xFF;
|
||||||
|
|
||||||
out_frame[i++] = TXT_TYPE_PLAIN;
|
out_frame[i++] = TXT_TYPE_PLAIN;
|
||||||
@@ -570,7 +571,13 @@ void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packe
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
ui_task.newMsg(path_len, "Public", text, offline_queue_len);
|
// Get the channel name from the channel index
|
||||||
|
const char *channel_name = "Unknown";
|
||||||
|
ChannelDetails channel_details;
|
||||||
|
if (getChannel(channel_idx, channel_details)) {
|
||||||
|
channel_name = channel_details.name;
|
||||||
|
}
|
||||||
|
ui_task.newMsg(path_len, channel_name, text, offline_queue_len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ static uint32_t _atoi(const char* sp) {
|
|||||||
/* GLOBAL OBJECTS */
|
/* GLOBAL OBJECTS */
|
||||||
StdRNG fast_rng;
|
StdRNG fast_rng;
|
||||||
SimpleMeshTables tables;
|
SimpleMeshTables tables;
|
||||||
MyMesh the_mesh(radio_driver, fast_rng, *new VolatileRTCClock(), tables); // TODO: test with 'rtc_clock' in target.cpp
|
MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables);
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
#include "UITask.h"
|
#include "UITask.h"
|
||||||
|
|||||||
@@ -4,13 +4,19 @@
|
|||||||
|
|
||||||
|
|
||||||
class LocationProvider {
|
class LocationProvider {
|
||||||
|
protected:
|
||||||
|
bool _time_sync_needed = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual void syncTime() { _time_sync_needed = true; }
|
||||||
|
virtual bool waitingTimeSync() { return _time_sync_needed; }
|
||||||
virtual long getLatitude() = 0;
|
virtual long getLatitude() = 0;
|
||||||
virtual long getLongitude() = 0;
|
virtual long getLongitude() = 0;
|
||||||
virtual long getAltitude() = 0;
|
virtual long getAltitude() = 0;
|
||||||
|
virtual long satellitesCount() = 0;
|
||||||
virtual bool isValid() = 0;
|
virtual bool isValid() = 0;
|
||||||
virtual long getTimestamp() = 0;
|
virtual long getTimestamp() = 0;
|
||||||
|
virtual void sendSentence(const char * sentence);
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
virtual void begin();
|
virtual void begin();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
|
|||||||
@@ -19,13 +19,16 @@
|
|||||||
class MicroNMEALocationProvider : public LocationProvider {
|
class MicroNMEALocationProvider : public LocationProvider {
|
||||||
char _nmeaBuffer[100];
|
char _nmeaBuffer[100];
|
||||||
MicroNMEA nmea;
|
MicroNMEA nmea;
|
||||||
|
mesh::RTCClock* _clock;
|
||||||
Stream* _gps_serial;
|
Stream* _gps_serial;
|
||||||
int _pin_reset;
|
int _pin_reset;
|
||||||
int _pin_en;
|
int _pin_en;
|
||||||
|
long next_check = 0;
|
||||||
|
long time_valid = 0;
|
||||||
|
|
||||||
public :
|
public :
|
||||||
MicroNMEALocationProvider(Stream& ser, int pin_reset = GPS_RESET, int pin_en = GPS_EN) :
|
MicroNMEALocationProvider(Stream& ser, mesh::RTCClock* clock = NULL, int pin_reset = GPS_RESET, int pin_en = GPS_EN) :
|
||||||
_gps_serial(&ser), nmea(_nmeaBuffer, sizeof(_nmeaBuffer)), _pin_reset(pin_reset), _pin_en(pin_en) {
|
_gps_serial(&ser), nmea(_nmeaBuffer, sizeof(_nmeaBuffer)), _pin_reset(pin_reset), _pin_en(pin_en), _clock(clock) {
|
||||||
if (_pin_reset != -1) {
|
if (_pin_reset != -1) {
|
||||||
pinMode(_pin_reset, OUTPUT);
|
pinMode(_pin_reset, OUTPUT);
|
||||||
digitalWrite(_pin_reset, GPS_RESET_FORCE);
|
digitalWrite(_pin_reset, GPS_RESET_FORCE);
|
||||||
@@ -59,6 +62,7 @@ public :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void syncTime() override { nmea.clear(); LocationProvider::syncTime(); }
|
||||||
long getLatitude() override { return nmea.getLatitude(); }
|
long getLatitude() override { return nmea.getLatitude(); }
|
||||||
long getLongitude() override { return nmea.getLongitude(); }
|
long getLongitude() override { return nmea.getLongitude(); }
|
||||||
long getAltitude() override {
|
long getAltitude() override {
|
||||||
@@ -66,6 +70,7 @@ public :
|
|||||||
nmea.getAltitude(alt);
|
nmea.getAltitude(alt);
|
||||||
return alt;
|
return alt;
|
||||||
}
|
}
|
||||||
|
long satellitesCount() override { return nmea.getNumSatellites(); }
|
||||||
bool isValid() override { return nmea.isValid(); }
|
bool isValid() override { return nmea.isValid(); }
|
||||||
|
|
||||||
long getTimestamp() override {
|
long getTimestamp() override {
|
||||||
@@ -73,7 +78,12 @@ public :
|
|||||||
return dt.unixtime();
|
return dt.unixtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sendSentence(const char *sentence) override {
|
||||||
|
nmea.sendSentence(*_gps_serial, sentence);
|
||||||
|
}
|
||||||
|
|
||||||
void loop() override {
|
void loop() override {
|
||||||
|
|
||||||
while (_gps_serial->available()) {
|
while (_gps_serial->available()) {
|
||||||
char c = _gps_serial->read();
|
char c = _gps_serial->read();
|
||||||
#ifdef GPS_NMEA_DEBUG
|
#ifdef GPS_NMEA_DEBUG
|
||||||
@@ -81,5 +91,20 @@ public :
|
|||||||
#endif
|
#endif
|
||||||
nmea.process(c);
|
nmea.process(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isValid()) time_valid = 0;
|
||||||
|
|
||||||
|
if (millis() > next_check) {
|
||||||
|
next_check = millis() + 1000;
|
||||||
|
if (_time_sync_needed && time_valid > 2) {
|
||||||
|
if (_clock != NULL) {
|
||||||
|
_clock->setCurrentTime(getTimestamp());
|
||||||
|
_time_sync_needed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isValid()) {
|
||||||
|
time_valid ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -126,11 +126,14 @@ InternalFileSystem::InternalFileSystem(void)
|
|||||||
|
|
||||||
bool InternalFileSystem::begin(void)
|
bool InternalFileSystem::begin(void)
|
||||||
{
|
{
|
||||||
|
volatile bool format_fs;
|
||||||
#ifdef FORMAT_FS
|
#ifdef FORMAT_FS
|
||||||
this->format();
|
format_fs = true;
|
||||||
|
#else
|
||||||
|
format_fs = false; // you can always use debugger to force formatting ;)
|
||||||
#endif
|
#endif
|
||||||
// failed to mount, erase all sector then format and mount again
|
// failed to mount, erase all sector then format and mount again
|
||||||
if ( !Adafruit_LittleFS::begin() )
|
if ( format_fs || !Adafruit_LittleFS::begin() )
|
||||||
{
|
{
|
||||||
// lfs format
|
// lfs format
|
||||||
this->format();
|
this->format();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BU
|
|||||||
WRAPPER_CLASS radio_driver(radio, board);
|
WRAPPER_CLASS radio_driver(radio, board);
|
||||||
|
|
||||||
VolatileRTCClock rtc_clock;
|
VolatileRTCClock rtc_clock;
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||||
T1000SensorManager sensors = T1000SensorManager(nmea);
|
T1000SensorManager sensors = T1000SensorManager(nmea);
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ build_flags = ${stm32_base.build_flags}
|
|||||||
-I variants/wio-e5-mini
|
-I variants/wio-e5-mini
|
||||||
build_src_filter = ${stm32_base.build_src_filter}
|
build_src_filter = ${stm32_base.build_src_filter}
|
||||||
+<../variants/wio-e5-mini>
|
+<../variants/wio-e5-mini>
|
||||||
|
lib_deps = ${stm32_base.lib_deps}
|
||||||
|
finitespace/BME280 @ ^3.0.0
|
||||||
|
|
||||||
[env:wio-e5-mini-repeater]
|
[env:wio-e5-mini-repeater]
|
||||||
extends = lora_e5_mini
|
extends = lora_e5_mini
|
||||||
|
|||||||
@@ -18,20 +18,14 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
VolatileRTCClock rtc_clock;
|
VolatileRTCClock rtc_clock;
|
||||||
SensorManager sensors;
|
WIOE5SensorManager sensors;
|
||||||
|
|
||||||
#ifndef LORA_CR
|
#ifndef LORA_CR
|
||||||
#define LORA_CR 5
|
#define LORA_CR 5
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool radio_init() {
|
bool radio_init() {
|
||||||
// rtc_clock.begin(Wire);
|
Wire.begin();
|
||||||
|
|
||||||
// #ifdef SX126X_DIO3_TCXO_VOLTAGE
|
|
||||||
// float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
|
|
||||||
// #else
|
|
||||||
// float tcxo = 1.6f;
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
|
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
|
||||||
|
|
||||||
@@ -71,3 +65,26 @@ mesh::LocalIdentity radio_new_identity() {
|
|||||||
RadioNoiseListener rng(radio);
|
RadioNoiseListener rng(radio);
|
||||||
return mesh::LocalIdentity(&rng); // create new random identity
|
return mesh::LocalIdentity(&rng); // create new random identity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WIOE5SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
|
||||||
|
if (!has_bme) return false;
|
||||||
|
|
||||||
|
float temp(NAN), hum(NAN), pres(NAN);
|
||||||
|
|
||||||
|
BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
|
||||||
|
BME280::PresUnit presUnit(BME280::PresUnit_hPa);
|
||||||
|
|
||||||
|
bme.read(pres, temp, hum, tempUnit, presUnit);
|
||||||
|
|
||||||
|
telemetry.addTemperature(TELEM_CHANNEL_SELF, temp);
|
||||||
|
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF, hum);
|
||||||
|
telemetry.addBarometricPressure(TELEM_CHANNEL_SELF, pres);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WIOE5SensorManager::begin() {
|
||||||
|
has_bme = bme.begin();
|
||||||
|
|
||||||
|
return has_bme;
|
||||||
|
}
|
||||||
@@ -8,6 +8,9 @@
|
|||||||
#include <helpers/ArduinoHelpers.h>
|
#include <helpers/ArduinoHelpers.h>
|
||||||
#include <helpers/SensorManager.h>
|
#include <helpers/SensorManager.h>
|
||||||
|
|
||||||
|
#include <BME280I2C.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
class WIOE5Board : public STM32Board {
|
class WIOE5Board : public STM32Board {
|
||||||
public:
|
public:
|
||||||
const char* getManufacturerName() const override {
|
const char* getManufacturerName() const override {
|
||||||
@@ -21,10 +24,20 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class WIOE5SensorManager : public SensorManager {
|
||||||
|
BME280I2C bme;
|
||||||
|
bool has_bme = false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
WIOE5SensorManager() {}
|
||||||
|
bool begin() override;
|
||||||
|
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
|
||||||
|
};
|
||||||
|
|
||||||
extern WIOE5Board board;
|
extern WIOE5Board board;
|
||||||
extern WRAPPER_CLASS radio_driver;
|
extern WRAPPER_CLASS radio_driver;
|
||||||
extern VolatileRTCClock rtc_clock;
|
extern VolatileRTCClock rtc_clock;
|
||||||
extern SensorManager sensors;
|
extern WIOE5SensorManager sensors;
|
||||||
|
|
||||||
bool radio_init();
|
bool radio_init();
|
||||||
uint32_t radio_get_rng_seed();
|
uint32_t radio_get_rng_seed();
|
||||||
|
|||||||
Reference in New Issue
Block a user