An API for using MQTT over multiple transports for mbed OS 5

Dependencies:   FP MQTTPacket

Fork of MQTT by MQTT

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Thu Feb 20 22:12:19 2014 +0000
Child:
1:1a6016a0cf66
Commit message:
Initial draft. Working out an API skeleton

Changed in this revision

FP.lib Show annotated file Show diff for this revision Revisions of this file
MQTT.cpp Show annotated file Show diff for this revision Revisions of this file
MQTT.h Show annotated file Show diff for this revision Revisions of this file
MQTTClient.lib Show annotated file Show diff for this revision Revisions of this file
MQTTConnection.cpp Show annotated file Show diff for this revision Revisions of this file
MQTTConnection.h Show annotated file Show diff for this revision Revisions of this file
MQTTPubSub.cpp Show annotated file Show diff for this revision Revisions of this file
MQTTPubSub.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FP.lib	Thu Feb 20 22:12:19 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/sam_grove/code/FP/#e9a4765b560f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MQTT.cpp	Thu Feb 20 22:12:19 2014 +0000
@@ -0,0 +1,24 @@
+/**
+ * @file    MQTT.cpp
+ * @brief   API - for MQTT
+ * @author  
+ * @version 1.0
+ * @see     
+ *
+ * Copyright (c) 2014
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include "MQTT.h"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MQTT.h	Thu Feb 20 22:12:19 2014 +0000
@@ -0,0 +1,67 @@
+/**
+ * @file    MQTT.h
+ * @brief   API - for MQTT
+ * @author  
+ * @version 1.0
+ * @see     
+ *
+ * Copyright (c) 2014
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MQTT_H
+#define MQTT_H
+
+/** Example using the MQTT API class
+ * @code
+ *  #include "mbed.h"
+ *  #include "MQTT.h"
+ *  
+ *  DigitalOut myled(LED1);
+ *  
+ *  int main()
+ *  {
+ *      while(1) 
+ *      {
+ *          myled = 1;
+ *          wait(0.2);
+ *          myled = 0;
+ *          wait(0.2);
+ *      }
+ *  }
+ * @endcode
+ */
+
+struct TopicPayload
+{
+    char *topic;
+    char *payload;
+};
+
+#include "FP.h"
+#include "MQTTPubSub.h"
+#include "mbed.h"
+
+class MQTT : public MQTTPubSub
+{
+public:
+    MQTT(){}
+    
+    char *mqttStream(void){return 0;}
+    int   mqttStreamLength(void){return 0;}
+    
+    FP <void,char*>callback;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MQTTClient.lib	Thu Feb 20 22:12:19 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/icraggs/code/MQTTClient/#7734401cc1b4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MQTTConnection.cpp	Thu Feb 20 22:12:19 2014 +0000
@@ -0,0 +1,24 @@
+/**
+ * @file    MQTTConnection.cpp
+ * @brief   API - for MQTT
+ * @author  
+ * @version 1.0
+ * @see     
+ *
+ * Copyright (c) 2014
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include "MQTTConnection.h"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MQTTConnection.h	Thu Feb 20 22:12:19 2014 +0000
@@ -0,0 +1,36 @@
+/**
+ * @file    MQTTConnection.h
+ * @brief   API - for MQTT
+ * @author  
+ * @version 1.0
+ * @see     
+ *
+ * Copyright (c) 2014
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#ifndef MQTTCONNECTION_H
+#define MQTTCONNECTION_H
+
+#include "MQTTPacket.h"
+
+class MQTTConnect
+{
+    MQTTPacket_connectData connect_data;
+    char *host;
+    int   port;
+    char *serialize_buffer;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MQTTPubSub.cpp	Thu Feb 20 22:12:19 2014 +0000
@@ -0,0 +1,24 @@
+/**
+ * @file    MQTTPubSub.cpp
+ * @brief   API - for MQTT
+ * @author  
+ * @version 1.0
+ * @see     
+ *
+ * Copyright (c) 2014
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include "MQTTPubSub.h"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MQTTPubSub.h	Thu Feb 20 22:12:19 2014 +0000
@@ -0,0 +1,51 @@
+/**
+ * @file    MQTTPubSub.h
+ * @brief   API - for MQTT
+ * @author  
+ * @version 1.0
+ * @see     
+ *
+ * Copyright (c) 2014
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MQTTPUBSUB_H
+#define MQTTPUBSUB_H
+
+#include "MQTTConnection.h"
+
+class MQTTTopic
+{
+    MQTTString topic;
+    char *msg_buffer;
+    int   msg_size;
+};
+
+class MQTTPubSub : private MQTTConnect
+{
+private:
+    MQTTTopic topic;
+
+public:    
+    enum {
+        TOPIC_PUBLISH, TOPIC_SUBSCRIBE
+    }Message;
+    
+    MQTTPubSub(){}
+    
+    void publish(){}
+    void subscribe(){}    
+};
+
+#endif