TinyB  0.5.1
TinyB - The Tiny Bluetooth LE library
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
tinyb::BluetoothGattCharacteristic Class Reference

#include <BluetoothGattCharacteristic.hpp>

Inheritance diagram for tinyb::BluetoothGattCharacteristic:
tinyb::BluetoothObject

Public Member Functions

virtual std::string get_java_class () const
 
virtual std::string get_class_name () const
 
virtual std::string get_object_path () const
 
virtual BluetoothType get_bluetooth_type () const
 
 BluetoothGattCharacteristic (const BluetoothGattCharacteristic &object)
 
virtual BluetoothGattCharacteristicclone () const
 
std::unique_ptr< BluetoothGattDescriptorfind (std::string *identifier, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero())
 
std::vector< unsigned char > read_value (uint16_t offset=0)
 
bool write_value (const std::vector< unsigned char > &arg_value, uint16_t offset=0)
 
bool enable_value_notifications (std::function< void(BluetoothGattCharacteristic &characteristic, std::vector< unsigned char > &value, void *userdata)> callback, void *user_data)
 
bool enable_value_notifications (std::function< void(std::vector< unsigned char > &value)> callback)
 
bool disable_value_notifications ()
 
std::string get_uuid ()
 
BluetoothGattService get_service ()
 
std::vector< unsigned char > get_value ()
 
bool get_notifying ()
 
std::vector< std::string > get_flags ()
 
std::vector< std::unique_ptr< BluetoothGattDescriptor > > get_descriptors ()
 
- Public Member Functions inherited from tinyb::BluetoothObject
virtual bool operator== (const BluetoothObject &other) const
 
virtual bool operator!= (const BluetoothObject &other) const
 

Static Public Member Functions

static std::string java_class ()
 
static BluetoothType class_type ()
 
- Static Public Member Functions inherited from tinyb::BluetoothObject
static BluetoothType class_type ()
 
static std::string java_class ()
 

Protected Member Functions

 BluetoothGattCharacteristic (GattCharacteristic1 *object)
 
bool start_notify ()
 
bool stop_notify ()
 
- Protected Member Functions inherited from tinyb::BluetoothObject
bool lock ()
 
void unlock ()
 

Static Protected Member Functions

static std::unique_ptr< BluetoothGattCharacteristicmake (Object *object, BluetoothType type=BluetoothType::GATT_CHARACTERISTIC, std::string *name=nullptr, std::string *identifier=nullptr, BluetoothObject *parent=nullptr)
 

Protected Attributes

std::function< void(std::vector< unsigned char > &)> value_changed_callback
 
- Protected Attributes inherited from tinyb::BluetoothObject
std::mutex lk
 
std::atomic_bool valid
 

Friends

class tinyb::BluetoothGattService
 
class tinyb::BluetoothGattDescriptor
 
class tinyb::BluetoothManager
 
class tinyb::BluetoothEventManager
 
class BluetoothNotificationHandler
 

Detailed Description

Provides access to Bluetooth GATT characteristic. Follows the BlueZ adapter API available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt

Member Function Documentation

virtual BluetoothGattCharacteristic* tinyb::BluetoothGattCharacteristic::clone ( ) const
virtual

Returns a raw pointer to a clone of the object

Returns
A raw pointer to a clone of the object

Reimplemented from tinyb::BluetoothObject.

bool tinyb::BluetoothGattCharacteristic::disable_value_notifications ( )

Disables notifications for changes of the value of the characteristic and uninstalls any callback (including BLE level).

bool tinyb::BluetoothGattCharacteristic::enable_value_notifications ( std::function< void(BluetoothGattCharacteristic &characteristic, std::vector< unsigned char > &value, void *userdata)>  callback,
void *  user_data 
)

Enables notifications (including at BLE level) for changes of the value of the characteristic and triggers the callback when the value changes. Uninstalls the previous value callback, if any was installed.

Parameters
callbackA function of the form void(BluetoothGattCharacteristic&, std::vector<unsigned char> &, void *), where BluetoothGattCharacteristic& is the adapter for which the callback was set, bool will contain the new value of the powered property and void * contains optional, user set data
userdataThe data which will be delivered to the callback when it is triggered. Memory must be managed by user.
bool tinyb::BluetoothGattCharacteristic::enable_value_notifications ( std::function< void(std::vector< unsigned char > &value)>  callback)

Enables notifications (including at BLE level) for changes of the value of the characteristic and triggers the callback when the value changes. Uninstalls the previous powered callback, if any was installed.

Parameters
callbackA function of the form void(std::vector<unsigned char> &), where std::vector<unsigned char>& will contain the new value
virtual BluetoothType tinyb::BluetoothGattCharacteristic::get_bluetooth_type ( ) const
virtual

Returns the BluetoothType of this object

Returns
The BluetoothType of this object

Reimplemented from tinyb::BluetoothObject.

virtual std::string tinyb::BluetoothGattCharacteristic::get_class_name ( ) const
virtual

Returns the class name of this object

Returns
A std::string containing the class name of this object

Reimplemented from tinyb::BluetoothObject.

std::vector<std::unique_ptr<BluetoothGattDescriptor> > tinyb::BluetoothGattCharacteristic::get_descriptors ( )

Returns a list of BluetoothGattDescriptors this characteristic exposes.

Returns
A list of BluetoothGattDescriptors exposed by this characteristic NULL if an error occurred
std::vector<std::string> tinyb::BluetoothGattCharacteristic::get_flags ( )

Returns the flags this characterstic has.

Returns
A list of flags for this characteristic.
virtual std::string tinyb::BluetoothGattCharacteristic::get_java_class ( ) const
virtual

Returns the complete Java class of this object

Returns
A std::string containing the java class of this object

Reimplemented from tinyb::BluetoothObject.

bool tinyb::BluetoothGattCharacteristic::get_notifying ( )

Returns true if notification for changes of this characteristic are activated.

Returns
True if notificatios are activated.
virtual std::string tinyb::BluetoothGattCharacteristic::get_object_path ( ) const
virtual

Returns the DBus object path of this object

Returns
A std::string containing the DBus object path of this object

Reimplemented from tinyb::BluetoothObject.

BluetoothGattService tinyb::BluetoothGattCharacteristic::get_service ( )

Returns the service to which this characteristic belongs to.

Returns
The service.
std::string tinyb::BluetoothGattCharacteristic::get_uuid ( )

Get the UUID of this characteristic.

Returns
The 128 byte UUID of this characteristic, NULL if an error occurred
std::vector<unsigned char> tinyb::BluetoothGattCharacteristic::get_value ( )

Returns the cached value of this characteristic, if any.

Returns
The cached value of this characteristic.
std::vector<unsigned char> tinyb::BluetoothGattCharacteristic::read_value ( uint16_t  offset = 0)

Reads the value of this characteristic.

Returns
A std::vector<unsgined char> containing the value of this characteristic.
bool tinyb::BluetoothGattCharacteristic::write_value ( const std::vector< unsigned char > &  arg_value,
uint16_t  offset = 0 
)

Writes the value of this characteristic.

Parameters
[in]arg_valueThe data as vector<uchar> to be written packed in a GBytes struct
Returns
TRUE if value was written succesfully

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