Pixels Plugin for Unity
Enable communications with Pixels dice using Bluetooth Low Energy.
Loading...
Searching...
No Matches
Systemic::BluetoothLE::Characteristic Class Reference

Represents a service's characteristic of a Bluetooth Low Energy (BLE) peripheral. More...

#include <Characteristic.h>

Public Member Functions

Destructor
 ~Characteristic ()
 Destroys the Characteristic instance.
 
Getters
std::uint16_t handle () const
 Gets the 16 bits handle of the BLE characteristic.
 
winrt::guid uuid () const
 Gets the UUID of the characteristic.
 
std::underlying_type< CharacteristicProperties >::type properties () const
 Gets the standard BLE properties of the characteristic.
 
bool canWrite () const
 Indicates whether the characteristic can be written.
 
bool canRead () const
 Indicates whether the characteristic can be read.
 
bool canNotify () const
 Indicates whether the characteristic can notify its value changes.
 

Characteristic operations

std::future< std::vector< std::uint8_t > > readValueAsync ()
 Reads the value from the characteristic.
 
std::future< BleRequestStatuswriteAsync (const std::vector< std::uint8_t > &data, bool withoutResponse=false)
 Writes the given data to the value of the characteristic.
 
std::future< BleRequestStatussubscribeAsync (const std::function< void(const std::vector< std::uint8_t > &)> &onValueChanged)
 Subscribes for value changes of the characteristic.
 
std::future< BleRequestStatusunsubscribeAsync ()
 Unsubscribes from value changes of the characteristic.
 

Detailed Description

Represents a service's characteristic of a Bluetooth Low Energy (BLE) peripheral.

A characteristic may be queried for its properties, and its underlying value may be read and/or written depending on the characteristic's capabilities. A characteristic with the notifiable property may be subscribed to get notified when its value changes.

Those operations are asynchronous and return a std::future.

The Characteristic class internally stores a WinRT's GattCharacteristic object.

Member Function Documentation

◆ canNotify()

bool Systemic::BluetoothLE::Characteristic::canNotify ( ) const

Indicates whether the characteristic can notify its value changes.

Returns
Whether the characteristic can notify.

◆ canRead()

bool Systemic::BluetoothLE::Characteristic::canRead ( ) const

Indicates whether the characteristic can be read.

Returns
Whether the characteristic can be read.

◆ canWrite()

bool Systemic::BluetoothLE::Characteristic::canWrite ( ) const

Indicates whether the characteristic can be written.

Returns
Whether the characteristic can be written.

◆ handle()

std::uint16_t Systemic::BluetoothLE::Characteristic::handle ( ) const

Gets the 16 bits handle of the BLE characteristic.

Returns
The 16 bits handle of the characteristic.

◆ properties()

std::underlying_type< CharacteristicProperties >::type Systemic::BluetoothLE::Characteristic::properties ( ) const

Gets the standard BLE properties of the characteristic.

Returns
The properties of the characteristic. See CharacteristicProperties for the different values (it may be a combination of them).

◆ readValueAsync()

std::future< std::vector< std::uint8_t > > Systemic::BluetoothLE::Characteristic::readValueAsync ( )

Reads the value from the characteristic.

The call fails if the characteristic is not readable.

Returns
A future with the read value as a vector of bytes.

◆ subscribeAsync()

std::future< BleRequestStatus > Systemic::BluetoothLE::Characteristic::subscribeAsync ( const std::function< void(const std::vector< std::uint8_t > &)> &  onValueChanged)

Subscribes for value changes of the characteristic.

Replaces a previously registered value change callback. The call fails if the characteristic doesn't support notifications.

Parameters
onValueChangedCalled when the value of the characteristic changes.
Returns
A future with the resulting request status.

◆ unsubscribeAsync()

std::future< BleRequestStatus > Systemic::BluetoothLE::Characteristic::unsubscribeAsync ( )

Unsubscribes from value changes of the characteristic.

Returns
A future with the resulting request status.

◆ uuid()

winrt::guid Systemic::BluetoothLE::Characteristic::uuid ( ) const

Gets the UUID of the characteristic.

Returns
The UUID of the characteristic.

◆ writeAsync()

std::future< BleRequestStatus > Systemic::BluetoothLE::Characteristic::writeAsync ( const std::vector< std::uint8_t > &  data,
bool  withoutResponse = false 
)

Writes the given data to the value of the characteristic.

The call fails if the characteristic is not writable.

Parameters
dataThe data to write to the characteristic (may be empty).
withoutResponseWhether to wait for the peripheral to respond.
Returns
A future with the resulting request status.

The documentation for this class was generated from the following file: