Jim Flynn / MQTT
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MQTT.h Source File

MQTT.h

00001 #ifndef __MQTT_H__
00002 #define __MQTT_H__
00003 
00004 #include "MQTTmbed.h"
00005 #include "MQTTSocket.h"
00006 
00007 template <class T>
00008 class MQTTconnect : public MQTTSocket
00009 {
00010     T eth;
00011   public:
00012     MQTTconnect() : MQTTSocket(&eth)
00013     { eth.connect(); }
00014 
00015     T& getEth()
00016     { return eth; }
00017 };
00018 
00019 //
00020 // To add additional transports, Define it as:
00021 //
00022 #define MQTT_BG96         100
00023 #define MQTT_WNC14A2A     101
00024 #define MQTT_ETHERNET     102
00025 
00026 //
00027 // Then define the interface that will be used:
00028 //
00029 #if   MBED_CONF_APP_MQTT_INTERFACE == MQTT_BG96
00030 #define _ift BG96Interface
00031 
00032 #elif MBED_CONF_APP_MQTT_INTERFACE == MQTT_WNC14A2A
00033 #define _ift WNC14A2AInterface
00034 
00035 #elif MBED_CONF_APP_MQTT_INTERFACE == MQTT_ETHERNET
00036 #define _ift EthernetInterface
00037 
00038 #else
00039 #error "No MQTT Network Transport chosen. Please add 'config.mqtt-interfaces.value' to your mbed_app.json (see README.md for more information)."
00040 #endif
00041 
00042 typedef MQTTconnect<_ift> MQTTct; 
00043 typedef _ift MQTTnet;
00044 
00045 #endif
00046