Pixels Plugin for Unity
Enable communications with Pixels dice using Bluetooth Low Energy.
|
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< BleRequestStatus > | writeAsync (const std::vector< std::uint8_t > &data, bool withoutResponse=false) |
Writes the given data to the value of the characteristic. | |
std::future< BleRequestStatus > | subscribeAsync (const std::function< void(const std::vector< std::uint8_t > &)> &onValueChanged) |
Subscribes for value changes of the characteristic. | |
std::future< BleRequestStatus > | unsubscribeAsync () |
Unsubscribes from value changes of the characteristic. | |
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.
bool Systemic::BluetoothLE::Characteristic::canNotify | ( | ) | const |
Indicates whether the characteristic can notify its value changes.
bool Systemic::BluetoothLE::Characteristic::canRead | ( | ) | const |
Indicates whether the characteristic can be read.
bool Systemic::BluetoothLE::Characteristic::canWrite | ( | ) | const |
Indicates whether the characteristic can be written.
std::uint16_t Systemic::BluetoothLE::Characteristic::handle | ( | ) | const |
Gets the 16 bits handle of the BLE characteristic.
std::underlying_type< CharacteristicProperties >::type Systemic::BluetoothLE::Characteristic::properties | ( | ) | const |
Gets the standard BLE properties of the characteristic.
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.
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.
onValueChanged | Called when the value of the characteristic changes. |
std::future< BleRequestStatus > Systemic::BluetoothLE::Characteristic::unsubscribeAsync | ( | ) |
Unsubscribes from value changes of the characteristic.
winrt::guid Systemic::BluetoothLE::Characteristic::uuid | ( | ) | const |
Gets the UUID of the characteristic.
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.
data | The data to write to the characteristic (may be empty). |
withoutResponse | Whether to wait for the peripheral to respond. |