FREEDM DGI
|
Provides an interface for communicating with an MQTT broker. More...
#include <CMqttAdapter.hpp>
Classes | |
struct | DeviceData |
Public Types | |
typedef boost::shared_ptr< CMqttAdapter > | Pointer |
Pointer to a CMqttAdapater object. More... | |
Public Member Functions | |
~CMqttAdapter () | |
Destructor. More... | |
std::set< std::string > | GetDevices () const |
Get the list of registered device names. More... | |
SignalValue | GetState (const std::string device, const std::string key) const |
Retrieves a value from a device. More... | |
void | RegisterDevice (const std::string devid) |
Register a device name with the adapter. More... | |
void | SetCommand (const std::string device, const std::string key, const SignalValue value) |
Sets a value on a device. More... | |
void | Start () |
Start the MQTT client. More... | |
void | Stop () |
Stop the MQTT client. More... | |
Static Public Member Functions | |
static IAdapter::Pointer | Create (std::string id, std::string address) |
Create a CMqttAdapter object and return a point to it. More... | |
Protected Member Functions | |
void | RevealDevices () |
Reveals devices in the device manager. More... | |
Private Types | |
typedef std::map< std::string, DeviceData > | TDeviceToData |
Map from a device name to its stored signal values. More... | |
Private Member Functions | |
CMqttAdapter (std::string id, std::string address) | |
Constructor. More... | |
void | AddSignals (std::string device, boost::property_tree::ptree::value_type &ptree, std::set< std::string > &sigset, std::set< std::string > &type) |
void | CreateDevice (std::string deviceName, std::string json) |
Create a CDevice object from a JSON specification. More... | |
void | HandleMessage (std::string topic, std::string message) |
Handles messages received from subscribed topics. More... | |
void | Publish (std::string topic, std::string content) |
Publish a message on a topic to the MQTT broker. More... | |
void | SubscribeAll (std::string deviceName) |
does a full Subscribe More... | |
void | UnsubscribeAll (std::string deviceName) |
does a full UnSubscribe More... | |
Static Private Member Functions | |
static void | ConnectionLost (void *id, char *reason) |
Callback function when the client cannot reach the broker. More... | |
static void | DeliveryComplete (void *id, MQTTClient_deliveryToken token) |
Callback function when a message has been delivered to the broker. More... | |
static int | HandleMessage (void *id, char *topic, int topicLen, MQTTClient_message *msg) |
Callback function when the client receives a message about a subscribed topic. More... | |
Private Attributes | |
MQTTClient | m_Client |
MQTT client object. More... | |
TDeviceToData | m_DeviceData |
Map of device data expected over MQTT. More... | |
boost::mutex | m_DeviceDataLock |
Protect the device data map. More... | |
char | m_ID [24] |
MQTT client identifier. More... | |
std::list< CMqttMessage::Pointer > | m_MessageQueue |
Storage for MQTT messages. More... | |
MQTTClient_message | pubmsg |
MQTTClient_deliveryToken | token |
This class handles communication with physical devices through MQTT. It implements an asynchronous MQTT client that subscribes to a join channel to listen for the appearance of new plug-and-play devices. When a new device joins, the adapter subscribes to that device to receive its state changes.
typedef boost::shared_ptr<CMqttAdapter> freedm::broker::device::CMqttAdapter::Pointer |
|
private |
freedm::broker::device::CMqttAdapter::~CMqttAdapter | ( | ) |
|
private |
|
private |
|
staticprivate |
|
static |
|
private |
|
staticprivate |
|
inherited |
Accessor function for the registered device set.
|
virtual |
Implements freedm::broker::device::IAdapter.
|
staticprivate |
|
private |
|
private |
|
inherited |
Adds a device name to the registered device set.
devid | The name of the device to register. |
|
protectedinherited |
Reveals the associated devices in the device manager.
|
virtual |
Implements freedm::broker::device::IAdapter.
|
virtual |
Implements freedm::broker::device::IAdapter.
|
virtual |
Implements freedm::broker::device::IAdapter.
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |