Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

BluetoothLeDevice

Bluetooth Low Energy Device, discovered by the BluetoothLeManager component. More...

Import Statement: import Felgo 4.0
Since: Felgo 3.7.0

Properties

Signals

Methods

Detailed Description

General info and usage examples for Bluetooth LE: Use Bluetooth Low Energy

Bluetooth Low Energy Services for the device are exposed in the QVariantList services property, services can only be usable after the service discovery has finished which is triggered by calling the BluetoothLeDevice::connect() method.

The only notified property appart from services is the rssi signal strength, but it’s only updated during device discovery. The discovery process could be set to continuous to keep the rssi updated for applications using the rssi as distance measurement for indoor location for example.

Property Documentation

Error : enumeration

Indicates all possible error conditions found during the connection and the underlying controller's existence.

  • BluetoothLeDevice.NoError No error has occurred.
  • BluetoothLeDevice.UnknownError An unknown error has occurred.
  • BluetoothLeDevice.UnknownRemoteDeviceError The remote Bluetooth Low Energy device with the address passed to the constructor of this class cannot be found.
  • BluetoothLeDevice.NetworkError The attempt to read from or write to the remote device failed.
  • BluetoothLeDevice.InvalidBluetoothAdapterError The local Bluetooth device with the address passed to the constructor of this class cannot be found or there is no local Bluetooth device.
  • BluetoothLeDevice.ConnectionError The attempt to connect to the remote device failed.
  • BluetoothLeDevice.AdvertisingError The attempt to start advertising failed.
  • BluetoothLeDevice.RemoteHostClosedError The remote device closed the connection.
  • BluetoothLeDevice.AuthorizationError The local Bluetooth device closed the connection due to insufficient authorization.

address : string

The remote device address, on Android the MAC address is returned, on iOS a UUID address is provided by the operating system instead, the format is "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where 'x' is a hex digit.


[read-only] connected : bool

Current connection state to the remote device.


discovered : bool

Cached devices set the discovered property to false during discovery, once it's discovered again by the BluetoothLeManager component, this property is set back to true, this property is useful to make sure the device is still available.


error : BluetoothLeDevice::Error

Error state for the connection to the remote device and the underlying connection QLowEnergyController.


name : string

The name reported by the remote device, can be empty if the remote device does not advertise it.


rssi : int

The latest reported RSSI signal strength, its updated only during device discovery.


services : list<BluetoothLeService>

The device discovered services.


Signal Documentation

serviceDiscoveryFinished()

Service discovery has finished after a successful connection and the current device and services are ready to be used.

Note: The corresponding handler is onServiceDiscoveryFinished.


Method Documentation

void connect()

Request a connection to the remote device.


void disconnect()

Disconnect from the remote device if an active connection exists.


void setDevice(QVariantMap device, bool connect)

Set a device from a BluetoothLeManager::deviceDiscovered() signal to this BluetoothLeDevice instance. Use this to describe expected devices in a declarative way in QML and then set the discovered device. This method also triggers a connection request after successfully setting the device.


void setDevice(QVariantMap device)

This function overloads setDevice().

Set a device from a BluetoothLeManager::deviceDiscovered() signal to this BluetoothLeDevice instance. Use this to describe expected devices in a declarative way in QML and then set the discovered device. This method does not trigger a connection. Use the overloaded method setDevice() if a connection request is desired.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded