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

#include <BluetoothAdapter.hpp>

Inheritance diagram for tinyb::BluetoothAdapter:
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
 
 BluetoothAdapter (const BluetoothAdapter &object)
 
virtual BluetoothAdapterclone () const
 
std::unique_ptr< BluetoothDevicefind (std::string *name, std::string *identifier, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero())
 
bool remove_device (const std::string &arg_device)
 
bool start_discovery ()
 
bool stop_discovery ()
 
bool set_discovery_filter (std::vector< BluetoothUUID > uuids, int16_t rssi, uint16_t pathloss, const TransportType &transport)
 
std::vector< std::unique_ptr< BluetoothDevice > > get_devices ()
 
std::string get_address ()
 
std::string get_name ()
 
std::string get_alias ()
 
void set_alias (const std::string &value)
 
unsigned int get_class ()
 
bool get_powered ()
 
void set_powered (bool value)
 
void enable_powered_notifications (std::function< void(BluetoothAdapter &adapter, bool powered, void *userdata)> callback, void *userdata)
 
void enable_powered_notifications (std::function< void(bool powered)> callback)
 
void disable_powered_notifications ()
 
bool get_discoverable ()
 
void set_discoverable (bool value)
 
void enable_discoverable_notifications (std::function< void(BluetoothAdapter &adapter, bool discoverable, void *userdata)> callback, void *userdata)
 
void enable_discoverable_notifications (std::function< void(bool discoverable)> callback)
 
void disable_discoverable_notifications ()
 
unsigned int get_discoverable_timeout ()
 
void set_discoverable_timeout (unsigned int value)
 
bool get_pairable ()
 
void set_pairable (bool value)
 
void enable_pairable_notifications (std::function< void(BluetoothAdapter &adapter, bool pairable, void *userdata)> callback, void *userdata)
 
void enable_pairable_notifications (std::function< void(bool pairable)> callback)
 
void disable_pairable_notifications ()
 
unsigned int get_pairable_timeout ()
 
void set_pairable_timeout (unsigned int value)
 
bool get_discovering ()
 
void enable_discovering_notifications (std::function< void(BluetoothAdapter &adapter, bool discovering, void *userdata)> callback, void *userdata)
 
void enable_discovering_notifications (std::function< void(bool discovering)> callback)
 
void disable_discovering_notifications ()
 
std::vector< std::string > get_uuids ()
 
std::unique_ptr< std::string > get_modalias ()
 
- 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

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

Static Protected Member Functions

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

Protected Attributes

std::function< void(bool)> powered_callback
 
std::function< void(bool)> discoverable_callback
 
std::function< void(bool)> pairable_callback
 
std::function< void(bool)> discovering_callback
 
- Protected Attributes inherited from tinyb::BluetoothObject
std::mutex lk
 
std::atomic_bool valid
 

Friends

class tinyb::BluetoothManager
 
class tinyb::BluetoothEventManager
 
class tinyb::BluetoothDevice
 
class tinyb::BluetoothNotificationHandler
 

Detailed Description

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

Member Function Documentation

virtual BluetoothAdapter* tinyb::BluetoothAdapter::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.

void tinyb::BluetoothAdapter::disable_discoverable_notifications ( )

Disables notifications for changes of the discoverable status of the adapter and uninstalls any callback;

void tinyb::BluetoothAdapter::disable_discovering_notifications ( )

Disables notifications for changes of the discovering status of the adapter and uninstalls any callback;

void tinyb::BluetoothAdapter::disable_pairable_notifications ( )

Disables notifications for changes of the pairable status of the adapter and uninstalls any callback;

void tinyb::BluetoothAdapter::disable_powered_notifications ( )

Disables notifications for changes of the powered status of the adapter and uninstalls any callback.

void tinyb::BluetoothAdapter::enable_discoverable_notifications ( std::function< void(BluetoothAdapter &adapter, bool discoverable, void *userdata)>  callback,
void *  userdata 
)

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

Parameters
callbackA function of the form void(BluetoothAdapter&, bool, void *), where BluetoothAdapter& is the adapter for which the callback was set, bool will contain the new value of the discoverable 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::BluetoothAdapter::enable_discoverable_notifications ( std::function< void(bool discoverable)>  callback)

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

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the discoverable property
void tinyb::BluetoothAdapter::enable_discovering_notifications ( std::function< void(BluetoothAdapter &adapter, bool discovering, void *userdata)>  callback,
void *  userdata 
)

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

Parameters
callbackA function of the form void(BluetoothAdapter&, bool, void *), where BluetoothAdapter& is the adapter for which the callback was set, bool will contain the new value of the discovering 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::BluetoothAdapter::enable_discovering_notifications ( std::function< void(bool discovering)>  callback)

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

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the discovering property
void tinyb::BluetoothAdapter::enable_pairable_notifications ( std::function< void(BluetoothAdapter &adapter, bool pairable, void *userdata)>  callback,
void *  userdata 
)

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

