Fix BLE pairing display and RX gain defaults

This commit is contained in:
mikecarper committed 2026-08-10 19:42:44 -07:00
1 parent 968ca3363b
commit 2ff1166c15
22 files changed
+297 -39

No files matched your search

+2 -1
View File
@@ -31,6 +31,7 @@ does not reflect the GoogleTest count -- run the built binary directly
| `test_mqtt_topic_router` | `src/helpers/MQTTTopicRouter.h` | complete preset/custom topic-routing contract; MeshRank packets-only behavior; required identifiers; invalid inputs/slots; exact buffer boundaries |
| `test_mqtt_connection_policy` | `src/helpers/MQTTConnectionPolicy.h` | reconnect guard/backoff/stagger and breaker transitions; stable reset; JWT lifetime/renewal policy; exact timing boundaries and 32-bit `millis()` rollover |
| `test_wifi_reconnect_policy` | `src/helpers/WiFiReconnectPolicy.h` | five-minute forced reconnect cadence, connection resets, duplicate disconnect observations, and 32-bit `millis()` rollover |
| `test_radio_liveness` | `src/helpers/RadioLivenessTracker.h`, `src/helpers/radiolib/RxBoostedGainDefaults.h` | staged radio recovery, activity reset and rollover handling; target-specific RX boosted-gain defaults and SX126x precedence |
| `test_lr1110_rx_recovery` | `src/helpers/radiolib/LR1110RxRecovery.h` | LR1110 four-byte RX-buffer shift signature; captured and accumulated shifts; ordinary/scoped packet exclusions |
| `test_mqtt_packet_queue_policy` | `src/helpers/MQTTPacketQueuePolicy.h` | queue-full eviction; stale-disconnect flush; adaptive drain limits; bounded QoS0 retries; exact timing boundaries and 32-bit `millis()` rollover |
| `test_mqtt_runtime_buffer_lifecycle` | `src/helpers/MQTTRuntimeBufferLifecycle.h` | idempotent allocation/release; partial-allocation degradation; retry of only missing buffers |
@@ -43,7 +44,7 @@ does not reflect the GoogleTest count -- run the built binary directly
| `test_logical_message_cache` | `src/helpers/LogicalMessageCache.h` | bounded logical-message mapping; stable retry timestamps; exact older retries after newer messages; stale and same-timestamp mismatch rejection |
| `test_remote_cli_reply_cache` | `src/helpers/RemoteCliReplyCache.h`, `src/helpers/RemoteCliRequest.h` | authenticated logical-request matching; bounded recent-reply history; backward-compatible retry identity; empty-response completion; on-air truncation and clearing |
| `test_companion_frame_queue` | `src/helpers/CompanionFrameQueue.h` | response/required/best-effort classification; reserved capacity; stable priority; safe eviction; message-waiting coalescing |
| `test_serial_mode_switch` | `src/helpers/ArduinoSerialInterface.cpp` | independent terminal/seeder control-sequence recognition across reads and binary-frame boundaries; passthrough ownership of USB input and suppression of binary output |
| `test_serial_mode_switch` | `src/helpers/ArduinoSerialInterface.cpp`, `src/helpers/MultiSerialInterface.h` | independent terminal/seeder control-sequence recognition across reads and binary-frame boundaries; passthrough ownership of USB input and suppression of binary output; Bluetooth-only connection and pairing-request routing |
| `test_ble_tx_stall_watchdog` | `src/helpers/BleTxStallWatchdog.h` | exact BLE fragment progress; blocked-reply timeout; rollover-safe elapsed time; disconnect recovery retry and completion |
| `test_utils` | `src/Utils.cpp` | `Utils::toHex` (upstream) |
@@ -1,10 +1,28 @@
#include <gtest/gtest.h>
#include <helpers/RadioLivenessTracker.h>
#include <helpers/radiolib/RxBoostedGainDefaults.h>
using mesh::RadioLivenessTracker;
using mesh::RadioRecoveryAction;
TEST(RxBoostedGainDefaults, UsesTargetCompileTimeSetting) {
using mesh::radio::selectRxBoostedGainDefault;
EXPECT_EQ(selectRxBoostedGainDefault(true, 0, false, 0), 0);
EXPECT_EQ(selectRxBoostedGainDefault(true, 1, false, 0), 1);
EXPECT_EQ(selectRxBoostedGainDefault(false, 0, true, 0), 0);
EXPECT_EQ(selectRxBoostedGainDefault(false, 0, true, 1), 1);
EXPECT_EQ(selectRxBoostedGainDefault(false, 0, false, 0), 1);
}
TEST(RxBoostedGainDefaults, Sx126xSettingTakesPrecedence) {
using mesh::radio::selectRxBoostedGainDefault;
EXPECT_EQ(selectRxBoostedGainDefault(true, 0, true, 1), 0);
EXPECT_EQ(selectRxBoostedGainDefault(true, 1, true, 0), 1);
}
TEST(RadioLivenessTracker, StagesSoftThenHardRecovery) {
RadioLivenessTracker tracker;
tracker.begin(1000);
@@ -4,6 +4,7 @@
#include <vector>
#include "helpers/ArduinoSerialInterface.h"
#include "helpers/MultiSerialInterface.h"
class BufferStream : public Stream {
public:
@@ -41,6 +42,63 @@ public:
static const char START_TOKEN[] = "+++MESHCORE-TERM-START";
static const char SEEDER_TOKEN[] = "ota folder on";
class FakeSerialInterface : public BaseSerialInterface {
public:
bool enabled = false;
bool connected = false;
bool pairing_request = false;
void enable() override { enabled = true; }
void disable() override { enabled = false; }
bool isEnabled() const override { return enabled; }
bool isConnected() const override { return connected; }
bool isReadBusy() const override { return false; }
bool isWriteBusy() const override { return false; }
bool takePairingRequest() override {
bool pending = pairing_request;
pairing_request = false;
return pending;
}
size_t writeFrame(const uint8_t[], size_t len) override { return len; }
size_t checkRecvFrame(uint8_t[]) override { return 0; }
};
TEST(MultiSerialInterface, TracksBluetoothConnectionSeparately) {
MultiSerialInterface manager;
FakeSerialInterface usb;
FakeSerialInterface bluetooth;
usb.connected = true;
ASSERT_TRUE(manager.addInterface(InterfaceType::USB, &usb));
ASSERT_TRUE(manager.addInterface(InterfaceType::Bluetooth, &bluetooth));
manager.enable();
EXPECT_TRUE(manager.isConnected());
EXPECT_FALSE(manager.isBluetoothConnected());
bluetooth.connected = true;
EXPECT_TRUE(manager.isBluetoothConnected());
manager.disableBluetooth();
EXPECT_FALSE(manager.isBluetoothConnected());
}
TEST(MultiSerialInterface, PairingRequestsComeOnlyFromBluetooth) {
MultiSerialInterface manager;
FakeSerialInterface usb;
FakeSerialInterface bluetooth;
ASSERT_TRUE(manager.addInterface(InterfaceType::USB, &usb));
ASSERT_TRUE(manager.addInterface(InterfaceType::Bluetooth, &bluetooth));
manager.enable();
usb.pairing_request = true;
EXPECT_FALSE(manager.takePairingRequest());
bluetooth.pairing_request = true;
EXPECT_TRUE(manager.takePairingRequest());
EXPECT_FALSE(manager.takePairingRequest());
}
TEST(SerialModeSwitch, RecognizesControlSequenceAcrossReads) {
BufferStream stream;
ArduinoSerialInterface interface;