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::BluetoothDevice Class Reference

#include <BluetoothDevice.hpp>

Inheritance diagram for tinyb::BluetoothDevice:
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
 
 BluetoothDevice (const BluetoothDevice &object)
 
virtual BluetoothDeviceclone () const
 
std::unique_ptr< BluetoothGattServicefind (std::string *identifier, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero())
 
bool disconnect ()
 
bool connect ()
 
bool connect_profile (const std::string &arg_UUID)
 
bool disconnect_profile (const std::string &arg_UUID)
 
bool pair ()
 
bool remove_device ()
 
bool cancel_pairing ()
 
std::vector< std::unique_ptr< BluetoothGattService > > get_services ()
 
std::string get_address ()
 
std::string get_name ()
 
std::string get_alias ()
 
void set_alias (const std::string &value)
 
unsigned int get_class ()
 
uint16_t get_appearance ()
 
std::unique_ptr< std::string > get_icon ()
 
bool get_paired ()
 
void enable_paired_notifications (std::function< void(BluetoothDevice &device, bool paired, void *userdata)> callback, void *userdata)
 
void enable_paired_notifications (std::function< void(bool paired)> callback)
 
void disable_paired_notifications ()
 
bool get_trusted ()
 
void set_trusted (bool value)
 
void enable_trusted_notifications (std::function< void(BluetoothDevice &device, bool trusted, void *userdata)> callback, void *userdata)
 
void enable_trusted_notifications (std::function< void(bool trusted)> callback)
 
void disable_trusted_notifications ()
 
bool get_blocked ()
 
void set_blocked (bool value)
 
void enable_blocked_notifications (std::function< void(BluetoothDevice &device, bool blocked, void *userdata)> callback, void *userdata)
 
void enable_blocked_notifications (std::function< void(bool blocked)> callback)
 
void disable_blocked_notifications ()
 
bool get_legacy_pairing ()
 
int16_t get_rssi ()
 
void enable_rssi_notifications (std::function< void(BluetoothDevice &device, int16_t rssi, void *userdata)> callback, void *userdata=nullptr)
 
void enable_rssi_notifications (std::function< void(int16_t rssi)> callback)
 
void disable_rssi_notifications ()
 
bool get_connected ()
 
void enable_connected_notifications (std::function< void(BluetoothDevice &device, bool connected, void *userdata)> callback, void *userdata)
 
void enable_connected_notifications (std::function< void(bool connected)> callback)
 
void disable_connected_notifications ()
 
std::vector< std::string > get_uuids ()
 
std::unique_ptr< std::string > get_modalias ()
 
BluetoothAdapter get_adapter ()
 
std::map< uint16_t, std::vector< uint8_t > > get_manufacturer_data ()
 
void enable_manufacturer_data_notifications (std::function< void(BluetoothDevice &device, std::map< uint16_t, std::vector< uint8_t >> &mfgdata, void *userdata)> callback, void *userdata)
 
void enable_manufacturer_data_notifications (std::function< void(std::map< uint16_t, std::vector< uint8_t >> &mfgdata)> callback)
 
void disable_manufacturer_data_notifications ()
 
std::map< std::string, std::vector< uint8_t > > get_service_data ()
 
void enable_service_data_notifications (std::function< void(BluetoothDevice &device, std::map< std::string, std::vector< uint8_t >> &servicedata, void *userdata)> callback, void *userdata)
 
void enable_service_data_notifications (std::function< void(std::map< std::string, std::vector< uint8_t >> &servicedata)> callback)
 
void disable_service_data_notifications ()
 
int16_t get_tx_power ()
 
bool get_services_resolved ()
 
void enable_services_resolved_notifications (std::function< void(BluetoothDevice &device, bool services_resolved, void *userdata)> callback, void *userdata)
 
void enable_services_resolved_notifications (std::function< void(bool connec)> callback)
 
void disable_services_resolved_notifications ()
 
- 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

 BluetoothDevice (Device1 *object)
 
- Protected Member Functions inherited from tinyb::BluetoothObject
bool lock ()
 
void unlock ()
 

Static Protected Member Functions

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

Protected Attributes

std::function< void(int16_t)> rssi_callback
 
std::function< void(bool)> trusted_callback
 
std::function< void(bool)> paired_callback
 
std::function< void(bool)> connected_callback
 
std::function< void(bool)> blocked_callback
 
