BluetoothDevice class
- Available extensions
Constructors
- BluetoothDevice.new({required DeviceIdentifier remoteId})
- BluetoothDevice.fromId(String remoteId)
- Create a device from an id
- BluetoothDevice.fromProto(BmBluetoothDevice p)
Properties
- advName → String
-
Advertised Named
no setter
-
bondState
→ Stream<
BluetoothBondState> -
Get the current bondState of the device (Android Only)
no setter
-
connectionState
→ Stream<
BluetoothConnectionState> -
The current connection state of our app to the device
no setter
- disconnectReason → DisconnectReason?
-
The most recent disconnection reason
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → DeviceIdentifier
-
no setter
- isAutoConnectEnabled → bool
-
Returns true if autoConnect is currently enabled for this device
no setter
- isConnected → bool
-
Returns true if this device is currently connected to your app
no setter
- isDisconnected → bool
-
Returns true if this device is currently disconnected from your app
no setter
-
isDiscoveringServices
→ Stream<
bool> -
no setter
- localName → String
-
no setter
-
mtu
→ Stream<
int> -
Stream emits a value:
no setter
- mtuNow → int
-
The current MTU size in bytes
no setter
- name → String
-
no setter
-
onServicesReset
→ Stream<
void> -
Services Reset Stream
no setter
- platformName → String
-
platform name
no setter
- prevBondState → BluetoothBondState?
-
Get the previous bondState of the device (Android Only)
no setter
- remoteId → DeviceIdentifier
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
services
→ Stream<
List< BluetoothService> > -
no setter
-
servicesList
→ List<
BluetoothService> -
Get services
returns empty when:
no setter
-
servicesStream
→ Stream<
List< BluetoothService> > -
no setter
-
state
→ Stream<
BluetoothConnectionState> -
no setter
Methods
-
cancelWhenDisconnected(
StreamSubscription subscription, {bool next = false, bool delayed = false}) → void - Register a subscription to be canceled when the device is disconnected. This function simplifies cleanup, so you can prevent creating duplicate stream subscriptions.
-
clearGattCache(
) → Future< void> - Refresh ble services & characteristics (Android Only)
-
connect(
{Duration timeout = const Duration(seconds: 35), int? mtu = 512, bool autoConnect = false}) → Future< void> -
Establishes a connection to the Bluetooth Device.
timeout
if timeout occurs, cancel the connection request and throw exceptionmtu
Android only. Request a larger mtu right after connection, if set.autoConnect
reconnect whenever the device is found - if true, this function always returns immediately. - you must listen toconnectionState
to know when connection occurs. - auto connect is turned off by callingdisconnect
- auto connect results in a slower connection process compared to a direct connection because it relies on the internal scheduling of background scans. -
createBond(
{int timeout = 90, Uint8List? pin}) → Future< void> - Force the bonding popup to show now (Android Only) Note! calling this is usually not necessary!! The platform does it automatically.
-
disconnect(
{int timeout = 35, bool queue = true, int androidDelay = 2000}) → Future< void> - Cancels connection to the Bluetooth Device
-
discoverServices(
{bool subscribeToServicesChanged = true, int timeout = 15}) → Future< List< BluetoothService> > - Discover services, characteristics, and descriptors of the remote device
-
exitProvisioning(
{String psk = 'viamsetup'}) → Future< void> -
Available on BluetoothDevice, provided by the ViamWriting extension
-
getBleService(
{dynamic attempts = 2}) → Future< BluetoothService> -
Available on BluetoothDevice, provided by the ViamReading extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pair(
) → Future< void> -
readAgentVersion(
) → Future< String> -
Available on BluetoothDevice, provided by the ViamReading extension
-
readErrors(
) → Future< List< String> > -
Available on BluetoothDevice, provided by the ViamReading extension
Errors are returned in a list ordered from oldest to newest. -
readFragmentId(
) → Future< String> -
Available on BluetoothDevice, provided by the ViamReading extension
-
readManufacturer(
) → Future< String> -
Available on BluetoothDevice, provided by the ViamReading extension
-
readModel(
) → Future< String> -
Available on BluetoothDevice, provided by the ViamReading extension
-
readNetworkList(
) → Future< List< WifiNetwork> > -
Available on BluetoothDevice, provided by the ViamReading extension
-
readRssi(
{int timeout = 15}) → Future< int> - Read the RSSI of connected remote device
-
readStatus(
) → Future< ({bool isConfigured, bool isConnected})> -
Available on BluetoothDevice, provided by the ViamReading extension
-
removeBond(
{int timeout = 30}) → Future< void> - Remove bond (Android Only)
-
requestConnectionPriority(
{required ConnectionPriority connectionPriorityRequest}) → Future< void> - Request connection priority update (Android only)
-
requestMtu(
int desiredMtu, {double predelay = 0.35, int timeout = 15}) → Future< int> - Request to change MTU (Android Only)
-
setPreferredPhy(
{required int txPhy, required int rxPhy, required PhyCoding option}) → Future< void> - Set the preferred connection (Android Only)
-
toString(
) → String -
A string representation of this object.
override
-
unlockPairing(
{String psk = 'viamsetup'}) → Future< void> -
Available on BluetoothDevice, provided by the ViamWriting extension
-
writeNetworkConfig(
{required String ssid, String? pw, String psk = 'viamsetup'}) → Future< void> -
Available on BluetoothDevice, provided by the ViamWriting extension
-
writeRobotPartConfig(
{required String partId, required String secret, String appAddress = 'https://app.viam.com:443', String psk = 'viamsetup'}) → Future< void> -
Available on BluetoothDevice, provided by the ViamWriting extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override