Peripheral class

Representation of a unique peripheral

This class allows for managing the connection, discovery, retrieving Services, Characteristics and Descriptors and has convenience methods for manipulation of the latter two.

Only connect(), observeConnectionState(), isConnected() and disconnectOrCancelConnection() can be used if peripheral is not connected.

Constructors

Peripheral.fromJson(Map<String, dynamic> json, ManagerForPeripheral manager)

Properties

hashCode int
The hash code for this object.
no setterinherited
identifier String
getter/setter pair
name String?
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

characteristics(String servicedUuid) Future<List<Characteristic>>
Returns a list of discovered Characteristics of a Service identified by servicedUuid.
connect({bool isAutoConnect = false, int requestMtu = NO_MTU_NEGOTIATION, bool refreshGatt = false, Duration? timeout}) Future<void>
Connects to the peripheral.
descriptorsForCharacteristic(String serviceUuid, String characteristicUuid) Future<List<Descriptor>>
Returns a list of Descriptors for Characteristic matching specified UUIDs.
disconnectOrCancelConnection() Future<void>
Disconnects from this peripheral if it's connected or cancels pending connection.
discoverAllServicesAndCharacteristics({String? transactionId}) Future<void>
Discovers all Services, Characteristics and Descriptors of this peripheral. Must be done prior to any other operation concerning those.
isConnected() Future<bool>
Returns whether this peripheral is connected.
monitorCharacteristic(String serviceUuid, String characteristicUuid, {String? transactionId}) Stream<CharacteristicWithValue>
Returns a stream of notifications/indications from Characteristic matching specified UUIDs.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
observeConnectionState({bool emitCurrentValue = false, bool completeOnDisconnect = false}) Stream<PeripheralConnectionState>
Returns a stream of PeripheralConnectionState.
readCharacteristic(String serviceUuid, String characteristicUuid, {String? transactionId}) Future<CharacteristicWithValue>
Reads value of Characteristic matching specified UUIDs.
readDescriptor(String serviceUuid, String characteristicUuid, String descriptorUuid, {String? transactionId}) Future<DescriptorWithValue>
Reads value of Descriptor matching specified UUIDs.
requestMtu(int mtu, {String? transactionId}) Future<int>
Requests new MTU value for current connection and return the negotiation result on Android, reads MTU on iOS.
rssi({String? transactionId}) Future<int>
Reads RSSI for the peripheral.
services() Future<List<Service>>
Returns a list of Services of this peripheral.
toString() String
A string representation of this object.
override
writeCharacteristic(String serviceUuid, String characteristicUuid, Uint8List value, bool withResponse, {String? transactionId}) Future<Characteristic>
Writes value of Characteristic matching specified UUIDs.
writeDescriptor(String serviceUuid, String characteristicUuid, String descriptorUuid, Uint8List value, {String? transactionId}) Future<Descriptor>
Writes value of Descriptor matching specified UUIDs.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

NO_MTU_NEGOTIATION → const int