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.
pull/1072/head
diffwireauto 3 weeks ago committed by Strycher
parent 92d5cd212b
commit 747653af90

@ -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 -----------------------------------------------------

@ -148,10 +148,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
// 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<MeshCoreConnector, bool>(
(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

@ -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,
);

@ -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(

@ -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,

@ -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 {

@ -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.

Loading…
Cancel
Save

Powered by TurnKey Linux.