Add staggered transmit-only channel text beacons
This commit is contained in:
1 parent
8049754de9
commit
009bfff383
35 files changed
+3389
-19
No files matched your search
@@ -0,0 +1,30 @@
|
||||
#include "MyMesh.h"
|
||||
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
#include <helpers/BeaconManager.h>
|
||||
#include <new>
|
||||
|
||||
void MyMesh::beginBeacons() {
|
||||
auto* fs = _store->getPrimaryFS();
|
||||
if (_beacons || !fs || (!fs->exists("/beacons") && !fs->exists("/beacons.bak"))) return;
|
||||
_beacons = new (std::nothrow) mesh::BeaconManager;
|
||||
if (_beacons) _beacons->begin(fs, this, getRTCClock(), _prefs.node_name);
|
||||
}
|
||||
|
||||
void MyMesh::loopBeacons() { if (_beacons) _beacons->loop(millis()); }
|
||||
|
||||
void MyMesh::suspendBeacons() {
|
||||
if (_beacons) _beacons->suspend();
|
||||
cancelBeaconRadioFrame();
|
||||
}
|
||||
|
||||
bool MyMesh::handleBeaconCommand(const char* command, char* reply, size_t capacity) {
|
||||
if (!mesh::BeaconManager::isCommand(command)) return false;
|
||||
if (!_beacons) {
|
||||
_beacons = new (std::nothrow) mesh::BeaconManager;
|
||||
if (_beacons) _beacons->begin(_store->getPrimaryFS(), this, getRTCClock(), _prefs.node_name);
|
||||
}
|
||||
if (!_beacons) { snprintf(reply, capacity, "Error: beacon allocation failed"); return true; }
|
||||
return _beacons->handle(command, reply, capacity);
|
||||
}
|
||||
#endif
|
||||
@@ -3158,6 +3158,9 @@ void MyMesh::begin(bool has_display, bool radio_available,
|
||||
#endif
|
||||
|
||||
configureRadioFromPrefs();
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
beginBeacons();
|
||||
#endif
|
||||
#if MESH_ENABLE_MESHTEXT_CHAT
|
||||
beginMeshtext();
|
||||
#endif
|
||||
@@ -3688,6 +3691,9 @@ bool MyMesh::handleLocalControlCommand(const char* command, char* reply,
|
||||
}
|
||||
|
||||
if (handleTxRoutingCommand(command, reply, reply_size)) return true;
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
if (handleBeaconCommand(command, reply, reply_size)) return true;
|
||||
#endif
|
||||
#if MESH_ENABLE_MESHTEXT_CHAT
|
||||
if (handleMeshtextCommand(command, reply, reply_size)) return true;
|
||||
#endif
|
||||
@@ -7234,6 +7240,9 @@ void MyMesh::handleCmdFrame(size_t len) {
|
||||
MESH_DEBUG_PRINTLN("Factory reset: disabling serial interface to prevent reconnects (BLE/WiFi)");
|
||||
_serial->disable(); // Phone app disconnects before we can send OK frame so it's safe here
|
||||
}
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
suspendBeacons();
|
||||
#endif
|
||||
bool success = _store->formatFileSystem();
|
||||
if (success) {
|
||||
writeOKFrame();
|
||||
@@ -10030,6 +10039,10 @@ void MyMesh::handleTerminalCommand(char* command, bool reader_prompt,
|
||||
" board\r\n"
|
||||
" version\r\n");
|
||||
terminalOutput().print(" get storage.layout\r\n");
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
terminalOutput().print(" get beacon [slot] / set beacon <slot> <meshcore|meshtext> ...\r\n"
|
||||
" delete beacon <slot|all> / set beacon.interval <12|24|36|48> (default 24h)\r\n");
|
||||
#endif
|
||||
#if MESH_ENABLE_MESHTEXT_CHAT
|
||||
terminalOutput().print(" get mt.status / get mt.region / get mt.slot / get mt.hops\r\n"
|
||||
" get mt.node / get mt.shortname\r\n"
|
||||
@@ -10303,6 +10316,9 @@ bool MyMesh::handleDirectCommand(const char* command, char* reply, size_t reply_
|
||||
return true;
|
||||
}
|
||||
if (strcmp(command, "erase") == 0) {
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
suspendBeacons();
|
||||
#endif
|
||||
if (_store->formatFileSystem()) {
|
||||
stopContactsIterator();
|
||||
resetContacts();
|
||||
@@ -10836,6 +10852,9 @@ complete_line:
|
||||
scanInternalExtraFS(output);
|
||||
#endif
|
||||
} else if (strcmp(cli_command, "rebuild") == 0) {
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
suspendBeacons();
|
||||
#endif
|
||||
bool success = _store->formatFileSystem();
|
||||
if (success) {
|
||||
const bool identity_saved = _store->saveMainIdentity(self_id);
|
||||
@@ -10862,6 +10881,9 @@ complete_line:
|
||||
output.println(" Error: erase failed");
|
||||
}
|
||||
} else if (strcmp(cli_command, "erase") == 0) {
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
suspendBeacons();
|
||||
#endif
|
||||
bool success = _store->formatFileSystem();
|
||||
#if MESH_ENABLE_MESHTEXT_CHAT
|
||||
if (success && !eraseMeshtextSettings()) {
|
||||
@@ -11119,6 +11141,9 @@ void MyMesh::loop() {
|
||||
#endif
|
||||
|
||||
if (!mesh::morseTimingActive(_radio)) _radio_profiles.loop();
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
if (!mesh::morseTimingActive(_radio)) loopBeacons();
|
||||
#endif
|
||||
#if MESH_ENABLE_MESHTEXT_CHAT
|
||||
refreshMeshtextProfile();
|
||||
#endif
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <helpers/RadioProfileCLI.h>
|
||||
#include <helpers/MorseReplyHandoff.h>
|
||||
#include <helpers/MeshtextConfig.h>
|
||||
namespace mesh { class BeaconManager; }
|
||||
#if MESH_ENABLE_MESHTEXT_CHAT
|
||||
#include <helpers/CompanionMeshtextChannel.h>
|
||||
#endif
|
||||
@@ -985,6 +986,13 @@ private:
|
||||
|
||||
void checkControlDataForPendingDiscovery(uint8_t payload[], size_t p_len);
|
||||
#endif
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
mesh::BeaconManager* _beacons = nullptr;
|
||||
void beginBeacons();
|
||||
void loopBeacons();
|
||||
void suspendBeacons();
|
||||
bool handleBeaconCommand(const char* command, char* reply, size_t capacity);
|
||||
#endif
|
||||
};
|
||||
|
||||
extern MyMesh the_mesh;
|
||||
Reference in new issue
Block a user