MQTT and MQTTS with wolfSSL TSL library

Dependencies:   FP MQTTPacket

Dependents:   YoPlegma

Fork of MQTT by MQTT

MQTT is light weight publish/subscribe based messaging protocol for M2M, IoT. This library was forked from MQTT https://developer.mbed.org/teams/mqtt for adding MQTTS security layer on the protocol. TLS(SSL) part of the library is by wolfSSL.https://developer.mbed.org/users/wolfSSL/code/wolfSSL/

"connect" method was extended for TLS. Rest of API's stay compatible with MQTT.

connect methode

 int connect(char* hostname, int port,  const char *certName = NULL, int timeout=1000)

The 3rd argument certName can be following values.

  • NULL: connecting with MQTT
  • pointer to certificate file: connecting with MQTTS. PEM or DER for server verification.
  • pointer to NULL string: connecting with MQTTS without server verification. This option is for prototyping only, not recommended in security perspective.

日本語:https://developer.mbed.org/users/wolfSSL/code/MQTTS/wiki/MQTTSライブラリ

Committer:
icraggs
Date:
Thu May 22 23:58:08 2014 +0000
Revision:
31:a51dd239b78e
Child:
36:2f1ada427e56
Create MQTTSocket.h to not use EthernetInterface

Who changed what in which revision?

UserRevisionLine numberNew contents of line
icraggs 31:a51dd239b78e 1 #if !defined(MQTTSOCKET_H)
icraggs 31:a51dd239b78e 2 #define MQTTSOCKET_H
icraggs 31:a51dd239b78e 3
icraggs 31:a51dd239b78e 4 #include "MQTT_mbed.h"
icraggs 31:a51dd239b78e 5 #include "TCPSocketConnection.h"
icraggs 31:a51dd239b78e 6
icraggs 31:a51dd239b78e 7 class MQTTSocket
icraggs 31:a51dd239b78e 8 {
icraggs 31:a51dd239b78e 9 public:
icraggs 31:a51dd239b78e 10 int connect(char* hostname, int port, int timeout=1000)
icraggs 31:a51dd239b78e 11 {
icraggs 31:a51dd239b78e 12 mysock.set_blocking(false, timeout); // 1 second Timeout
icraggs 31:a51dd239b78e 13 return mysock.connect(hostname, port);
icraggs 31:a51dd239b78e 14 }
icraggs 31:a51dd239b78e 15
icraggs 31:a51dd239b78e 16 int read(char* buffer, int len, int timeout)
icraggs 31:a51dd239b78e 17 {
icraggs 31:a51dd239b78e 18 mysock.set_blocking(false, timeout);
icraggs 31:a51dd239b78e 19 return mysock.receive(buffer, len);
icraggs 31:a51dd239b78e 20 }
icraggs 31:a51dd239b78e 21
icraggs 31:a51dd239b78e 22 int write(char* buffer, int len, int timeout)
icraggs 31:a51dd239b78e 23 {
icraggs 31:a51dd239b78e 24 mysock.set_blocking(false, timeout);
icraggs 31:a51dd239b78e 25 return mysock.send(buffer, len);
icraggs 31:a51dd239b78e 26 }
icraggs 31:a51dd239b78e 27
icraggs 31:a51dd239b78e 28 int disconnect()
icraggs 31:a51dd239b78e 29 {
icraggs 31:a51dd239b78e 30 return mysock.close();
icraggs 31:a51dd239b78e 31 }
icraggs 31:a51dd239b78e 32
icraggs 31:a51dd239b78e 33 private:
icraggs 31:a51dd239b78e 34
icraggs 31:a51dd239b78e 35 TCPSocketConnection mysock;
icraggs 31:a51dd239b78e 36
icraggs 31:a51dd239b78e 37 };
icraggs 31:a51dd239b78e 38
icraggs 31:a51dd239b78e 39
icraggs 31:a51dd239b78e 40
icraggs 31:a51dd239b78e 41 #endif