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ライブラリ

Revision:
34:e18a166198df
Parent:
31:a51dd239b78e
Child:
40:9623a2c9c8ac
--- a/MQTTClient.h	Thu May 22 23:58:08 2014 +0000
+++ b/MQTTClient.h	Fri Aug 01 12:52:50 2014 +0000
@@ -27,7 +27,7 @@
 #if !defined(MQTTCLIENT_H)
 #define MQTTCLIENT_H
 
-#include "FP.cpp"
+#include "FP.h"
 #include "MQTTPacket.h"
 #include "stdio.h"
 
@@ -419,7 +419,7 @@
         case PUBLISH:
             MQTTString topicName;
             Message msg;
-            if (MQTTDeserialize_publish((int*)&msg.dup, (int*)&msg.qos, (int*)&msg.retained, (int*)&msg.id, &topicName,
+            if (MQTTDeserialize_publish((unsigned char*)&msg.dup, (int*)&msg.qos, (unsigned char*)&msg.retained, (int*)&msg.id, &topicName,
                                  (char**)&msg.payload, (int*)&msg.payloadlen, readbuf, MAX_MQTT_PACKET_SIZE) != 1)
                 goto exit;
 //          if (msg.qos != QOS2) 
@@ -446,7 +446,8 @@
             }
             break;
         case PUBREC:
-            int type, dup, mypacketid;
+            int type, mypacketid;
+            unsigned char dup;
             if (MQTTDeserialize_ack(&type, &dup, &mypacketid, readbuf, MAX_MQTT_PACKET_SIZE) != 1)
                 rc = FAILURE;
             else if ((len = MQTTSerialize_ack(buf, MAX_MQTT_PACKET_SIZE, PUBREL, 0, mypacketid)) <= 0)
@@ -654,7 +655,8 @@
     {
         if (waitfor(PUBACK, timer) == PUBACK)
         {
-            int type, dup, mypacketid;
+            int type, mypacketid;
+            unsigned char dup;
             if (MQTTDeserialize_ack(&type, &dup, &mypacketid, readbuf, MAX_MQTT_PACKET_SIZE) != 1)
                 rc = FAILURE;
         }
@@ -665,7 +667,8 @@
     {
         if (waitfor(PUBCOMP, timer) == PUBCOMP)
         {
-            int type, dup, mypacketid;
+            int type, mypacketid;
+            unsigned char dup;
             if (MQTTDeserialize_ack(&type, &dup, &mypacketid, readbuf, MAX_MQTT_PACKET_SIZE) != 1)
                 rc = FAILURE;
         }