BeeeOn Gateway
v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
|
The class realizes communication with BlueZ deamon using D-Bus. It allows to find new BLE and Bluetooth Classic devices and send read/write requests. More...
#include <DBusHciInterface.h>
Data Structures | |
class | Device |
The class represents the Bluetooth Low Energy device and stores necessary data about device such as instance of device, handle of signal and timestamp of last rssi update. Also the class allows to store necessary data (signal handle, pointer to callback) when the device is watched. More... | |
Public Types | |
typedef Poco::SharedPtr < DBusHciInterface > | Ptr |
typedef std::function< bool(const std::string &path)> | PathFilter |
typedef std::pair < Poco::FastMutex, std::map < MACAddress, Device > > | ThreadSafeDevices |
Public Types inherited from BeeeOn::HciInterface | |
typedef Poco::SharedPtr < HciInterface > | Ptr |
typedef std::function< void(const MACAddress &, std::vector < unsigned char > &)> | WatchCallback |
Public Member Functions | |
DBusHciInterface (const std::string &name, const Poco::Timespan &leMaxAgeRssi, const Poco::Timespan &leMaxUnavailabilityTime, const Poco::Timespan &classicArtificialAvaibilityTimeout) | |
void | down () const |
Sets hci interface down. More... | |
void | up () const override |
void | reset () const override |
bool | detect (const MACAddress &address) const override |
Uses detect method of BluezHciInterface class to check state of device with MACAddress. If the device is unavailable and has been seen within a certain time (m_classicUnavailableMaxAge), the method returns true. | |
std::map< MACAddress, std::string > | scan () const override |
Uses scan method of BluezHciInterface class to discover the bluetooh classic devices. | |
std::map< MACAddress, std::string > | lescan (const Poco::Timespan &timeout) const override |
Scans the Bluetooth LE network and returns all available devices. The method returns devices whitch updated their RSSI before the given time. | |
HciInfo | info () const override |
Uses BluezHciInterface to retrieve hci info. | |
HciConnection::Ptr | connect (const MACAddress &address, const Poco::Timespan &timeout) const override |
void | watch (const MACAddress &address, Poco::SharedPtr< WatchCallback > callBack) override |
void | unwatch (const MACAddress &address) override |
Static Protected Member Functions | |
static gboolean | onStopLoop (gpointer loop) |
Callback handling the timeout event which stops the given GMainLoop. | |
static void | onDBusObjectAdded (GDBusObjectManager *objectManager, GDBusObject *object, gpointer userData) |
Callback handling the event of creating new device. The method adds the new device to m_devices and register onDeviceRSSIChanged callback. | |
static gboolean | onDeviceRSSIChanged (OrgBluezDevice1 *device, GVariant *properties, const gchar *const *invalidatedProperties, gpointer userData) |
Callback handling the event of RSSI changed. It is used to detecting that the device is available. | |
static gboolean | onDeviceManufacturerDataRecieved (OrgBluezDevice1 *device, GVariant *properties, const gchar *const *invalidatedProperties, gpointer userData) |
Callback handling the event of receiving advertising data. | |
static void | processManufacturerData (OrgBluezDevice1 *device, GVariant *value, gpointer userData) |
Process the single advertising data and call callback stored in userData. | |
Friends | |
class | DBusHciConnection |
The class realizes communication with BlueZ deamon using D-Bus. It allows to find new BLE and Bluetooth Classic devices and send read/write requests.
The class uses BluezHciInterface to work with Bluetooth Classic devices and to retrieve hci info. It requires a running instance of the D-Bus service "org.bluez" to work wth BLE devices. Firstly it is needed to find BLE devices in a bluetooth network to create D-Bus device objects. Accessing the BLE devices is possible via D-Bus device objects (defined by path "/org/bluez/hci0/dev_FF_FF_FF_FF_FF_FF"). The D-Bus device objects provide methods to perform actions as connect, read, write and disconnect.
DBusHciInterface::DBusHciInterface | ( | const std::string & | name, |
const Poco::Timespan & | leMaxAgeRssi, | ||
const Poco::Timespan & | leMaxUnavailabilityTime, | ||
const Poco::Timespan & | classicArtificialAvaibilityTimeout | ||
) |
name | name of hci |
leMaxAgeRssi | maximum time from the rssi update of the device to declare the device is available |
leMaxUnavailabilityTime | maximum LE device unavailability time for device to be deleted |
classicArtificialAvaibilityTimeout | maximum time from the last seen of the device to declare the device is available |
|
overridevirtual |
Connects to device defined by MAC address and loads it's services.
IOException | in case of a failure |
Implements BeeeOn::HciInterface.
void DBusHciInterface::down | ( | ) | const |
Sets hci interface down.
IOException | in case of a failure |
|
overridevirtual |
Reset hci interface - turn down & up.
IOException | in case of a failure |
Implements BeeeOn::HciInterface.
|
overridevirtual |
Unregister device to process advertising data.
Implements BeeeOn::HciInterface.
|
overridevirtual |
Try to set hci interface up. The root priviledges of the system might be required.
IOException | in case of a failure |
Implements BeeeOn::HciInterface.
|
overridevirtual |
Register device to process advertising data. After recieving advertising data, the callBack is called.
IOException | in case of a failure |
Implements BeeeOn::HciInterface.