Parameters
callbackA function of the form void(BluetoothAdapter&, bool, void *), where BluetoothAdapter& is the adapter for which the callback was set, bool will contain the new value of the pairable 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::BluetoothAdapter::enable_pairable_notifications ( std::function< void(bool pairable)>  callback)

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

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the pairable property
void tinyb::BluetoothAdapter::enable_powered_notifications ( std::function< void(BluetoothAdapter &adapter, bool powered, void *userdata)>  callback,
void *  userdata 
)

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

Parameters
callbackA function of the form void(BluetoothAdapter&, bool, void *), where BluetoothAdapter& 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.
void tinyb::BluetoothAdapter::enable_powered_notifications ( std::function< void(bool powered)>  callback)

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

Parameters
callbackA function of the form void(bool), where bool will contain the new value of the powered property
std::string tinyb::BluetoothAdapter::get_address ( )

Returns the hardware address of this adapter.

Returns
The hardware address of this adapter.
std::string tinyb::BluetoothAdapter::get_alias ( )

Returns the friendly name of this adapter.

Returns
The friendly name of this adapter.
virtual BluetoothType tinyb::BluetoothAdapter::get_bluetooth_type ( ) const
virtual

Returns the BluetoothType of this object

Returns
The BluetoothType of this object

Reimplemented from tinyb::BluetoothObject.

unsigned int tinyb::BluetoothAdapter::get_class ( )

Returns the Bluetooth class of the adapter.

Returns
The Bluetooth class of the adapter.
virtual std::string tinyb::BluetoothAdapter::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<BluetoothDevice> > tinyb::BluetoothAdapter::get_devices ( )

Returns a list of BluetoothDevices visible from this adapter.

Returns
A list of BluetoothDevices visible on this adapter, NULL if an error occurred
bool tinyb::BluetoothAdapter::get_discoverable ( )

Returns the discoverable state the adapter.

Returns
The discoverable state of the adapter.
unsigned int tinyb::BluetoothAdapter::get_discoverable_timeout ( )

Returns the discoverable timeout the adapter.

Returns
The discoverable timeout of the adapter.
bool tinyb::BluetoothAdapter::get_discovering ( )

Returns the discovering state the adapter. It can be modified through start_discovery/stop_discovery functions.

Returns
The discovering state of the adapter.
virtual std::string tinyb::BluetoothAdapter::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.

std::unique_ptr<std::string> tinyb::BluetoothAdapter::get_modalias ( )

Returns the local ID of the adapter.

Returns
The local ID of the adapter.
std::string tinyb::BluetoothAdapter::get_name ( )

Returns the system name of this adapter.

Returns
The system name of this adapter.
virtual std::string tinyb::BluetoothAdapter::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::BluetoothAdapter::get_pairable ( )

Returns the pairable state the adapter.

Returns
The pairable state of the adapter.
unsigned int tinyb::BluetoothAdapter::get_pairable_timeout ( )

Returns the timeout in seconds after which pairable state turns off automatically, 0 means never.

Returns
The pairable timeout of the adapter.
bool tinyb::BluetoothAdapter::get_powered ( )

Returns the power state the adapter.

Returns
The power state of the adapter.
std::vector<std::string> tinyb::BluetoothAdapter::get_uuids ( )

Returns the UUIDs of the adapter.

Returns
Array containing the UUIDs of the adapter, ends with NULL.
bool tinyb::BluetoothAdapter::remove_device ( const std::string &  arg_device)

Removes a device from the list of devices available on this adapter.

Parameters
[in]arg_deviceThe path of the device on DBus
Returns
TRUE if device was successfully removed
void tinyb::BluetoothAdapter::set_alias ( const std::string &  value)

Sets the friendly name of this adapter.

void tinyb::BluetoothAdapter::set_discoverable ( bool  value)

Sets the discoverable state the adapter.

void tinyb::BluetoothAdapter::set_discoverable_timeout ( unsigned int  value)

Sets the discoverable timeout the adapter. A value of 0 disables the timeout.

bool tinyb::BluetoothAdapter::set_discovery_filter ( std::vector< BluetoothUUID uuids,
int16_t  rssi,
uint16_t  pathloss,
const TransportType &  transport 
)

Sets the device discovery filter for the caller. If all fields are empty, filter is removed.

Parameters
uuidsVector of UUIDs to filter on
rssiRSSI low bounded threshold
pathlossPathloss threshold value
transportType of scan to run
void tinyb::BluetoothAdapter::set_pairable ( bool  value)

Sets the discoverable state the adapter.

void tinyb::BluetoothAdapter::set_pairable_timeout ( unsigned int  value)

Sets the timeout after which pairable state turns off automatically, 0 means never.

void tinyb::BluetoothAdapter::set_powered ( bool  value)

Sets the power state the adapter.

bool tinyb::BluetoothAdapter::start_discovery ( )

Turns on device discovery if it is disabled.

Returns
TRUE if discovery was successfully enabled
bool tinyb::BluetoothAdapter::stop_discovery ( )

Turns off device discovery if it is enabled.

Returns
TRUE if discovery was successfully disabled

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