TinyB  0.5.1
TinyB - The Tiny Bluetooth LE library
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
tinyb::BluetoothManager Class Reference
Inheritance diagram for tinyb::BluetoothManager:
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
 
void add_event (std::shared_ptr< BluetoothEvent > &event)
 
void remove_event (std::shared_ptr< BluetoothEvent > &event)
 
void remove_event (BluetoothEvent &event)
 
template<class T >
std::unique_ptr< T > find (std::string *name, std::string *identifier, BluetoothObject *parent, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero())
 
std::unique_ptr< BluetoothObjectfind (BluetoothType type, std::string *name, std::string *identifier, BluetoothObject *parent, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero())
 
std::weak_ptr< BluetoothEventfind (BluetoothType type, std::string *name, std::string *identifier, BluetoothObject *parent, BluetoothCallback cb, bool execute_once=true, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero())
 
std::unique_ptr< BluetoothObjectget_object (BluetoothType type, std::string *name, std::string *identifier, BluetoothObject *parent)
 
std::vector< std::unique_ptr< BluetoothObject > > get_objects (BluetoothType type=BluetoothType::NONE, std::string *name=nullptr, std::string *identifier=nullptr, BluetoothObject *parent=nullptr)
 
std::vector< std::unique_ptr< BluetoothAdapter > > get_adapters ()
 
std::vector< std::unique_ptr< BluetoothDevice > > get_devices ()
 
std::vector< std::unique_ptr< BluetoothGattService > > get_services ()
 
bool set_default_adapter (BluetoothAdapter &adapter)
 
std::unique_ptr< BluetoothAdapterget_default_adapter ()
 
bool start_discovery ()
 
bool stop_discovery ()
 
bool get_discovering ()
 
- Public Member Functions inherited from tinyb::BluetoothObject
virtual BluetoothObjectclone () const
 
virtual bool operator== (const BluetoothObject &other) const
 
virtual bool operator!= (const BluetoothObject &other) const
 

Static Public Member Functions

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

Protected Member Functions

void handle_event (BluetoothType type, std::string *name, std::string *identifier, BluetoothObject *parent, BluetoothObject &object)
 
- Protected Member Functions inherited from tinyb::BluetoothObject
bool lock ()
 
void unlock ()
 

Friends

class BluetoothAdapter
 
class BluetoothDevice
 
class BluetoothGattService
 
class BluetoothGattCharacteristic
 
class BluetoothGattDescriptor
 
class BluetoothEventManager
 

Additional Inherited Members

- Protected Attributes inherited from tinyb::BluetoothObject
std::mutex lk
 
std::atomic_bool valid
 

Member Function Documentation

void tinyb::BluetoothManager::add_event ( std::shared_ptr< BluetoothEvent > &  event)
inline

Add event to checked against events generated by BlueZ. If an the event matches an incoming event its' callback will be triggered. Events can be the addition of a new Device, GattService, GattCharacteristic, etc.

template<class T >
std::unique_ptr<T> tinyb::BluetoothManager::find ( std::string *  name,
std::string *  identifier,
BluetoothObject parent,
std::chrono::milliseconds  timeout = std::chrono::milliseconds::zero() 
)
inline

Find a BluetoothObject of type T. If parameters name, identifier and parent are not null, the returned object will have to match them. It will first check for existing objects. It will not turn on discovery or connect to devices. name optionally specify the name of the object you are waiting for (for Adapter or Device) identifier optionally specify the identifier of the object you are waiting for (UUID for GattService, GattCharacteristic or GattDescriptor, address for Adapter or Device) parent optionally specify the parent of the object you are waiting for timeout the function will return after timeout time, a value of zero means wait forever. If object is not found during this time null will be returned.

Returns
An object matching the name, identifier, parent or null if not found before timeout expires or event is canceled.
std::unique_ptr<BluetoothObject> tinyb::BluetoothManager::find ( BluetoothType  type,
std::string *  name,
std::string *  identifier,
BluetoothObject parent,
std::chrono::milliseconds  timeout = std::chrono::milliseconds::zero() 
)

Find a BluetoothObject of a type matching type. If parameters name, identifier and parent are not null, the returned object will have to match them. It will first check for existing objects. It will not turn on discovery or connect to devices. type specify the type of the object you are waiting for, NONE means anything. name optionally specify the name of the object you are waiting for (for Adapter or Device) identifier optionally specify the identifier of the object you are waiting for (UUID for GattService, GattCharacteristic or GattDescriptor, address for Adapter or Device) parent optionally specify the parent of the object you are waiting for timeout the function will return after timeout time, a value of zero means wait forever. If object is not found during this time null will be returned.

