From 747653af90c9cd0a66fee1966083e7d1f15b0e2c Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Mon, 2 Nov 2026 22:14:17 -0500 Subject: [PATCH] fix(#1065): drop the observer-config version gate too, bit only Owner reaffirmed: do not depend on FIRMWARE_VER_CODE, depend on caps bits. The 0xC0 config gate ANDed OFFBAND_CONFIG_MIN_VER (14) on top of the OFFBAND_CAP_WIFI_OBSERVER bit, which left it passing at zero margin once the code rolled back onto 14. Removed; supportsConfig now takes only offbandCaps. The bit is the sounder signal: caps byte 1 exists only on fork replies, which are the only replies that carry 0xC0 at all, and a build without the observer backend compiled in leaves the bit clear whatever version it reports. minVerCode is deleted rather than left unused, so it cannot be reintroduced into a gate. Two call sites and four tests updated. Four gates now depend on caps bits alone: block, caplog, packet hash, observer config. Those are all of the readers in the conflated 14-22 range. Full suite: 1739 passed. --- lib/connector/observer_config_client.dart | 24 +++++++++---------- lib/screens/settings_screen.dart | 6 ++--- lib/services/observer_config_service.dart | 7 +++--- test/connector/observer_caps_test.dart | 22 +++++++++++------ test/population_conformance_test.dart | 1 - .../observer_config_service_test.dart | 11 ++++++--- test/services/observer_provider_test.dart | 4 ++-- 7 files changed, 42 insertions(+), 33 deletions(-) diff --git a/lib/connector/observer_config_client.dart b/lib/connector/observer_config_client.dart index 0edfb30e..e58a9b42 100644 --- a/lib/connector/observer_config_client.dart +++ b/lib/connector/observer_config_client.dart @@ -91,9 +91,6 @@ class ObserverConfigClient { static const int cmdConfig = 0xC0; static const int respConfig = 0xC0; - /// Command exists iff FIRMWARE_VER_CODE >= this AND the capability bit is set. - static const int minVerCode = 14; - /// Bit 0 of the `offband_caps` byte appended to the device-info reply. static const int capWifiObserver = 0x01; @@ -117,16 +114,19 @@ class ObserverConfigClient { /// Number of MQTT broker slots (firmware OFFBAND_MAX_BROKERS). static const int brokerSlotCount = 10; - /// True iff the device advertises config support: version gate AND the + /// True iff the device advertises config support: the /// `OFFBAND_CAP_WIFI_OBSERVER` bit in the device-info `offband_caps` byte. - /// The WHOLE command (display included) is observer-gated, so both must hold. - static bool supportsConfig({ - required int firmwareVerCode, - required int offbandCaps, - }) { - return firmwareVerCode >= minVerCode && - (offbandCaps & capWifiObserver) != 0; - } + /// The WHOLE command (display included) is observer-gated. + /// + /// The bit alone, never `FIRMWARE_VER_CODE` (#1065). This used to also + /// require `>= 14`, mirroring firmware's `OFFBAND_CONFIG_MIN_VER`, which left + /// it passing at zero margin once the code rolled back onto 14. The bit is a + /// sounder signal than the floor ever was: caps byte 1 exists only on fork + /// replies, which are the only ones that carry the `0xC0` command, and a + /// build without the observer backend compiled in leaves the bit clear + /// whatever it reports as its version. + static bool supportsConfig({required int offbandCaps}) => + (offbandCaps & capWifiObserver) != 0; // --- Request builders ----------------------------------------------------- diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 1d77d777..b516b0e1 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -148,10 +148,8 @@ class _SettingsScreenState extends State { // A blanket context.watch here rebuilt the whole settings screen on every // sync frame, thrashing the UI thread and slowing the channel sync (#81). final showObserver = context.select( - (c) => ObserverConfigClient.supportsConfig( - firmwareVerCode: c.firmwareVerCode ?? 0, - offbandCaps: c.offbandCaps ?? 0, - ), + (c) => + ObserverConfigClient.supportsConfig(offbandCaps: c.offbandCaps ?? 0), ); // Owner-only Experimental section (#509), revealed by the 7-tap gesture on // the Device Info Build row. Selects narrowly so the category list only diff --git a/lib/services/observer_config_service.dart b/lib/services/observer_config_service.dart index 5b7af481..10aa8101 100644 --- a/lib/services/observer_config_service.dart +++ b/lib/services/observer_config_service.dart @@ -47,12 +47,11 @@ class ObserverConfigService extends ChangeNotifier { bool _brokersUnavailable = false; bool get brokersUnavailable => _brokersUnavailable; - /// Whether the connected device supports the config command, the version - /// gate AND the capability bit, read live from the connector's device-info - /// parse. The settings UI watches the connector, so the Observer category + /// Whether the connected device supports the config command: the capability + /// bit, read live from the connector's device-info parse (#1065, no version + /// gate). The settings UI watches the connector, so the Observer category /// appears/hides as this flips on connect/disconnect. bool get supported => ObserverConfigClient.supportsConfig( - firmwareVerCode: _connector.firmwareVerCode ?? 0, offbandCaps: _connector.offbandCaps ?? 0, ); diff --git a/test/connector/observer_caps_test.dart b/test/connector/observer_caps_test.dart index e8313953..f3f18d73 100644 --- a/test/connector/observer_caps_test.dart +++ b/test/connector/observer_caps_test.dart @@ -12,6 +12,7 @@ import 'dart:typed_data'; import 'package:flutter_test/flutter_test.dart'; import 'package:meshcore_open/connector/meshcore_connector.dart'; +import 'package:meshcore_open/connector/meshcore_protocol.dart'; import 'package:meshcore_open/connector/observer_config_client.dart'; void main() { @@ -38,15 +39,22 @@ void main() { final caps = MeshCoreConnector.parseOffbandCaps( frame(83, caps: ObserverConfigClient.capWifiObserver), )!; - expect( - ObserverConfigClient.supportsConfig( - firmwareVerCode: ObserverConfigClient.minVerCode, - offbandCaps: caps, - ), - isTrue, - ); + expect(ObserverConfigClient.supportsConfig(offbandCaps: caps), isTrue); }); + test( + 'a clear observer bit is unsupported (#1065: the bit is the gate)', + () { + final caps = MeshCoreConnector.parseOffbandCaps(frame(83, caps: 0x00))!; + expect(ObserverConfigClient.supportsConfig(offbandCaps: caps), isFalse); + // Another feature's bit must not open the config command. + expect( + ObserverConfigClient.supportsConfig(offbandCaps: offbandCapCaplog), + isFalse, + ); + }, + ); + test('hostile/truncated short frames never throw, always null', () { for (final n in [0, 1, 4, 80, 81, 82]) { expect( diff --git a/test/population_conformance_test.dart b/test/population_conformance_test.dart index b62ad493..8c57f0d3 100644 --- a/test/population_conformance_test.dart +++ b/test/population_conformance_test.dart @@ -204,7 +204,6 @@ void main() { expect(connector.supportsPktHash, f.pktHash, reason: 'pkt hash 0xC6'); expect( ObserverConfigClient.supportsConfig( - firmwareVerCode: connector.firmwareVerCode ?? 0, offbandCaps: connector.offbandCaps ?? 0, ), f.observerConfig, diff --git a/test/services/observer_config_service_test.dart b/test/services/observer_config_service_test.dart index 12199b4f..9be130f4 100644 --- a/test/services/observer_config_service_test.dart +++ b/test/services/observer_config_service_test.dart @@ -165,13 +165,18 @@ void main() { }); tearDown(() => c.close()); - test('supported reflects version gate + capability bit', () { + test('supported reflects the capability bit alone (#1065)', () { expect(svc.supported, isTrue); c.caps = 0x00; // observer bit off expect(svc.supported, isFalse); c.caps = 0x01; - c.ver = 13; // below gate - expect(svc.supported, isFalse); + expect(svc.supported, isTrue); + // The ver code is no longer consulted: a device reporting the rolled-back + // 14, or anything else, is supported iff the observer bit is set. + c.ver = 13; + expect(svc.supported, isTrue); + c.ver = 14; + expect(svc.supported, isTrue); }); test('setFlat returns true on ACK (happy path)', () async { diff --git a/test/services/observer_provider_test.dart b/test/services/observer_provider_test.dart index 24cfc81f..ce14788f 100644 --- a/test/services/observer_provider_test.dart +++ b/test/services/observer_provider_test.dart @@ -47,10 +47,10 @@ void main() { ), ); - // Unsupported until the shared connector reports a v14+ observer build. + // Unsupported until the shared connector reports the observer cap bit + // (#1065: the bit alone, no version gate). expect(svc.supported, isFalse); - connector.ver = ObserverConfigClient.minVerCode; connector.caps = ObserverConfigClient.capWifiObserver; // The gate flips because the service reads through the SAME connector.