feat: add Bluetooth-controlled LoRa OTA
Add the framed BLE mOTA transport and companion control path, complete the full-profile build and runtime fixes, and document and test the OTA workflow.
This commit is contained in:
1 parent
91870e4bb0
commit
e5fd77e53f
79 files changed
+3178
-304
No files matched your search
@@ -664,7 +664,7 @@ uint8_t MyMesh::handleAnonClockReq(const mesh::Identity& sender, uint32_t sender
|
||||
memcpy(&reply_data[4], &now, 4); // include our clock (for easy clock sync, and packet hash uniqueness)
|
||||
reply_data[8] = 0; // features
|
||||
#ifdef WITH_RS232_BRIDGE
|
||||
reply_data[8] |= 0x01; // is bridge, type UART
|
||||
if (_prefs.bridge_enabled) reply_data[8] |= 0x01; // is bridge, type UART
|
||||
#elif WITH_ESPNOW_BRIDGE
|
||||
reply_data[8] |= 0x03; // is bridge, type ESP-NOW
|
||||
#endif
|
||||
@@ -3161,7 +3161,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
||||
#if defined(WITH_MQTT_BRIDGE)
|
||||
, mqtt_bridge(nullptr)
|
||||
#elif defined(WITH_RS232_BRIDGE)
|
||||
, bridge(&_prefs, WITH_RS232_BRIDGE, _mgr, &rtc)
|
||||
, bridge(nullptr)
|
||||
#elif defined(WITH_ESPNOW_BRIDGE)
|
||||
, bridge(&_prefs, _mgr, &rtc)
|
||||
#endif
|
||||
@@ -3335,11 +3335,21 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
||||
&_prefs.rx_ps_sleep_us);
|
||||
|
||||
// bridge defaults
|
||||
#if defined(WITH_RS232_BRIDGE) && defined(RS232_BRIDGE_MERGED) \
|
||||
&& !defined(RS232_BRIDGE_DEFAULT_ON)
|
||||
_prefs.bridge_enabled = 0; // normal repeater until explicitly enabled
|
||||
#else
|
||||
_prefs.bridge_enabled = 1; // enabled
|
||||
#endif
|
||||
_prefs.bridge_delay = 500; // milliseconds
|
||||
_prefs.bridge_pkt_src = 1; // logRx (RX packets)
|
||||
_prefs.bridge_baud = 115200; // baud rate
|
||||
_prefs.bridge_channel = 1; // channel 1
|
||||
#ifdef WITH_RS232_BRIDGE
|
||||
_prefs.bridge_uart = WITH_RS232_BRIDGE_UART;
|
||||
#else
|
||||
_prefs.bridge_uart = 0;
|
||||
#endif
|
||||
|
||||
StrHelper::strncpy(_prefs.bridge_secret, "LVSITANOS", sizeof(_prefs.bridge_secret));
|
||||
|
||||
@@ -3470,6 +3480,11 @@ void MyMesh::begin(FILESYSTEM *fs) {
|
||||
node_info.repeat_when_nonzero = false;
|
||||
mqtt_bridge = new MQTTBridge(node_info, _cli.getObserverPrefs(),
|
||||
getRTCClock(), &self_id);
|
||||
#endif
|
||||
#ifdef WITH_RS232_BRIDGE
|
||||
if (!bridge) {
|
||||
bridge = createRS232Bridge();
|
||||
}
|
||||
#endif
|
||||
AbstractBridge* active_bridge = activeBridge();
|
||||
if (active_bridge) {
|
||||
|
||||
@@ -493,7 +493,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks
|
||||
#if defined(WITH_MQTT_BRIDGE)
|
||||
MQTTBridge* mqtt_bridge;
|
||||
#elif defined(WITH_RS232_BRIDGE)
|
||||
RS232Bridge bridge;
|
||||
RS232Bridge* bridge;
|
||||
#elif defined(WITH_ESPNOW_BRIDGE)
|
||||
ESPNowBridge bridge;
|
||||
#endif
|
||||
@@ -501,6 +501,8 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks
|
||||
AbstractBridge* activeBridge() {
|
||||
#ifdef WITH_MQTT_BRIDGE
|
||||
return mqtt_bridge;
|
||||
#elif defined(WITH_RS232_BRIDGE)
|
||||
return bridge;
|
||||
#else
|
||||
return &bridge;
|
||||
#endif
|
||||
@@ -508,6 +510,8 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks
|
||||
const AbstractBridge* activeBridge() const {
|
||||
#ifdef WITH_MQTT_BRIDGE
|
||||
return mqtt_bridge;
|
||||
#elif defined(WITH_RS232_BRIDGE)
|
||||
return bridge;
|
||||
#else
|
||||
return &bridge;
|
||||
#endif
|
||||
@@ -975,6 +979,21 @@ public:
|
||||
uint32_t getPowerSaveSleepSeconds(uint32_t max_secs) const;
|
||||
|
||||
#if defined(WITH_BRIDGE)
|
||||
#ifdef WITH_RS232_BRIDGE
|
||||
RS232Bridge* createRS232Bridge() {
|
||||
#ifdef WITH_RS232_BRIDGE_ALT
|
||||
if (_prefs.bridge_uart == WITH_RS232_BRIDGE_ALT_UART) {
|
||||
return new RS232Bridge(&_prefs, WITH_RS232_BRIDGE_ALT,
|
||||
WITH_RS232_BRIDGE_ALT_RX,
|
||||
WITH_RS232_BRIDGE_ALT_TX, _mgr, getRTCClock());
|
||||
}
|
||||
#endif
|
||||
return new RS232Bridge(&_prefs, WITH_RS232_BRIDGE,
|
||||
WITH_RS232_BRIDGE_RX, WITH_RS232_BRIDGE_TX,
|
||||
_mgr, getRTCClock());
|
||||
}
|
||||
#endif
|
||||
|
||||
void setBridgeState(bool enable) override {
|
||||
#ifdef WITH_MQTT_BRIDGE
|
||||
if (!mqtt_bridge) {
|
||||
@@ -990,9 +1009,24 @@ public:
|
||||
getRTCClock(), &self_id);
|
||||
if (!mqtt_bridge) return;
|
||||
}
|
||||
#endif
|
||||
#ifdef WITH_RS232_BRIDGE
|
||||
if (enable && !bridge) {
|
||||
bridge = createRS232Bridge();
|
||||
if (!bridge) return;
|
||||
}
|
||||
#endif
|
||||
AbstractBridge* active_bridge = activeBridge();
|
||||
if (!active_bridge || enable == active_bridge->isRunning()) return;
|
||||
if (!active_bridge) return;
|
||||
if (enable == active_bridge->isRunning()) {
|
||||
#ifdef WITH_RS232_BRIDGE
|
||||
if (!enable) {
|
||||
delete bridge;
|
||||
bridge = nullptr;
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (enable)
|
||||
{
|
||||
#ifdef WITH_MQTT_BRIDGE
|
||||
@@ -1014,6 +1048,10 @@ public:
|
||||
else
|
||||
{
|
||||
active_bridge->end();
|
||||
#ifdef WITH_RS232_BRIDGE
|
||||
delete bridge;
|
||||
bridge = nullptr;
|
||||
#endif
|
||||
#ifdef WITH_MQTT_BRIDGE
|
||||
_alerter.setBridge(nullptr);
|
||||
#endif
|
||||
@@ -1030,6 +1068,12 @@ public:
|
||||
}
|
||||
#endif
|
||||
active_bridge->end();
|
||||
#ifdef WITH_RS232_BRIDGE
|
||||
delete bridge;
|
||||
bridge = createRS232Bridge();
|
||||
if (bridge) bridge->begin();
|
||||
return;
|
||||
#endif
|
||||
#ifdef WITH_MQTT_BRIDGE
|
||||
// Set device metadata before restarting bridge (same as in begin())
|
||||
char device_id[65];
|
||||
|
||||
Reference in new issue
Block a user