Persist Companion TX preferences per contact and channel. Default repeater, room, and sensor replies to both active TX profiles, with a reply-only force option for an RX-only secondary profile. Track both reply copies before a temporary-radio handoff and account for OTA copies under queue backpressure. Add bridge/crossover filter modes and the third built-in wardriving filter, plus compact filter CLI syntax, documentation, and CI coverage. Fix quoted target names being interpreted as slot/key selectors, partial recovery of invalid saved reply settings, filter suspension during tempradio2, and unnecessary packet allocation while OTA traffic is throttled. Validation: 1,477 native tests, 52 Python integration tests, 29 filter UI tests, and five firmware builds covering ESP32, nRF52, and STM32 passed.
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
#include "BridgeBase.h"
|
|
|
|
#include <Arduino.h>
|
|
|
|
bool BridgeBase::isRunning() const {
|
|
return _initialized;
|
|
}
|
|
|
|
const char *BridgeBase::getLogDateTime() {
|
|
static char tmp[32];
|
|
uint32_t now = _rtc->getCurrentTime();
|
|
DateTime dt = DateTime(now);
|
|
sprintf(tmp, "%02d:%02d:%02d - %d/%d/%d U", dt.hour(), dt.minute(), dt.second(), dt.day(), dt.month(),
|
|
dt.year());
|
|
return tmp;
|
|
}
|
|
|
|
uint16_t BridgeBase::fletcher16(const uint8_t *data, size_t len) {
|
|
uint8_t sum1 = 0, sum2 = 0;
|
|
|
|
for (size_t i = 0; i < len; i++) {
|
|
sum1 = (sum1 + data[i]) % 255;
|
|
sum2 = (sum2 + sum1) % 255;
|
|
}
|
|
|
|
return (sum2 << 8) | sum1;
|
|
}
|
|
|
|
bool BridgeBase::validateChecksum(const uint8_t *data, size_t len, uint16_t received_checksum) {
|
|
uint16_t calculated_checksum = fletcher16(data, len);
|
|
return received_checksum == calculated_checksum;
|
|
}
|
|
|
|
void BridgeBase::handleReceivedPacket(mesh::Packet *packet) {
|
|
// Guard against uninitialized state
|
|
if (_initialized == false) {
|
|
BRIDGE_DEBUG_PRINTLN("RX packet received before initialization\n");
|
|
_mgr->free(packet);
|
|
return;
|
|
}
|
|
|
|
if (!allowsPacket(packet)) {
|
|
_mgr->free(packet);
|
|
return;
|
|
}
|
|
|
|
if (!_seen_packets.wasSeen(packet)) {
|
|
_seen_packets.markSeen(packet);
|
|
// bridge_delay provides a buffer to prevent immediate processing conflicts in the mesh network.
|
|
_mgr->queueInbound(packet, millis() + _prefs->bridge_delay);
|
|
} else {
|
|
_mgr->free(packet);
|
|
}
|
|
}
|