Version to make it easier to reuse without source modifications
MQTT.h@0:5cd4781e0c88, 2018-03-27 (annotated)
- Committer:
- JMF
- Date:
- Tue Mar 27 17:26:35 2018 +0000
- Revision:
- 0:5cd4781e0c88
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JMF | 0:5cd4781e0c88 | 1 | #ifndef __MQTT_H__ |
JMF | 0:5cd4781e0c88 | 2 | #define __MQTT_H__ |
JMF | 0:5cd4781e0c88 | 3 | |
JMF | 0:5cd4781e0c88 | 4 | #include "MQTTmbed.h" |
JMF | 0:5cd4781e0c88 | 5 | #include "MQTTSocket.h" |
JMF | 0:5cd4781e0c88 | 6 | |
JMF | 0:5cd4781e0c88 | 7 | template <class T> |
JMF | 0:5cd4781e0c88 | 8 | class MQTTconnect : public MQTTSocket |
JMF | 0:5cd4781e0c88 | 9 | { |
JMF | 0:5cd4781e0c88 | 10 | T eth; |
JMF | 0:5cd4781e0c88 | 11 | public: |
JMF | 0:5cd4781e0c88 | 12 | MQTTconnect() : MQTTSocket(ð) |
JMF | 0:5cd4781e0c88 | 13 | { eth.connect(); } |
JMF | 0:5cd4781e0c88 | 14 | |
JMF | 0:5cd4781e0c88 | 15 | T& getEth() |
JMF | 0:5cd4781e0c88 | 16 | { return eth; } |
JMF | 0:5cd4781e0c88 | 17 | }; |
JMF | 0:5cd4781e0c88 | 18 | |
JMF | 0:5cd4781e0c88 | 19 | // |
JMF | 0:5cd4781e0c88 | 20 | // To add additional transports, Define it as: |
JMF | 0:5cd4781e0c88 | 21 | // |
JMF | 0:5cd4781e0c88 | 22 | #define MQTT_BG96 100 |
JMF | 0:5cd4781e0c88 | 23 | #define MQTT_WNC14A2A 101 |
JMF | 0:5cd4781e0c88 | 24 | #define MQTT_ETHERNET 102 |
JMF | 0:5cd4781e0c88 | 25 | |
JMF | 0:5cd4781e0c88 | 26 | // |
JMF | 0:5cd4781e0c88 | 27 | // Then define the interface that will be used: |
JMF | 0:5cd4781e0c88 | 28 | // |
JMF | 0:5cd4781e0c88 | 29 | #if MBED_CONF_APP_MQTT_INTERFACE == MQTT_BG96 |
JMF | 0:5cd4781e0c88 | 30 | #define _ift BG96Interface |
JMF | 0:5cd4781e0c88 | 31 | |
JMF | 0:5cd4781e0c88 | 32 | #elif MBED_CONF_APP_MQTT_INTERFACE == MQTT_WNC14A2A |
JMF | 0:5cd4781e0c88 | 33 | #define _ift WNC14A2AInterface |
JMF | 0:5cd4781e0c88 | 34 | |
JMF | 0:5cd4781e0c88 | 35 | #elif MBED_CONF_APP_MQTT_INTERFACE == MQTT_ETHERNET |
JMF | 0:5cd4781e0c88 | 36 | #define _ift EthernetInterface |
JMF | 0:5cd4781e0c88 | 37 | |
JMF | 0:5cd4781e0c88 | 38 | #else |
JMF | 0:5cd4781e0c88 | 39 | #error "No MQTT Network Transport chosen. Please add 'config.mqtt-interfaces.value' to your mbed_app.json (see README.md for more information)." |
JMF | 0:5cd4781e0c88 | 40 | #endif |
JMF | 0:5cd4781e0c88 | 41 | |
JMF | 0:5cd4781e0c88 | 42 | typedef MQTTconnect<_ift> MQTTct; |
JMF | 0:5cd4781e0c88 | 43 | typedef _ift MQTTnet; |
JMF | 0:5cd4781e0c88 | 44 | |
JMF | 0:5cd4781e0c88 | 45 | #endif |
JMF | 0:5cd4781e0c88 | 46 |