4S Device Communication Module Collection
Version 0.6-SNAPSHOT
Public interfaces of the modules in the 4SDC collection (aimed at users of the 4SDC modules)
|
|
The PAL interface for communication with personal health devices. More...
#include <personalhealthdevice.h>
Protected Member Functions | |
virtual void | registerDatatype (uint16_t datatype)=0 |
Registers a session-layer component as handler of a datatype. More... | |
virtual void | unregisterDatatype (uint16_t datatype) noexcept=0 |
Unregisters a session-layer component as handler of a datatype. More... | |
virtual void | connectIndication (std::shared_ptr< VirtualPHD > device) noexcept=0 |
Indicates the connection of a new device. More... | |
virtual void | disconnectIndication (std::shared_ptr< VirtualPHD > device, errortype error=0) noexcept=0 |
Indicates a device disconnection along with error details. More... | |
virtual void | apduReceived (std::shared_ptr< VirtualPHD > device, std::shared_ptr< std::vector< uint8_t > > apdu, bool reliableTransport) noexcept=0 |
Receive a message from this device. More... | |
virtual void | sendApduPrimary (std::shared_ptr< VirtualPHD > device, std::shared_ptr< std::vector< uint8_t > > apdu) noexcept=0 |
Send a message to this device on the primary virtual channel. More... | |
virtual void | disconnect (std::shared_ptr< VirtualPHD > device) noexcept=0 |
Disconnect the device. More... | |
The communication between transport components in the PAL layer and session-layer components is defined by this class.
All possible signals communicated across the PAL interface are realized as methods of this class. Some are implemented by the session layer and called from the PAL layer, while others travels in the opposite direction. Two abstract subclasses of this class, PersonalHealthDeviceProviderBase and PersonalHealthDeviceHandler manages the magic of wrapping these method calls in messages and sending them back and forth between the modules. The PersonalHealthDeviceHandler will be extended by a class in the session layer, while the PersonalHealthDeviceProviderBase is extended by a class in the PAL layer (a component of the appropriate transport).
The PersonalHealthDeviceProviderBase and PersonalHealthDeviceHandler classes will keep track of which PAL- and session-layer components handles which PersonalHealthDevice, and make sure the messages are forwarded appropriately. A few messages does not relate to particular devices, and these messages will instead be broadcast to all possible peers.
|
protectedpure virtualnoexcept |
A PAL-to-protocol message. A message arrived from a connected device. This device was previously announced by the connectIndication() signal and has not yet been disconnected.
device | The source of the message. |
apdu | The buffer of bytes received from the device. |
reliableTransport | The message arrived on a reliable transport channel. |
Implemented in PAL::PersonalHealthDeviceProviderBase.
|
protectedpure virtualnoexcept |
A PAL-to-protocol message. A new device has been connected at the PAL layer and is now available for the session layer.
The message magic implemented by PersonalHealthDeviceProviderBase and PersonalHealthDeviceHandler will choose a session-layer component which has previously registered itself for the datatype matching this device using registerDatatype() and establish a one-to-one connection. If no session-layer component is currently registered, the message will be dropped.
device | The device that was just connected. |
Implemented in PAL::PersonalHealthDeviceProviderBase.
|
protectedpure virtualnoexcept |
A protocol-to-PAL message. If the device is currently connected, it will be disconnected immediately (and a disconnectIndication() will be returned from the PAL shortly), otherwise nothing will happen.
device | The device, we wish to disconnect. |
Implemented in PAL::PersonalHealthDeviceHandler.
|
protectedpure virtualnoexcept |
A PAL-to-protocol message. A device (which was previously connected using connectIndication()) has been disconnected. It is no longer available for the session layer. No more messageReceived() signals will ever be emitted for this object, and sendMessage() attempts will be discarded. The session layer should forget all about this object and delete all references.
Notice that this message also cuts the link between the PAL and session layer components, so no more messages regarding this device can be communicated until the PAL layer emits a new connectionIndication() (which, by-the-way, may choose to connect the device to a different protocol component, if more are available).
The optional error argument carries detailed information of an error in the PAL-layer component that caused this disconnection. The usage of this argument is completely optional for the PAL component – it is always allowed to use the non-error variant instead. The session-layer component may also choose to ignore the error argument; however, it is recommended that the session layer should forward the error message to the application layer in some way, to allow the error message to be presented to the user, if relevant.
device | The device object, which will no longer be in use. |
error | An error code (optional - defaults to "no error"). |
Implemented in PAL::PersonalHealthDeviceProviderBase.
|
protectedpure virtual |
A protocol-to-PAL message. This message is issued by the session-layer component, when it is ready to handle a given datatype. When the component no longer handles the datatype, the unregisterDatatype() is used to stop new connections of that particular datatype.
The datatype must be one of the IEEE MDC_DEV_SPEC_PROFILE_
codes belonging to the MDC_PART_INFRA
partition.
The PersonalHealthDeviceProviderBase and PersonalHealthDeviceHandler classes will keep track of which session-layer components handles which datatypes, and will broadcast the registerDatatype() and unregisterDatatype() messages to all PAL-layer components when a previously unhandled datatype is registered for the first time and when a datatype is no longer being handled.
Except in the unlikely event of memory exhaustion, this method should never throw any exceptions.
datatype | The datatype handled by this component. |
std::bad_alloc | in case of memory exhaustion. |
Implemented in PAL::PersonalHealthDeviceHandler, and PAL::BluetoothModule.
|
protectedpure virtualnoexcept |
A protocol-to-PAL message. If the device is currently connected, this method will (attempt to) send a message to the device on the primary virtual channel (which by definition is a reliable transport service). There will be no indication of whether this attempt was succesful or not. In particular, if this device object is currently not connected, the method invocation will be ignored.
device | The device, we are sending to. |
apdu | The buffer of bytes to transmit to the device. |
Implemented in PAL::PersonalHealthDeviceHandler.
|
protectedpure virtualnoexcept |
A protocol-to-PAL message. This message is issued by the session-layer component, when it no longer wishes to handle the given datatype. For more details, see the documentation of the registerDatatype() method.
datatype | The datatype no longer handled by this component. |
Implemented in PAL::PersonalHealthDeviceHandler, and PAL::BluetoothModule.