Returns
An object matching the name, identifier, parent or null if not found before timeout expires or event is canceled.
std::weak_ptr<BluetoothEvent> tinyb::BluetoothManager::find ( BluetoothType  type,
std::string *  name,
std::string *  identifier,
BluetoothObject parent,
BluetoothCallback  cb,
bool  execute_once = true,
std::chrono::milliseconds  timeout = std::chrono::milliseconds::zero() 
)

Find a BluetoothObject of a type matching type. If parameters name, identifier and parent are not null, the found object will have to match them. The callback cb will be triggered when a match is made. Only new objects will trigger the callback. type specify the type of the object you are waiting for, NONE means anything. name optionally specify the name of the object you are waiting for (for Adapter or Device) identifier optionally specify the identifier of the object you are waiting for (UUID for GattService, GattCharacteristic or GattDescriptor, address for Adapter or Device) parent optionally specify the parent of the object you are waiting for timeout the function will return after timeout time, a value of zero means wait forever. If object is not found during this time null will be returned.

Returns
It returns the BluetoothEvent generated by this function, allowing to manage the parameters or cancel the event.
std::vector<std::unique_ptr<BluetoothAdapter> > tinyb::BluetoothManager::get_adapters ( )

Returns a list of BluetoothAdapters available in the system

Returns
A list of BluetoothAdapters available in the system
static BluetoothManager* tinyb::BluetoothManager::get_bluetooth_manager ( )
static

Returns an instance of BluetoothManager, to be used instead of constructor.

Returns
An initialized BluetoothManager instance.
virtual BluetoothType tinyb::BluetoothManager::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::BluetoothManager::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::BluetoothManager::get_devices ( )

Returns a list of discovered BluetoothDevices

Returns
A list of discovered BluetoothDevices
bool tinyb::BluetoothManager::get_discovering ( )

Returns if the discovers is running or not.

Returns
TRUE if discovery is running
virtual std::string tinyb::BluetoothManager::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<BluetoothObject> tinyb::BluetoothManager::get_object ( BluetoothType  type,
std::string *  name,
std::string *  identifier,
BluetoothObject parent 
)

Return a BluetoothObject of a type matching type. If parameters name, identifier and parent are not null, the returned object will have to match them. Only objects which are already in the system will be returned. type specify the type of the object you are waiting for, NONE means anything. name optionally specify the name of the object you are waiting for (for Adapter or Device) identifier optionally specify the identifier of the object you are waiting for (UUID for GattService, GattCharacteristic or GattDescriptor, address for Adapter or Device) parent optionally specify the parent of the object you are waiting for

Returns
An object matching the name, identifier, parent or null if not found.
virtual std::string tinyb::BluetoothManager::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.

std::vector<std::unique_ptr<BluetoothObject> > tinyb::BluetoothManager::get_objects ( BluetoothType  type = BluetoothType::NONE,
std::string *  name = nullptr,
std::string *  identifier = nullptr,
BluetoothObject parent = nullptr 
)

Return a vector of BluetoothObject of a type matching type. If parameters name, identifier and parent are not null, the returned object will have to match them. Only objects which are already in the system will be returned. type specify the type of the object you are waiting for, NONE means anything. name optionally specify the name of the object you are waiting for (for Adapter or Device) identifier optionally specify the identifier of the object you are waiting for (UUID for GattService, GattCharacteristic or GattDescriptor, address for Adapter or Device) parent optionally specify the parent of the object you are waiting for

Returns
A vector of object matching the name, identifier, parent.
std::vector<std::unique_ptr<BluetoothGattService> > tinyb::BluetoothManager::get_services ( )

Returns a list of available BluetoothGattServices

Returns
A list of available BluetoothGattServices
void tinyb::BluetoothManager::remove_event ( std::shared_ptr< BluetoothEvent > &  event)
inline

Remove event to checked against events generated by BlueZ.

bool tinyb::BluetoothManager::set_default_adapter ( BluetoothAdapter adapter)

Sets a default adapter to use for discovery.

Returns
TRUE if the device was set
bool tinyb::BluetoothManager::start_discovery ( )

Turns on device discovery on the default adapter if it is disabled.

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

Turns off device discovery on the default adapter if it is enabled.

Returns
TRUE if discovery was successfully disabled

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