Sample MQTT program - simple send and receive (MQ Telemetry Transport) for GainSpan Wi-Fi module
Dependencies: C12832 GSwifiInterface MQTT mbed-rtos mbed
Fork of HelloMQTT by
mbedのMQTTグループで保守されているMQTTライブラリを GainSpan Wi-Fi モジュールへ対応させたサンプルです。
MQTT (MQ Telemetry Transport) とは、IoTやM2M向け デバイス間通信のためのプロトコルです。
MQTTサーバーには http://iot.eclipse.org/ のサンドボックスを使います。 送信したメッセージをエコーバックしてくるだけの動作をします。
mbed Application Board を使う場合は次の行のコメントアウトを外すとLCDへ表示するようになる。
#define MBED_APPLICATION_BOARD
GainSpanモジュールの接続ピンについては次の行で指定する。
gs = new GSwifiInterface(p9, p10, NC, NC, p30, NC, 9600); //tx, rx, cts, rts, reset, alarm, baud
Wi-Fiアクセスポイントは次の行で指定する。
#define SEC GSwifi::SEC_WPA_PSK #define SSID "SSID" #define PASS "PASSPHRASE"
MQTTGSwifi.h@16:fd155e824a80, 2014-10-02 (annotated)
- Committer:
- gsfan
- Date:
- Thu Oct 02 03:26:56 2014 +0000
- Revision:
- 16:fd155e824a80
Supported for GainSpan wi-fi module.; 1st build
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gsfan | 16:fd155e824a80 | 1 | |
gsfan | 16:fd155e824a80 | 2 | #ifndef MQTTGSWIFI_H |
gsfan | 16:fd155e824a80 | 3 | #define MQTTGSWIFI_H |
gsfan | 16:fd155e824a80 | 4 | |
gsfan | 16:fd155e824a80 | 5 | #include "MQTT_mbed.h" |
gsfan | 16:fd155e824a80 | 6 | #include "GSwifiInterface.h" |
gsfan | 16:fd155e824a80 | 7 | #include "MQTTSocket.h" |
gsfan | 16:fd155e824a80 | 8 | |
gsfan | 16:fd155e824a80 | 9 | class MQTTGSwifi : public MQTTSocket |
gsfan | 16:fd155e824a80 | 10 | { |
gsfan | 16:fd155e824a80 | 11 | public: |
gsfan | 16:fd155e824a80 | 12 | MQTTGSwifi(GSwifiInterface *gs) : eth(gs) |
gsfan | 16:fd155e824a80 | 13 | { |
gsfan | 16:fd155e824a80 | 14 | } |
gsfan | 16:fd155e824a80 | 15 | |
gsfan | 16:fd155e824a80 | 16 | private: |
gsfan | 16:fd155e824a80 | 17 | |
gsfan | 16:fd155e824a80 | 18 | GSwifiInterface *eth; |
gsfan | 16:fd155e824a80 | 19 | |
gsfan | 16:fd155e824a80 | 20 | }; |
gsfan | 16:fd155e824a80 | 21 | |
gsfan | 16:fd155e824a80 | 22 | #endif |