|
| 1 | +//INFO: This is a stub - contact me if you need the full implementation. |
| 2 | + |
| 3 | +import 'dart:async'; |
| 4 | +import 'dart:typed_data'; |
| 5 | + |
| 6 | +/// BLE seam for the SRAM protocol code. The app supplies a `universal_ble` |
| 7 | +/// backed implementation; tests supply a fake. |
| 8 | +abstract class SramTransport { |
| 9 | + Future<void> subscribe(String characteristic); |
| 10 | + Future<void> write(String characteristic, Uint8List data, {bool withoutResponse = false}); |
| 11 | + Future<Uint8List> read(String characteristic); |
| 12 | + |
| 13 | + /// Notifications delivered on [characteristic] after [subscribe]. |
| 14 | + Stream<Uint8List> notifications(String characteristic); |
| 15 | + |
| 16 | + /// UUIDs of characteristics that are both readable and writable. |
| 17 | + List<String> readWriteCharacteristics(); |
| 18 | +} |
| 19 | + |
| 20 | +/// Buffers notification fragments and hands back exactly `count` bytes per |
| 21 | +/// [take]. Stubbed. |
| 22 | +class SramByteInbox { |
| 23 | + void add(Uint8List data) {} |
| 24 | + |
| 25 | + Future<Uint8List> take(int count) => throw UnimplementedError(); |
| 26 | +} |
| 27 | + |
| 28 | +/// One reaction-config slot's trigger: parallel device-type / button-mask lists. |
| 29 | +class SramReactionTrigger { |
| 30 | + const SramReactionTrigger(this.deviceTypes, this.buttonMasks); |
| 31 | + |
| 32 | + final List<int> deviceTypes; |
| 33 | + final List<int> buttonMasks; |
| 34 | + |
| 35 | + Map<String, dynamic> toJson() => {'device_types': deviceTypes, 'button_masks': buttonMasks}; |
| 36 | + |
| 37 | + factory SramReactionTrigger.fromJson(Map<String, dynamic> json) => SramReactionTrigger( |
| 38 | + (json['device_types'] as List).cast<int>(), |
| 39 | + (json['button_masks'] as List).cast<int>(), |
| 40 | + ); |
| 41 | +} |
0 commit comments