![]() |
C++ API
|
Base class for all PLUX devices. More...
#include <baseDevPlux.h>
Public Member Functions | |
BaseDev (const String &path) | |
Connects to a PLUX device. More... | |
virtual | ~BaseDev (void) |
Disconnects from the device. More... | |
Properties | getProperties (void) |
Returns the device properties. More... | |
float | getBattery (void) |
Returns the remaining battery charge as a percentage of full capacity. More... | |
void | setTimeout (int timeout=-1) |
Sets the receiving timeout value for loop(). More... | |
void | loop (void) |
Runs the device message loop. More... | |
void | interrupt (void *param=NULL) |
Sends an interrupt signal to loop(). More... | |
virtual bool | onEvent (const Event &evt) |
Event callback. More... | |
virtual bool | onTimeout (void) |
Timeout callback. More... | |
virtual bool | onInterrupt (void *param) |
Interrupt signal callback. More... | |
Static Public Member Functions | |
static DevInfos | findDevices (const String &domain="") |
Finds PLUX devices within the given domain. More... | |
Base class for all PLUX devices.
This class provides the basic functionality common to all PLUX devices. A BaseDev device can be instantiated if a specific device functionality is not required. A BaseDev instance can be promoted afterwards to a derived class instance, based of device properties. This promotion is done by passing the BaseDev instance to the constructor of the derived class.
Alternatively, a derived class can be directly instantiated from the path string if a specific device functionality is required.
It is not possible to demote a derived class instance to a BaseDev instance.
Plux::BaseDev::BaseDev | ( | const String & | path | ) |
Connects to a PLUX device.
path | Path to the PLUX device. It can be a Classic Bluetooth MAC address ("xx:xx:xx:xx:xx:xx" or "BTHxx:xx:xx:xx:xx:xx"), a Bluetooth Low Energy MAC address ("BLExx:xx:xx:xx:xx:xx"), a serial port ("COMx") or an USB connection ("USB" or "USBx"). |
|
virtual |
Disconnects from the device.
If the device is in real-time acquisition (through SignalsDev.start()), it is automatically stopped.
Finds PLUX devices within the given domain.
domain | Domain of search (optional). It can be "BTH" for a Classic Bluetooth search, "BLE" for a Bluetooth Low Energy search, or "USB" for an USB search. If it is not given (or if it is an empty string), a search is attempted in all domains. |
Properties Plux::BaseDev::getProperties | ( | void | ) |
Returns the device properties.
The device properties map String keywords to Variant values. The currently defined keywords are:
Keyword | Meaning |
---|---|
description | Device description string |
fwVersion | Device firmware version |
hwVersion | Device hardware version (not present in old devices) |
memorySize | Device internal memory size in kBytes (only on MemoryDev instances) (zero if internal memory is not available) |
path | Device path string as passed to constructor |
productID | Device product identifier |
uid | Device unique identifier string |
The fwVersion
, hwVersion
and productID
properties are composed of two numbers (the major and minor numbers). These properties and are coded as 2-byte integers where the higher byte is the major number and the lower byte is the minor number.
float Plux::BaseDev::getBattery | ( | void | ) |
Returns the remaining battery charge as a percentage of full capacity.
The returned value is -1 if the device is charging.
void Plux::BaseDev::setTimeout | ( | int | timeout = -1 | ) |
Sets the receiving timeout value for loop().
timeout | Timeout value in milliseconds (optional). If timeout is 0, an immediate timeout condition occurs in loop() if there are no pending messages from device to dispatch. If timeout is not given or if it is -1, a timeout condition never occurs. |
void Plux::BaseDev::loop | ( | void | ) |
Runs the device message loop.
The message loop receives and dispatches the messages from the device to the callbacks. This method returns when a callback returns True.
void Plux::BaseDev::interrupt | ( | void * | param = NULL | ) |
Sends an interrupt signal to loop().
This method can be called from a thread while loop() is running on another thread. The onInterrupt() callback will be called from loop() (in the context of its thread).
param | An optional parameter to be passed to onInterrupt() callback. |
|
inlinevirtual |
Event callback.
This callback is called by message loop when an event is received from the device. In order to receive device events, an application must derive BaseDev class (or any of its derived classes) to a new class and override this method in the new class.
evt | Received event, which can be a EvtDigInUpdate, EvtDisconnect, EvtSchedChange or EvtSync object. |
|
inlinevirtual |
Timeout callback.
This callback is called by message loop when a timeout condition occurred. In order to receive timeout conditions, an application must derive BaseDev class (or any of its derived classes) to a new class and override this method in the new class.
|
inlinevirtual |
Interrupt signal callback.
This callback is called by message loop after interrupt() is called from another thread. In order to receive interrupt signals, an application must derive BaseDev class (or any of its derived classes) to a new class and override this method in the new class.
param | Optional parameter passed to interrupt() (or NULL if no parameter was given). |