std::function< void(std::map< uint16_t, std::vector< uint8_t >> &)> mfg_callback
 
std::function< void(std::map< std::string, std::vector< uint8_t >> &)> service_callback
 
std::function< void(bool)> services_resolved_callback
 
- Protected Attributes inherited from tinyb::BluetoothObject
std::mutex lk
 
std::atomic_bool valid
 

Friends

class tinyb::BluetoothManager
 
class tinyb::BluetoothEventManager
 
class tinyb::BluetoothAdapter
 
class tinyb::BluetoothGattService
 
class tinyb::BluetoothNotificationHandler
 

Detailed Description

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

Member Function Documentation

bool tinyb::BluetoothDevice::cancel_pairing ( )

Cancels an initiated pairing operation

Returns
TRUE if the paring is cancelled successfully
virtual BluetoothDevice* tinyb::BluetoothDevice::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::BluetoothDevice::connect ( )

A connection to this device is established, connecting each profile flagged as auto-connectable.

Returns
TRUE if the device connected
bool tinyb::BluetoothDevice::connect_profile ( const std::string &  arg_UUID)

Connects a specific profile available on the device, given by UUID

Parameters
arg_UUIDThe UUID of the profile to be connected
Returns
TRUE if the profile connected successfully
void tinyb::BluetoothDevice::disable_blocked_notifications ( )

Disables notifications for changes of the blocked status of the device and uninstalls any callback.

void tinyb::BluetoothDevice::disable_connected_notifications ( )

Disables notifications for changes of the connected status of the device and uninstalls any callback.

void tinyb::BluetoothDevice::disable_manufacturer_data_notifications ( )

Disables notifications for changes in the manufacturer data of the device and uninstalls any callback.

void tinyb::BluetoothDevice::disable_paired_notifications ( )

Disables notifications for changes of the paired status of the device and uninstalls any callback.

void tinyb::BluetoothDevice::disable_rssi_notifications ( )

Disables notifications for changes of the RSSI value of the device and uninstalls any callback.

void tinyb::BluetoothDevice::disable_service_data_notifications ( )

Disables notifications for changes in the service data of the device and uninstalls any callback.

void tinyb::BluetoothDevice::disable_services_resolved_notifications ( )

Disables notifications for changes of the services resolved status of the device and uninstalls any callback.

void tinyb::BluetoothDevice::disable_trusted_notifications ( )

Disables notifications for changes of the trusted status of the device and uninstalls any callback.

bool tinyb::BluetoothDevice::disconnect ( )

The connection to this device is removed, removing all connected profiles.

Returns
TRUE if the device disconnected
bool tinyb::BluetoothDevice::disconnect_profile ( const std::string &  arg_UUID)

Disconnects a specific profile available on the device, given by UUID

Parameters
arg_UUIDThe UUID of the profile to be disconnected
Returns
TRUE if the profile disconnected successfully
void tinyb::BluetoothDevice::enable_blocked_notifications ( std::function< void(BluetoothDevice &device, bool blocked, void *userdata)>  callback,
void *  userdata 
)

Enables notifications for changes of the blocked status of the device and triggers the callback when the value changes. Uninstalls the previous blocked callback, if any was installed.

Parameters
callbackA function of the form void(BluetoothDevice&, bool, void *), where BluetoothDevice& is the device for which the callback was set, bool will contain the new value of the blocked 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.
void tinyb::BluetoothDevice::enable_blocked_notifications ( std::function< void(bool blocked)>  callback)

Enables notifications for changes of the blocked status of the device and triggers the callback when the value changes. Uninstalls the previous blocked callback, if any was installed.

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the blocked property
void tinyb::BluetoothDevice::enable_connected_notifications ( std::function< void(BluetoothDevice &device, bool connected, void *userdata)>  callback,
void *  userdata 
)

Enables notifications for changes of the connected status of the device and triggers the callback when the value changes. Uninstalls the previous connected callback, if any was installed.

Parameters
callbackA function of the form void(BluetoothDevice&, bool, void *), where BluetoothDevice& is the device for which the callback was set, bool will contain the new value of the connected 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.
void tinyb::BluetoothDevice::enable_connected_notifications ( std::function< void(bool connected)>  callback)

Enables notifications for changes of the connected status of the device and triggers the callback when the value changes. Uninstalls the previous connected callback, if any was installed.

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the connected property
void tinyb::BluetoothDevice::enable_manufacturer_data_notifications ( )

