Tour Preview

Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

BluetoothLeDevice

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

Import Statement: import Felgo 3.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.


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(device, bool connect)

An overload method by passing true as the connect parameter, a connection request is triggered after successfully setting the device.


void setDevice(device)

Set a device from a BluetoothLeManager::deviceDiscovered() signal to this BluetoothLeDevice instance, useful in order 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 BluetoothLeDevice::setDevice(device, bool connect) if a connection request is desired.