Kallisto Linux API
Library for interacting with Kallisto devices
BluetoothDevice Class Reference

#include <bluetooth_device.hpp>

Inheritance diagram for BluetoothDevice:
Collaboration diagram for BluetoothDevice:

Public Types

typedef std::function< void(bool connected)> ConnectionListener
 

Public Member Functions

 BluetoothDevice (std::string name, std::string address)
 
virtual ~BluetoothDevice ()
 
 BluetoothDevice (BluetoothDevice const &)=delete
 
void operator= (BluetoothDevice const &)=delete
 
 BluetoothDevice (BluetoothDevice &&other)
 
BluetoothDeviceoperator= (BluetoothDevice &&other)
 
std::string getName () const
 
std::string getAddress () const
 
error::KallistoDetailedResult connect (ConnectionListener listener)
 
error::KallistoDetailedResult disconnect (bool no_callback)
 
bool getConnected ()
 
void close ()
 
error::KallistoDetailedResult getRssi (int &buffer)
 
std::vector< std::string > getServices ()
 
std::vector< std::string > getCharacteristics (std::string service_uuid)
 
error::KallistoDetailedResult readCharacteristic (std::string service_uuid, std::string characteristic_uuid, std::vector< unsigned char > &buffer)
 
error::KallistoDetailedResult writeCharacteristic (std::string service_uuid, std::string characteristic_uuid, std::vector< unsigned char > &buffer)
 
error::KallistoDetailedResult enableNotification (std::string service_uuid, std::string characteristic_uuid, BluetoothDispatcher::NotificationListener &listener)
 
error::KallistoDetailedResult disableNotification (std::string service_uuid, std::string characteristic_uuid, BluetoothDispatcher::NotificationListener &listener)
 
bool operator== (const BluetoothDevice &other) const
 
bool operator!= (const BluetoothDevice &other) const
 

Additional Inherited Members

- Protected Member Functions inherited from BluetoothDispatcher
 BluetoothDispatcher ()
 
virtual ~BluetoothDispatcher ()
 
 BluetoothDispatcher (BluetoothDispatcher const &)=delete
 
 BluetoothDispatcher (BluetoothDispatcher &&)=delete
 
void operator= (BluetoothDispatcher const &)=delete
 
void operator= (BluetoothDispatcher &&)=delete
 

Detailed Description

Class that represents a Bluetooth device.

Member Typedef Documentation

◆ ConnectionListener

typedef std::function<void(bool connected)> ConnectionListener

Called when there is a change in connection status.

Parameters
connected

Constructor & Destructor Documentation

◆ BluetoothDevice() [1/3]

BluetoothDevice ( std::string  name,
std::string  address 
)

Constructor.

◆ ~BluetoothDevice()

virtual ~BluetoothDevice ( )
virtual

Destructor.

◆ BluetoothDevice() [2/3]

BluetoothDevice ( BluetoothDevice const &  )
delete

Remove copy.

◆ BluetoothDevice() [3/3]

Move constructor.

Member Function Documentation

◆ close()

void close ( )

Cleans and closes the BLE device. It is called when the object is no longer needed and invalidates the instance.

◆ connect()

Connects to device

Parameters
listenerlistener for connection events.
Returns
A detailed result.

◆ disableNotification()

error::KallistoDetailedResult disableNotification ( std::string  service_uuid,
std::string  characteristic_uuid,
BluetoothDispatcher::NotificationListener listener 
)
virtual

Disables notifications of the the characteristic with the passed UUID of the service with the passed UUID.

Parameters
service_uuidThe UUID of the service containing the characteristic that should have its' notifications disabled.
characteristic_uuidThe UUID of the characteristic that should have its' notifications disabled.
listenerThe listener used in enableNotification(std::string, std::string, NotificationListener) call.
Returns
A detailed result.

Implements BluetoothDispatcher.

◆ disconnect()

error::KallistoDetailedResult disconnect ( bool  no_callback)

Disconnects from the device

Parameters
no_callbackSet to true if no disconnection callback is required. This allows devices to disconnect in destructor.
Returns
A detailed result.

◆ enableNotification()

error::KallistoDetailedResult enableNotification ( std::string  service_uuid,
std::string  characteristic_uuid,
BluetoothDispatcher::NotificationListener listener 
)
virtual

Enables notifications of the the characteristic with the passed UUID of the service with the passed UUID.

Parameters
service_uuidThe UUID of the service containing the characteristic that should have its' notifications enabled.
characteristic_uuidThe UUID of the characteristic that should have its' notifications enabled.
listenerThe listener to receive notifications.
Returns
A detailed result.

Implements BluetoothDispatcher.

◆ getAddress()

std::string getAddress ( ) const
inline

Returns this device address.

Returns
This device address.
Here is the call graph for this function:

◆ getCharacteristics()

std::vector<std::string> getCharacteristics ( std::string  service_uuid)
virtual

Get the remote device BLE characteristic list of the service with the passed UUID.

Parameters
service_uuidThe UUID of the service whose characteristic should be returned.
Returns
A list of UUIDs representing the BLE characteristic of the passed service. Will be empty if the service is not found.

Implements BluetoothDispatcher.

◆ getConnected()

bool getConnected ( )

Checks if the BLE device is connected

Returns
true
if connected

◆ getName()

std::string getName ( ) const
inline

Returns this device name.

Returns
This device name.

◆ getRssi()

error::KallistoDetailedResult getRssi ( int &  buffer)
virtual

Get the current RSSI value.

Parameters
[out]bufferThe RSSI value..
Returns
A detailed result.

Implements BluetoothDispatcher.

◆ getServices()

std::vector<std::string> getServices ( )
virtual

Get the remote device BLE service list.

Returns
A vector of UUIDs representing the BLE services.

Implements BluetoothDispatcher.

◆ operator=()

BluetoothDevice& operator= ( BluetoothDevice &&  other)

Move assigment.

◆ readCharacteristic()

error::KallistoDetailedResult readCharacteristic ( std::string  service_uuid,
std::string  characteristic_uuid,
std::vector< unsigned char > &  buffer 
)
virtual

Reads the characteristic with the passed UUID of the service with the passed UUID.

Parameters
[in]service_uuidThe UUID of the service containing the characteristic that should be read.
[in]characteristic_uuidThe UUID of the characteristic that should be read.
[out]bufferThe data read.
Returns
A detailed result.

Implements BluetoothDispatcher.

◆ writeCharacteristic()

error::KallistoDetailedResult writeCharacteristic ( std::string  service_uuid,
std::string  characteristic_uuid,
std::vector< unsigned char > &  buffer 
)
virtual

Writes the passed data to the characteristic with the passed UUID of the service with the passed UUID.

Parameters
[in]service_uuidThe UUID of the service containing the characteristic that should be written.
[in]characteristic_uuidThe UUID of the characteristic that should be written.
[in]bufferA byte buffer with the data to be written.
Returns
A detailed result.

Implements BluetoothDispatcher.


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