Enables notifications for changes of the manufacturer data of the device and triggers the callback when the value changes. Uninstalls the previous connected callback, if any was installed.

Parameters
callbackA function of the form void(BluetoothDevice&, bool, void *), where BluetoothDevice& is the device for which the callback was set, bool will contain the new value of the connected 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.
void tinyb::BluetoothDevice::enable_manufacturer_data_notifications ( )

Enables notifications for changes in the manufacturer data of the device and triggers the callback when the value changes. Uninstalls the previous connected callback, if any was installed.

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the connected property
void tinyb::BluetoothDevice::enable_paired_notifications ( std::function< void(BluetoothDevice &device, bool paired, void *userdata)>  callback,
void *  userdata 
)

Enables notifications for changes of the paired status of the device and triggers the callback when the value changes. Uninstalls the previous paired callback, if any was installed.

Parameters
callbackA function of the form void(BluetoothDevice&, bool, void *), where BluetoothDevice& is the device for which the callback was set, bool will contain the new value of the paired 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.
void tinyb::BluetoothDevice::enable_paired_notifications ( std::function< void(bool paired)>  callback)

Enables notifications for changes of the paired status of the device and triggers the callback when the value changes. Uninstalls the previous paired callback, if any was installed.

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the paired property
void tinyb::BluetoothDevice::enable_rssi_notifications ( std::function< void(BluetoothDevice &device, int16_t rssi, void *userdata)>  callback,
void *  userdata = nullptr 
)

Enables notifications for changes of the RSSI value of the device and triggers the callback when the value changes. Uninstalls the previous RSSI callback, if any was installed.

Parameters
callbackA function of the form void(BluetoothDevice&, int16_t, void *), where BluetoothDevice& is the device for which the callback was set, bool will contain the new value of the RSSI 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.
void tinyb::BluetoothDevice::enable_rssi_notifications ( std::function< void(int16_t rssi)>  callback)

Enables notifications for changes of the RSSI value of the device and triggers the callback when the value changes. Uninstalls the previous RSSI callback, if any was installed.

Parameters
callbackA function of the form void(int16_t), where bool will contain the new value of the RSSI property
void tinyb::BluetoothDevice::enable_service_data_notifications ( )

Enables notifications for changes of the service data of the device and triggers the callback when the value changes. Uninstalls the previous connected callback, if any was installed.

Parameters
callbackA function of the form void(BluetoothDevice&, bool, void *), where BluetoothDevice& is the device for which the callback was set, bool will contain the new value of the connected 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.
void tinyb::BluetoothDevice::enable_service_data_notifications ( )

Enables notifications for changes in the manufacturer data of the device and triggers the callback when the value changes. Uninstalls the previous connected callback, if any was installed.

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the connected property
void tinyb::BluetoothDevice::enable_services_resolved_notifications ( std::function< void(BluetoothDevice &device, bool services_resolved, void *userdata)>  callback,
void *  userdata 
)

Enables notifications for changes of the services resolved status of the device and triggers the callback when the value changes. Uninstalls the previous services resolved callback, if any was installed.

Parameters
callbackA function of the form void(BluetoothDevice&, bool, void *), where BluetoothDevice& is the device for which the callback was set, bool will contain the new value of the services resolved 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.
void tinyb::BluetoothDevice::enable_services_resolved_notifications ( std::function< void(bool connec)>  callback)

Enables notifications for changes of the services resolved status of the device and triggers the callback when the value changes. Uninstalls the previous services resolved callback, if any was installed.

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the services resolved property
void tinyb::BluetoothDevice::enable_trusted_notifications ( std::function< void(BluetoothDevice &device, bool trusted, void *userdata)>  callback,
void *  userdata 
)

Enables notifications for changes of the trusted status of the device and triggers the callback when the value changes. Uninstalls the previous trusted callback, if any was installed.

Parameters
callbackA function of the form void(BluetoothDevice&, bool, void *), where BluetoothDevice& is the device for which the callback was set, bool will contain the new value of the trusted 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.
void tinyb::BluetoothDevice::enable_trusted_notifications ( std::function< void(bool trusted)>  callback)

Enables notifications for changes of the trusted status of the device and triggers the callback when the value changes. Uninstalls the previous trusted callback, if any was installed.

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the trusted property
BluetoothAdapter tinyb::BluetoothDevice::get_adapter ( )

