mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* more experiments
This commit is contained in:
parent
7bd7bfb14a
commit
8355543366
6 changed files with 112 additions and 7 deletions
|
|
@ -7,8 +7,11 @@
|
|||
#include <SPIFFS.h>
|
||||
#endif
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#endif
|
||||
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/StaticPoolPacketManager.h>
|
||||
#include <helpers/SimpleMeshTables.h>
|
||||
|
|
@ -141,9 +144,13 @@ struct ServerStats {
|
|||
};
|
||||
|
||||
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
||||
RadioLibWrapper* my_radio;
|
||||
FILESYSTEM* _fs;
|
||||
#ifdef WRAPPER_CLASS
|
||||
RadioLibWrapper* my_radio;
|
||||
RADIO_CLASS* _phy;
|
||||
#else
|
||||
ESPNOWRadio* my_radio;
|
||||
#endif
|
||||
mesh::MainBoard* _board;
|
||||
unsigned long next_local_advert, next_flood_advert;
|
||||
NodePrefs _prefs;
|
||||
|
|
@ -593,9 +600,15 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
#ifdef WRAPPER_CLASS
|
||||
MyMesh(RADIO_CLASS& phy, mesh::MainBoard& board, RadioLibWrapper& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables)
|
||||
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
||||
_phy(&phy), _board(&board), _cli(board, this, &_prefs, this)
|
||||
#else
|
||||
MyMesh(mesh::MainBoard& board, ESPNOWRadio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables)
|
||||
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
||||
_board(&board), _cli(board, this, &_prefs, this)
|
||||
#endif
|
||||
{
|
||||
my_radio = &radio;
|
||||
next_local_advert = next_flood_advert = 0;
|
||||
|
|
@ -638,11 +651,13 @@ public:
|
|||
// load persisted prefs
|
||||
_cli.loadPrefs(_fs);
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
_phy->setFrequency(_prefs.freq);
|
||||
_phy->setSpreadingFactor(_prefs.sf);
|
||||
_phy->setBandwidth(_prefs.bw);
|
||||
_phy->setCodingRate(_prefs.cr);
|
||||
_phy->setOutputPower(_prefs.tx_power_dbm);
|
||||
#endif
|
||||
|
||||
updateAdvertTimer();
|
||||
}
|
||||
|
|
@ -695,7 +710,9 @@ public:
|
|||
void dumpLogFile() override { /* no-op */ }
|
||||
|
||||
void setTxPower(uint8_t power_dbm) override {
|
||||
#ifdef WRAPPER_CLASS
|
||||
_phy->setOutputPower(power_dbm);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
@ -764,7 +781,11 @@ VolatileRTCClock fallback_clock;
|
|||
#endif
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
MyMesh the_mesh(radio, board, *new WRAPPER_CLASS(radio, board), *new ArduinoMillis(), fast_rng, rtc_clock, tables);
|
||||
#else
|
||||
MyMesh the_mesh(board, radio, *new ArduinoMillis(), fast_rng, rtc_clock, tables);
|
||||
#endif
|
||||
|
||||
void halt() {
|
||||
while (1) ;
|
||||
|
|
@ -784,7 +805,11 @@ void setup() {
|
|||
|
||||
if (!radio_init()) { halt(); }
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
fast_rng.begin(radio.random(0x7FFFFFFF));
|
||||
#else
|
||||
fast_rng.begin(radio.intID());
|
||||
#endif
|
||||
|
||||
FILESYSTEM* fs;
|
||||
#if defined(NRF52_PLATFORM)
|
||||
|
|
@ -799,7 +824,11 @@ void setup() {
|
|||
#error "need to define filesystem"
|
||||
#endif
|
||||
if (!store.load("_main", the_mesh.self_id)) {
|
||||
#ifdef WRAPPER_CLASS
|
||||
RadioNoiseListener rng(radio);
|
||||
#else
|
||||
#define rng fast_rng
|
||||
#endif
|
||||
the_mesh.self_id = mesh::LocalIdentity(&rng); // create new random identity
|
||||
store.save("_main", the_mesh.self_id);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue