mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 19:15:49 +00:00
* new ESPNOWRadio driver
* refactored the examples/*/main.cpp modules, moving radio specifics to variants/*/target modules * new Generic_ESPNOW_* target envs
This commit is contained in:
@@ -7,9 +7,6 @@
|
||||
#include <SPIFFS.h>
|
||||
#endif
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/StaticPoolPacketManager.h>
|
||||
#include <helpers/SimpleMeshTables.h>
|
||||
@@ -197,7 +194,6 @@ struct NodePrefs { // persisted to file
|
||||
|
||||
class MyMesh : public BaseChatMesh {
|
||||
FILESYSTEM* _fs;
|
||||
RADIO_CLASS* _phy;
|
||||
IdentityStore* _identity_store;
|
||||
NodePrefs _prefs;
|
||||
uint32_t pending_login;
|
||||
@@ -229,9 +225,9 @@ class MyMesh : public BaseChatMesh {
|
||||
AckTableEntry expected_ack_table[EXPECTED_ACK_TABLE_SIZE]; // circular table
|
||||
int next_ack_idx;
|
||||
|
||||
void loadMainIdentity(mesh::RNG& trng) {
|
||||
void loadMainIdentity() {
|
||||
if (!_identity_store->load("_main", self_id)) {
|
||||
self_id = mesh::LocalIdentity(&trng); // create new random identity
|
||||
self_id = radio_new_identity(); // create new random identity
|
||||
saveMainIdentity(self_id);
|
||||
}
|
||||
}
|
||||
@@ -709,8 +705,8 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
MyMesh(RADIO_CLASS& phy, RadioLibWrapper& rw, mesh::RNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables)
|
||||
: BaseChatMesh(rw, *new ArduinoMillis(), rng, rtc, *new StaticPoolPacketManager(16), tables), _serial(NULL), _phy(&phy)
|
||||
MyMesh(mesh::Radio& radio, mesh::RNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables)
|
||||
: BaseChatMesh(radio, *new ArduinoMillis(), rng, rtc, *new StaticPoolPacketManager(16), tables), _serial(NULL)
|
||||
{
|
||||
_iter_started = false;
|
||||
offline_queue_len = 0;
|
||||
@@ -767,7 +763,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void begin(FILESYSTEM& fs, mesh::RNG& trng, bool has_display) {
|
||||
void begin(FILESYSTEM& fs, bool has_display) {
|
||||
_fs = &fs;
|
||||
|
||||
BaseChatMesh::begin();
|
||||
@@ -778,7 +774,7 @@ public:
|
||||
_identity_store = new IdentityStore(fs, "/identity");
|
||||
#endif
|
||||
|
||||
loadMainIdentity(trng);
|
||||
loadMainIdentity();
|
||||
|
||||
// load persisted prefs
|
||||
if (_fs->exists("/new_prefs")) {
|
||||
@@ -793,7 +789,8 @@ public:
|
||||
if (_prefs.ble_pin == 0) {
|
||||
#ifdef HAS_UI
|
||||
if (has_display) {
|
||||
_active_ble_pin = trng.nextInt(100000, 999999); // random pin each session
|
||||
StdRNG rng;
|
||||
_active_ble_pin = rng.nextInt(100000, 999999); // random pin each session
|
||||
} else {
|
||||
_active_ble_pin = BLE_PIN_CODE; // otherwise static pin
|
||||
}
|
||||
@@ -814,11 +811,8 @@ public:
|
||||
addChannel("Public", PUBLIC_GROUP_PSK); // pre-configure Andy's public channel
|
||||
loadChannels();
|
||||
|
||||
_phy->setFrequency(_prefs.freq);
|
||||
_phy->setSpreadingFactor(_prefs.sf);
|
||||
_phy->setBandwidth(_prefs.bw);
|
||||
_phy->setCodingRate(_prefs.cr);
|
||||
_phy->setOutputPower(_prefs.tx_power_dbm);
|
||||
radio_set_params(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr);
|
||||
radio_set_tx_power(_prefs.tx_power_dbm);
|
||||
}
|
||||
|
||||
const char* getNodeName() { return _prefs.node_name; }
|
||||
@@ -1153,10 +1147,7 @@ public:
|
||||
_prefs.bw = (float)bw / 1000.0;
|
||||
savePrefs();
|
||||
|
||||
_phy->setFrequency(_prefs.freq);
|
||||
_phy->setSpreadingFactor(_prefs.sf);
|
||||
_phy->setBandwidth(_prefs.bw);
|
||||
_phy->setCodingRate(_prefs.cr);
|
||||
radio_set_params(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr);
|
||||
MESH_DEBUG_PRINTLN("OK: CMD_SET_RADIO_PARAMS: f=%d, bw=%d, sf=%d, cr=%d", freq, bw, (uint32_t)sf, (uint32_t)cr);
|
||||
|
||||
writeOKFrame();
|
||||
@@ -1170,7 +1161,7 @@ public:
|
||||
} else {
|
||||
_prefs.tx_power_dbm = cmd_frame[1];
|
||||
savePrefs();
|
||||
_phy->setOutputPower(_prefs.tx_power_dbm);
|
||||
radio_set_tx_power(_prefs.tx_power_dbm);
|
||||
writeOKFrame();
|
||||
}
|
||||
} else if (cmd_frame[0] == CMD_SET_TUNING_PARAMS) {
|
||||
@@ -1431,7 +1422,7 @@ public:
|
||||
|
||||
StdRNG fast_rng;
|
||||
SimpleMeshTables tables;
|
||||
MyMesh the_mesh(radio, *new WRAPPER_CLASS(radio, board), fast_rng, *new VolatileRTCClock(), tables);
|
||||
MyMesh the_mesh(radio_driver, fast_rng, *new VolatileRTCClock(), tables);
|
||||
|
||||
void halt() {
|
||||
while (1) ;
|
||||
@@ -1444,9 +1435,7 @@ void setup() {
|
||||
|
||||
if (!radio_init()) { halt(); }
|
||||
|
||||
fast_rng.begin(radio.random(0x7FFFFFFF));
|
||||
|
||||
RadioNoiseListener trng(radio);
|
||||
fast_rng.begin(radio_get_rng_seed());
|
||||
|
||||
#ifdef HAS_UI
|
||||
DisplayDriver* disp = NULL;
|
||||
@@ -1459,7 +1448,7 @@ void setup() {
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
InternalFS.begin();
|
||||
the_mesh.begin(InternalFS, trng,
|
||||
the_mesh.begin(InternalFS,
|
||||
#ifdef HAS_UI
|
||||
disp != NULL
|
||||
#else
|
||||
@@ -1477,7 +1466,7 @@ void setup() {
|
||||
the_mesh.startInterface(serial_interface);
|
||||
#elif defined(ESP32)
|
||||
SPIFFS.begin(true);
|
||||
the_mesh.begin(SPIFFS, trng,
|
||||
the_mesh.begin(SPIFFS,
|
||||
#ifdef HAS_UI
|
||||
disp != NULL
|
||||
#else
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
#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>
|
||||
@@ -112,13 +107,6 @@ struct ClientInfo {
|
||||
|
||||
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
||||
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;
|
||||
bool _logging;
|
||||
NodePrefs _prefs;
|
||||
@@ -154,9 +142,9 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
||||
stats.batt_milli_volts = board.getBattMilliVolts();
|
||||
stats.curr_tx_queue_len = _mgr->getOutboundCount();
|
||||
stats.curr_free_queue_len = _mgr->getFreeCount();
|
||||
stats.last_rssi = (int16_t) my_radio->getLastRSSI();
|
||||
stats.n_packets_recv = my_radio->getPacketsRecv();
|
||||
stats.n_packets_sent = my_radio->getPacketsSent();
|
||||
stats.last_rssi = (int16_t) radio_driver.getLastRSSI();
|
||||
stats.n_packets_recv = radio_driver.getPacketsRecv();
|
||||
stats.n_packets_sent = radio_driver.getPacketsSent();
|
||||
stats.total_air_time_secs = getTotalAirTime() / 1000;
|
||||
stats.total_up_time_secs = _ms->getMillis() / 1000;
|
||||
stats.n_sent_flood = getNumSentFlood();
|
||||
@@ -164,7 +152,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
||||
stats.n_recv_flood = getNumRecvFlood();
|
||||
stats.n_recv_direct = getNumRecvDirect();
|
||||
stats.n_full_events = getNumFullEvents();
|
||||
stats.last_snr = (int16_t)(my_radio->getLastSNR() * 4);
|
||||
stats.last_snr = (int16_t)(radio_driver.getLastSNR() * 4);
|
||||
stats.n_direct_dups = ((SimpleMeshTables *)getTables())->getNumDirectDups();
|
||||
stats.n_flood_dups = ((SimpleMeshTables *)getTables())->getNumFloodDups();
|
||||
|
||||
@@ -481,17 +469,10 @@ 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)
|
||||
MyMesh(mesh::MainBoard& board, mesh::Radio& 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
|
||||
_cli(board, this, &_prefs, this)
|
||||
{
|
||||
my_radio = &radio;
|
||||
memset(known_clients, 0, sizeof(known_clients));
|
||||
next_local_advert = next_flood_advert = 0;
|
||||
_logging = false;
|
||||
@@ -523,13 +504,8 @@ 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
|
||||
radio_set_params(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr);
|
||||
radio_set_tx_power(_prefs.tx_power_dbm);
|
||||
|
||||
updateAdvertTimer();
|
||||
updateFloodAdvertTimer();
|
||||
@@ -597,9 +573,7 @@ public:
|
||||
}
|
||||
|
||||
void setTxPower(uint8_t power_dbm) override {
|
||||
#ifdef WRAPPER_CLASS
|
||||
_phy->setOutputPower(power_dbm);
|
||||
#endif
|
||||
radio_set_tx_power(power_dbm);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -633,11 +607,7 @@ 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
|
||||
MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables);
|
||||
|
||||
void halt() {
|
||||
while (1) ;
|
||||
@@ -657,11 +627,7 @@ void setup() {
|
||||
|
||||
if (!radio_init()) { halt(); }
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
fast_rng.begin(radio.random(0x7FFFFFFF));
|
||||
#else
|
||||
fast_rng.begin(radio.intID());
|
||||
#endif
|
||||
fast_rng.begin(radio_get_rng_seed());
|
||||
|
||||
FILESYSTEM* fs;
|
||||
#if defined(NRF52_PLATFORM)
|
||||
@@ -677,12 +643,7 @@ void setup() {
|
||||
#endif
|
||||
if (!store.load("_main", the_mesh.self_id)) {
|
||||
MESH_DEBUG_PRINTLN("Generating new keypair");
|
||||
#ifdef WRAPPER_CLASS
|
||||
RadioNoiseListener rng(radio);
|
||||
#else
|
||||
#define rng fast_rng
|
||||
#endif
|
||||
the_mesh.self_id = mesh::LocalIdentity(&rng); // create new random identity
|
||||
the_mesh.self_id = radio_new_identity(); // create new random identity
|
||||
store.save("_main", the_mesh.self_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
#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>
|
||||
@@ -147,13 +142,6 @@ struct ServerStats {
|
||||
|
||||
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
||||
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;
|
||||
bool _logging;
|
||||
NodePrefs _prefs;
|
||||
@@ -591,9 +579,9 @@ protected:
|
||||
stats.batt_milli_volts = board.getBattMilliVolts();
|
||||
stats.curr_tx_queue_len = _mgr->getOutboundCount();
|
||||
stats.curr_free_queue_len = _mgr->getFreeCount();
|
||||
stats.last_rssi = (int16_t) my_radio->getLastRSSI();
|
||||
stats.n_packets_recv = my_radio->getPacketsRecv();
|
||||
stats.n_packets_sent = my_radio->getPacketsSent();
|
||||
stats.last_rssi = (int16_t) radio_driver.getLastRSSI();
|
||||
stats.n_packets_recv = radio_driver.getPacketsRecv();
|
||||
stats.n_packets_sent = radio_driver.getPacketsSent();
|
||||
stats.total_air_time_secs = getTotalAirTime() / 1000;
|
||||
stats.total_up_time_secs = _ms->getMillis() / 1000;
|
||||
stats.n_sent_flood = getNumSentFlood();
|
||||
@@ -601,7 +589,7 @@ protected:
|
||||
stats.n_recv_flood = getNumRecvFlood();
|
||||
stats.n_recv_direct = getNumRecvDirect();
|
||||
stats.n_full_events = getNumFullEvents();
|
||||
stats.last_snr = (int16_t)(my_radio->getLastSNR() * 4);
|
||||
stats.last_snr = (int16_t)(radio_driver.getLastSNR() * 4);
|
||||
stats.n_direct_dups = ((SimpleMeshTables *)getTables())->getNumDirectDups();
|
||||
stats.n_flood_dups = ((SimpleMeshTables *)getTables())->getNumFloodDups();
|
||||
stats.n_posted = _num_posted;
|
||||
@@ -660,17 +648,10 @@ 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)
|
||||
MyMesh(mesh::MainBoard& board, mesh::Radio& 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
|
||||
_cli(board, this, &_prefs, this)
|
||||
{
|
||||
my_radio = &radio;
|
||||
next_local_advert = next_flood_advert = 0;
|
||||
_logging = false;
|
||||
|
||||
@@ -712,15 +693,11 @@ 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
|
||||
radio_set_params(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr);
|
||||
radio_set_tx_power(_prefs.tx_power_dbm);
|
||||
|
||||
updateAdvertTimer();
|
||||
updateFloodAdvertTimer();
|
||||
}
|
||||
|
||||
const char* getFirmwareVer() override { return FIRMWARE_VERSION; }
|
||||
@@ -785,9 +762,7 @@ public:
|
||||
}
|
||||
|
||||
void setTxPower(uint8_t power_dbm) override {
|
||||
#ifdef WRAPPER_CLASS
|
||||
_phy->setOutputPower(power_dbm);
|
||||
#endif
|
||||
radio_set_tx_power(power_dbm);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -856,11 +831,7 @@ 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
|
||||
MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock, tables);
|
||||
|
||||
void halt() {
|
||||
while (1) ;
|
||||
@@ -880,11 +851,7 @@ void setup() {
|
||||
|
||||
if (!radio_init()) { halt(); }
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
fast_rng.begin(radio.random(0x7FFFFFFF));
|
||||
#else
|
||||
fast_rng.begin(radio.intID());
|
||||
#endif
|
||||
fast_rng.begin(radio_get_rng_seed());
|
||||
|
||||
FILESYSTEM* fs;
|
||||
#if defined(NRF52_PLATFORM)
|
||||
@@ -899,12 +866,7 @@ 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
|
||||
the_mesh.self_id = radio_new_identity(); // create new random identity
|
||||
store.save("_main", the_mesh.self_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,6 @@
|
||||
#include <SPIFFS.h>
|
||||
#endif
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#endif
|
||||
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/StaticPoolPacketManager.h>
|
||||
#include <helpers/SimpleMeshTables.h>
|
||||
@@ -269,12 +263,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
MyMesh(RadioLibWrapper& radio, StdRNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables)
|
||||
#else
|
||||
MyMesh(mesh::Radio& radio, StdRNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables)
|
||||
#endif
|
||||
: BaseChatMesh(radio, *new ArduinoMillis(), rng, rtc, *new StaticPoolPacketManager(16), tables)
|
||||
{
|
||||
// defaults
|
||||
@@ -534,12 +523,7 @@ public:
|
||||
|
||||
StdRNG fast_rng;
|
||||
SimpleMeshTables tables;
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
MyMesh the_mesh(*new WRAPPER_CLASS(radio, board), fast_rng, *new VolatileRTCClock(), tables);
|
||||
#else
|
||||
MyMesh the_mesh(radio, fast_rng, *new VolatileRTCClock(), tables);
|
||||
#endif
|
||||
MyMesh the_mesh(radio_driver, fast_rng, *new VolatileRTCClock(), tables);
|
||||
|
||||
void halt() {
|
||||
while (1) ;
|
||||
@@ -552,11 +536,7 @@ void setup() {
|
||||
|
||||
if (!radio_init()) { halt(); }
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
fast_rng.begin(radio.random(0x7FFFFFFF));
|
||||
#else
|
||||
fast_rng.begin(millis());
|
||||
#endif
|
||||
fast_rng.begin(radio_get_rng_seed());
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
InternalFS.begin();
|
||||
@@ -568,14 +548,8 @@ void setup() {
|
||||
#error "need to define filesystem"
|
||||
#endif
|
||||
|
||||
#ifdef WRAPPER_CLASS
|
||||
if (LORA_FREQ != the_mesh.getFreqPref()) {
|
||||
radio.setFrequency(the_mesh.getFreqPref());
|
||||
}
|
||||
if (LORA_TX_POWER != the_mesh.getTxPowerPref()) {
|
||||
radio.setOutputPower(the_mesh.getTxPowerPref());
|
||||
}
|
||||
#endif
|
||||
radio_set_params(the_mesh.getFreqPref(), LORA_BW, LORA_SF, LORA_CR);
|
||||
radio_set_tx_power(the_mesh.getTxPowerPref());
|
||||
|
||||
the_mesh.showWelcome();
|
||||
|
||||
|
||||
@@ -34,7 +34,9 @@ public:
|
||||
#endif
|
||||
|
||||
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
|
||||
#if PIN_BOARD_SDA >= 0 && PIN_BOARD_SCL >= 0
|
||||
Wire.begin(PIN_BOARD_SDA, PIN_BOARD_SCL);
|
||||
#endif
|
||||
#else
|
||||
Wire.begin();
|
||||
#endif
|
||||
|
||||
@@ -50,6 +50,10 @@ void ESPNOWRadio::begin() {
|
||||
}
|
||||
}
|
||||
|
||||
void ESPNOWRadio::setTxPower(uint8_t dbm) {
|
||||
esp_wifi_set_max_tx_power(dbm * 4);
|
||||
}
|
||||
|
||||
uint32_t ESPNOWRadio::intID() {
|
||||
uint8_t mac[8];
|
||||
memset(mac, 0, sizeof(mac));
|
||||
@@ -58,7 +62,7 @@ uint32_t ESPNOWRadio::intID() {
|
||||
memcpy(&n, &mac[0], 4);
|
||||
memcpy(&m, &mac[4], 4);
|
||||
|
||||
return n * m;
|
||||
return n + m;
|
||||
}
|
||||
|
||||
void ESPNOWRadio::startSendRaw(const uint8_t* bytes, int len) {
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
|
||||
float packetScore(float snr, int packet_len) override { return 0; }
|
||||
uint32_t intID();
|
||||
void setTxPower(uint8_t dbm);
|
||||
};
|
||||
|
||||
#if ESPNOW_DEBUG_LOGGING && ARDUINO
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
|
||||
; ----------- Generic ESP32-C3 ------------
|
||||
|
||||
[env:Generic_C3_ESPNOW_terminal_chat]
|
||||
extends = esp32_base
|
||||
;board = esp32-c3-devkitm-1
|
||||
board = esp32-s3-devkitc-1
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-I variants/espnow_c3
|
||||
; -D ARDUINO_USB_MODE=1
|
||||
; -D ARDUINO_USB_CDC_ON_BOOT=1
|
||||
; -D ESP32_CPU_FREQ=80
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=1
|
||||
; -D ESPNOW_DEBUG_LOGGING=1
|
||||
; -D P_LORA_TX_LED=8
|
||||
-D P_LORA_TX_LED=35
|
||||
-D PIN_USER_BTN=0
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../examples/simple_secure_chat/main.cpp>
|
||||
+<helpers/esp32/ESPNowRadio.cpp>
|
||||
+<../variants/espnow_c3>
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Generic_C3_ESPNOW_repeater]
|
||||
extends = esp32_base
|
||||
board = esp32-c3-devkitm-1
|
||||
;board = esp32-s3-devkitc-1
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-I variants/espnow_c3
|
||||
-D ARDUINO_USB_MODE=1
|
||||
-D ARDUINO_USB_CDC_ON_BOOT=1
|
||||
-D ESP32_CPU_FREQ=80
|
||||
-D ESPNOW_DEBUG_LOGGING=1
|
||||
; -D P_LORA_TX_LED=8
|
||||
; -D P_LORA_TX_LED=35
|
||||
-D PIN_USER_BTN=0
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D ADVERT_NAME='"ESPNOW Repeater"'
|
||||
-D ADVERT_LAT=-37.0
|
||||
-D ADVERT_LON=145.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../examples/simple_repeater/main.cpp>
|
||||
+<helpers/esp32/ESPNowRadio.cpp>
|
||||
+<../variants/espnow_c3>
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
@@ -1,11 +0,0 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
|
||||
ESP32Board board;
|
||||
|
||||
ESPNOWRadio radio;
|
||||
|
||||
bool radio_init() {
|
||||
// NOTE: radio.begin() is called by Dispatcher::begin(), so not needed here
|
||||
return true; // success
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <helpers/esp32/ESPNOWRadio.h>
|
||||
|
||||
extern ESP32Board board;
|
||||
extern ESPNOWRadio radio;
|
||||
|
||||
bool radio_init();
|
||||
83
variants/generic_espnow/platformio.ini
Normal file
83
variants/generic_espnow/platformio.ini
Normal file
@@ -0,0 +1,83 @@
|
||||
|
||||
; ----------- Generic ESP32-C3 ------------
|
||||
|
||||
[Generic_ESPNOW]
|
||||
extends = esp32_base
|
||||
board = esp32-c3-devkitm-1
|
||||
;board = esp32-s3-devkitm-1
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-I variants/generic_espnow
|
||||
; -D ESP32_CPU_FREQ=80
|
||||
-D PIN_BOARD_SDA=-1
|
||||
-D PIN_BOARD_SCL=-1
|
||||
; -D P_LORA_TX_LED=8
|
||||
-D PIN_USER_BTN=0
|
||||
; -D ARDUINO_USB_MODE=1
|
||||
; -D ARDUINO_USB_CDC_ON_BOOT=1
|
||||
; -D ESPNOW_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<helpers/esp32/ESPNowRadio.cpp>
|
||||
+<../variants/generic_espnow>
|
||||
|
||||
[env:Generic_ESPNOW_terminal_chat]
|
||||
extends = Generic_ESPNOW
|
||||
build_flags =
|
||||
${Generic_ESPNOW.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=1
|
||||
build_src_filter = ${Generic_ESPNOW.build_src_filter}
|
||||
+<../examples/simple_secure_chat/main.cpp>
|
||||
lib_deps =
|
||||
${Generic_ESPNOW.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Generic_ESPNOW_repeater]
|
||||
extends = Generic_ESPNOW
|
||||
build_flags =
|
||||
${Generic_ESPNOW.build_flags}
|
||||
-D ADVERT_NAME='"ESPNOW Repeater"'
|
||||
-D ADVERT_LAT=-37.0
|
||||
-D ADVERT_LON=145.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
build_src_filter = ${Generic_ESPNOW.build_src_filter}
|
||||
+<../examples/simple_repeater/main.cpp>
|
||||
lib_deps =
|
||||
${Generic_ESPNOW.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Generic_ESPNOW_companion_radio_usb]
|
||||
extends = Generic_ESPNOW
|
||||
build_flags =
|
||||
${Generic_ESPNOW.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
; -D ENABLE_PRIVATE_KEY_IMPORT=1
|
||||
; -D ENABLE_PRIVATE_KEY_EXPORT=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||
; NOTE: DO NOT ENABLE --> -D ESPNOW_DEBUG_LOGGING=1
|
||||
build_src_filter = ${Generic_ESPNOW.build_src_filter}
|
||||
+<../examples/companion_radio/main.cpp>
|
||||
lib_deps =
|
||||
${Generic_ESPNOW.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Generic_ESPNOW_room_server]
|
||||
extends = Generic_ESPNOW
|
||||
build_flags =
|
||||
${Generic_ESPNOW.build_flags}
|
||||
-D ADVERT_NAME='"Heltec Room"'
|
||||
-D ADVERT_LAT=-37.0
|
||||
-D ADVERT_LON=145.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
build_src_filter = ${Generic_ESPNOW.build_src_filter}
|
||||
+<../examples/simple_room_server/main.cpp>
|
||||
lib_deps =
|
||||
${Generic_ESPNOW.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
29
variants/generic_espnow/target.cpp
Normal file
29
variants/generic_espnow/target.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
|
||||
ESP32Board board;
|
||||
|
||||
ESPNOWRadio radio_driver;
|
||||
|
||||
bool radio_init() {
|
||||
// NOTE: radio_driver.begin() is called by Dispatcher::begin(), so not needed here
|
||||
return true; // success
|
||||
}
|
||||
|
||||
uint32_t radio_get_rng_seed() {
|
||||
return millis() + radio_driver.intID(); // TODO: where to get some entropy?
|
||||
}
|
||||
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
void radio_set_tx_power(uint8_t dbm) {
|
||||
radio_driver.setTxPower(dbm);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
StdRNG rng; // TODO: need stronger True-RNG here
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
13
variants/generic_espnow/target.h
Normal file
13
variants/generic_espnow/target.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <helpers/esp32/ESPNOWRadio.h>
|
||||
|
||||
extern ESP32Board board;
|
||||
extern ESPNOWRadio radio_driver;
|
||||
|
||||
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,6 +10,8 @@ HeltecV2Board board;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -29,3 +31,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/HeltecV2Board.h>
|
||||
#include <helpers/CustomSX1276Wrapper.h>
|
||||
|
||||
extern HeltecV2Board board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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,6 +10,8 @@ HeltecV3Board board;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -45,3 +47,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/HeltecV3Board.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
|
||||
extern HeltecV3Board board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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,6 +10,8 @@ ESP32Board board;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -45,3 +47,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
|
||||
extern ESP32Board board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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,6 +10,8 @@ TBeamBoard board;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -29,3 +31,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/TBeamBoard.h>
|
||||
#include <helpers/CustomSX1276Wrapper.h>
|
||||
|
||||
extern TBeamBoard board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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();
|
||||
|
||||
@@ -6,6 +6,8 @@ LilyGoTLoraBoard board;
|
||||
static SPIClass spi;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -23,3 +25,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/LilyGoTLoraBoard.h>
|
||||
#include <helpers/CustomSX1276Wrapper.h>
|
||||
|
||||
extern LilyGoTLoraBoard board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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();
|
||||
|
||||
@@ -5,6 +5,8 @@ FaketecBoard 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);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -44,3 +46,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/nrf52/FaketecBoard.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/CustomLLCC68Wrapper.h>
|
||||
|
||||
extern FaketecBoard board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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();
|
||||
|
||||
@@ -5,6 +5,8 @@ RAK4631Board 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);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -39,3 +41,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/nrf52/RAK4631Board.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
|
||||
extern RAK4631Board board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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,6 +10,8 @@ StationG2Board board;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -45,3 +47,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/StationG2Board.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
|
||||
extern StationG2Board board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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();
|
||||
|
||||
@@ -5,6 +5,8 @@ T1000eBoard 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);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -58,3 +60,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/nrf52/T1000eBoard.h>
|
||||
#include <helpers/CustomLR1110Wrapper.h>
|
||||
|
||||
extern T1000eBoard board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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();
|
||||
|
||||
@@ -5,6 +5,8 @@ T114Board 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);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -39,3 +41,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/nrf52/T114Board.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
|
||||
extern T114Board board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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();
|
||||
|
||||
@@ -5,6 +5,8 @@ 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);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -39,3 +41,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/nrf52/TechoBoard.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
|
||||
extern TechoBoard board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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,6 +10,8 @@ XiaoC3Board board;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -45,3 +47,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/XiaoC3Board.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
#include <helpers/CustomSX1268Wrapper.h>
|
||||
|
||||
extern XiaoC3Board board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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,6 +10,8 @@ ESP32Board board;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
@@ -45,3 +47,23 @@ bool radio_init() {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <helpers/CustomSX1262Wrapper.h>
|
||||
|
||||
extern ESP32Board board;
|
||||
extern RADIO_CLASS radio;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user