Returns the adapter on which this device was discovered or connected.

Returns
The adapter.
std::string tinyb::BluetoothDevice::get_address ( )

Returns the hardware address of this device.

Returns
The hardware address of this device.
std::string tinyb::BluetoothDevice::get_alias ( )

Returns an alternative friendly name of this device.

Returns
The alternative friendly name of this device, or NULL if not set.
uint16_t tinyb::BluetoothDevice::get_appearance ( )

Returns the appearance of the device, as found by GAP service.

Returns
The appearance of the device, as found by GAP service.
bool tinyb::BluetoothDevice::get_blocked ( )

Returns the blocked state the device.

Returns
The blocked state of the device.
virtual BluetoothType tinyb::BluetoothDevice::get_bluetooth_type ( ) const
virtual

Returns the BluetoothType of this object

Returns
The BluetoothType of this object

Reimplemented from tinyb::BluetoothObject.

unsigned int tinyb::BluetoothDevice::get_class ( )

Returns the Bluetooth class of the device.

Returns
The Bluetooth class of the device.
virtual std::string tinyb::BluetoothDevice::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.

bool tinyb::BluetoothDevice::get_connected ( )

Returns the connected state of the device.

Returns
The connected state of the device.
std::unique_ptr<std::string> tinyb::BluetoothDevice::get_icon ( )

Returns the proposed icon name of the device.

Returns
The proposed icon name, or NULL if not set.
virtual std::string tinyb::BluetoothDevice::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::BluetoothDevice::get_legacy_pairing ( )

Returns if device uses only pre-Bluetooth 2.1 pairing mechanism.

Returns
True if device uses only pre-Bluetooth 2.1 pairing mechanism.
std::map<uint16_t, std::vector<uint8_t> > tinyb::BluetoothDevice::get_manufacturer_data ( )

Returns a map containing manufacturer specific advertisement data. An entry has a uint16_t key and an array of bytes.

Returns
manufacturer specific advertisement data.
std::unique_ptr<std::string> tinyb::BluetoothDevice::get_modalias ( )

Returns the local ID of the adapter, or nullptr.

Returns
The local ID of the adapter, or nullptr.
std::string tinyb::BluetoothDevice::get_name ( )

Returns the remote friendly name of this device.

Returns
The remote friendly name of this device, or NULL if not set.
virtual std::string tinyb::BluetoothDevice::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.

bool tinyb::BluetoothDevice::get_paired ( )

Returns the paired state the device.

Returns
The paired state of the device.
int16_t tinyb::BluetoothDevice::get_rssi ( )

Returns the Received Signal Strength Indicator of the device (0 means unknown).

Returns
The Received Signal Strength Indicator of the device (0 means unknown).
std::map<std::string, std::vector<uint8_t> > tinyb::BluetoothDevice::get_service_data ( )

Returns a map containing service advertisement data. An entry has a UUID string key and an array of bytes.

Returns
service advertisement data.
std::vector<std::unique_ptr<BluetoothGattService> > tinyb::BluetoothDevice::get_services ( )

Returns a list of BluetoothGattServices available on this device.

Returns
A list of BluetoothGattServices available on this device, NULL if an error occurred
bool tinyb::BluetoothDevice::get_services_resolved ( )

Returns true if service discovery has ended.

Returns
true if the service discovery has ended.
bool tinyb::BluetoothDevice::get_trusted ( )

Returns the trusted state the device.

Returns
The trusted state of the device.
int16_t tinyb::BluetoothDevice::get_tx_power ( )

Returns the transmission power level (0 means unknown).

Returns
the transmission power level (0 means unknown).
std::vector<std::string> tinyb::BluetoothDevice::get_uuids ( )

Returns the UUIDs of the device.

Returns
Array containing the UUIDs of the device, ends with NULL.
bool tinyb::BluetoothDevice::pair ( )

A connection to this device is established, and the device is then paired.

Returns
TRUE if the device connected and paired
bool tinyb::BluetoothDevice::remove_device ( )

Remove the current device (like an unpair).

Returns
true if the device has been removed from the system.
void tinyb::BluetoothDevice::set_alias ( const std::string &  value)

Sets an alternative friendly name of this device.

void tinyb::BluetoothDevice::set_blocked ( bool  value)

Sets the blocked state the device.

void tinyb::BluetoothDevice::set_trusted ( bool  value)

Sets the trusted state the device.


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