Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/src/commands.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ final List<Uint8List> initPackets = [
// ── Convenience builders for live ops ──────────────────────────────────────
Uint8List cmdLinkValid(int seq) =>
buildCommand(seq, Cmd.linkValid, const [0x00]);
Uint8List cmdGetBattery(int seq) =>
buildCommand(seq, Cmd.getBatteryLevel, const []);
Uint8List cmdGetBattery(int seq, {BandProfile profile = BandProfile.gen4}) =>
buildCommand(seq, Cmd.getBatteryLevel, const [], profile);
Uint8List cmdGetHello(int seq) =>
buildCommand(seq, Cmd.getHelloHarvard, const [0x00]);
Uint8List cmdGetHelloModern(int seq) =>
Expand Down
19 changes: 19 additions & 0 deletions test/gen5_command_surface_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,25 @@ void main() {
expect(f4.opcode, Cmd.abortHistoricalTransmits);
});

test('GET_BATTERY_LEVEL (26) is profile-aware', () {
// control.dart's decode branches on profile.isGen5 for this exact
// opcode's reply (u8 percent vs u16 LE deci-percent), so the request
// builder must be able to frame gen5 too.
final gen5Frame = cmdGetBattery(1, profile: gen5);
final f = parseFrame(gen5Frame, profile: gen5)!;
expect(f.valid, isTrue, reason: 'must parse as a gen5 frame');
expect(f.opcode, Cmd.getBatteryLevel);
final asGen4 = parseFrame(gen5Frame, profile: BandProfile.gen4);
expect(asGen4 == null || !asGen4.valid, isTrue,
reason: 'a gen5 frame must not also parse as valid gen4');

// Default (no profile arg) stays gen4 — backward compatible.
final gen4Frame = cmdGetBattery(1);
final f4 = parseFrame(gen4Frame, profile: BandProfile.gen4)!;
expect(f4.valid, isTrue);
expect(f4.opcode, Cmd.getBatteryLevel);
});

// Filtered reading ("Labrador", R17) — the three lifecycle toggles.
// Every body is [revision 01][operation]; 124's operation is
// NOT a boolean.
Expand Down
Loading