MQTT Client for mbed LPC1768 and Application Board over Ethernet; publish only.

Dependencies:   C12832 MMA7660 MQTT

Fork of HelloMQTT by MQTT

Machine-to-Machine-Communication

Das Message Queue Telemetry Transport (MQTT) Protokoll ist ein effizientes Internet of Things (IoT) Protokoll mit wenig Protokolloverhead. Es wurde als lightweight publish/subscribe messaging transport entworfen. Es ist sinnvoll für Verbindungen mit Remote-Standorten, wo nur wenig Resourcen benötigt werden bzw. geringe Bandbreite zur Verfügung steht. Neben MQTT gibt es weitere IoT-Protokoll, wie HTTP, CoAP, XMPP, ... (Überischt über IoT Protokolle). Eine Beschreibung des MQTT ist z.B. hier zu finden.

MQTT implementiert das Publish/Subscribe-Pattern, daher wird ein Brocker für die Vermittlung der Nachrichten (topics) benötigt. Neben vielen quelloffenen Implementierungen (z. B. mosquitto) gibt es auch kommerzielle bzw. freie Server (Broker), die unterschiedliche Features bereit stellen (z. B. den in Deutschland entwickelten HiveMQ).

Für die Programmierung der Clients bzw. Ebedded Systems stehen ebenso sehr viele Libaries in verschiedenen Programmiersprachen zur Verfügung.

Desktop MQTT-Clients

M3-Ethernet MQTT Client

M3-Ethernet ThingSpeak

C# Wpf Client

Weitere Kommunikationsmöglichkeiten

MQTTESP8266.h

Committer:
fpucher
Date:
2017-05-04
Revision:
21:4b8d80bf664f

File content as of revision 21:4b8d80bf664f:


#if !defined(MQTTESP8266_H)
#define MQTTESP8266_H

#include "MQTTmbed.h"
#include "ESP8266Interface.h"
#include "MQTTSocket.h"

// This struct is only used to workaround the order that the interfaces are initialized
// MQTTSocket contains a TCPSocketConnection which needs the ESP8266Interface to be 
// instantiated first. Unfortunately the only way to instantiate a member before a superclass 
// is through another superclass.
struct MQTTESP8266Holder {
    MQTTESP8266Holder(PinName tx, PinName rx, PinName reset, const char *ssid, const char *pass) :
            _wifi(tx, rx, reset, ssid, pass) {}
    
    ESP8266Interface _wifi;
};

// Straightforward implementation of a MQTT interface
class MQTTESP8266 : public MQTTESP8266Holder, public MQTTSocket {    
private:
    MQTTESP8266Holder::_wifi;
    //ESP8266Interface _wifi;
    
public:    
    MQTTESP8266(PinName tx, PinName rx, PinName reset, const char *ssid, const char *pass) :
            MQTTESP8266Holder(tx, rx, reset, ssid, pass) {
        _wifi.init();
        _wifi.connect();
    }
    
    ESP8266Interface& getInterface() {
        return _wifi;
    }
    
    void reconnect() {
        _wifi.disconnect();
        _wifi.connect();
    }
};


#endif