Merge pull request #831 from Meshcore-Portugal/jbrazio/2025_87fe0ad8

Add bridge management CLI
This commit is contained in:
fdlamotte 2025-10-06 14:23:35 +02:00 committed by GitHub
commit 5f31979e1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 508 additions and 248 deletions

View file

@ -331,6 +331,12 @@ void MyMesh::logRxRaw(float snr, float rssi, const uint8_t raw[], int len) {
}
void MyMesh::logRx(mesh::Packet *pkt, int len, float score) {
#ifdef WITH_BRIDGE
if (_prefs.bridge_pkt_src == 1) {
bridge.sendPacket(pkt);
}
#endif
if (_logging) {
File f = openAppend(PACKET_LOG_FILE);
if (f) {
@ -352,8 +358,11 @@ void MyMesh::logRx(mesh::Packet *pkt, int len, float score) {
void MyMesh::logTx(mesh::Packet *pkt, int len) {
#ifdef WITH_BRIDGE
bridge.onPacketTransmitted(pkt);
if (_prefs.bridge_pkt_src == 0) {
bridge.sendPacket(pkt);
}
#endif
if (_logging) {
File f = openAppend(PACKET_LOG_FILE);
if (f) {
@ -582,9 +591,10 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
_cli(board, rtc, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4)
#if defined(WITH_RS232_BRIDGE)
, bridge(WITH_RS232_BRIDGE, _mgr, &rtc)
#elif defined(WITH_ESPNOW_BRIDGE)
, bridge(_mgr, &rtc)
, bridge(&_prefs, WITH_RS232_BRIDGE, _mgr, &rtc)
#endif
#if defined(WITH_ESPNOW_BRIDGE)
, bridge(&_prefs, _mgr, &rtc)
#endif
{
next_local_advert = next_flood_advert = 0;
@ -614,6 +624,14 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_prefs.flood_advert_interval = 12; // 12 hours
_prefs.flood_max = 64;
_prefs.interference_threshold = 0; // disabled
// bridge defaults
_prefs.bridge_enabled = 1; // enabled
_prefs.bridge_delay = 500; // milliseconds
_prefs.bridge_pkt_src = 0; // logTx
_prefs.bridge_baud = 115200; // baud rate
_prefs.bridge_channel = 1; // channel 1
StrHelper::strncpy(_prefs.bridge_secret, "LVSITANOS", sizeof(_prefs.bridge_secret));
}
void MyMesh::begin(FILESYSTEM *fs) {
@ -624,8 +642,10 @@ void MyMesh::begin(FILESYSTEM *fs) {
acl.load(_fs);
#ifdef WITH_BRIDGE
bridge.begin();
#if defined(WITH_BRIDGE)
if (_prefs.bridge_enabled) {
bridge.begin();
}
#endif
radio_set_params(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr);