BluetoothSerialService class
A singleton service for managing Bluetooth serial communication and FHR data processing.
This class handles:
- Connecting and disconnecting to Bluetooth devices
- Receiving and parsing Bluetooth data packets
- Buffering and analyzing FHR (Fetal Heart Rate) data
- Streaming parsed FHR data to listeners
- Audio playback of decoded data using MyAudioTrack16Bit
- Enabling Bluetooth and retrieving paired devices
The service uses a broadcast Stream to provide real-time FHR data updates. It supports multiple data packet types and decodes them accordingly.
Example usage:
final bluetoothService = BluetoothSerialService();
await bluetoothService.connect(device);
bluetoothService.dataStream.listen((fhrData) { ... });
Constructors
- BluetoothSerialService()
-
factory
Properties
-
dataStream
→ Stream<
MyFhrData> -
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- lastFhr ↔ MyFhrData?
-
getter/setter pair
- myAudioTrack16Bit → MyAudioTrack16Bit
-
final
- onDataReceived ↔ dynamic Function(BluetoothData)?
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
connect(
BluetoothDevice device) → Future< bool> -
dataAnalyze(
BluetoothData data) → dynamic -
decodeData(
List< int> decodeValue) → void -
disconnect(
) → Future< void> -
dispose(
) → void -
enableBluetooth(
) → Future< bool> -
getPairedDevices(
) → Future< List< BluetoothDevice> > -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited