RCELE 85 / Mbed 2 deprecated Nucleo_mqtt_sim800_final

Dependencies:   GSM_MQTT mbed

Files at this revision

API Documentation at this revision

Comitter:
rcele_85
Date:
Tue Apr 17 05:04:02 2018 +0000
Commit message:
ok

Changed in this revision

GSM_MQTT.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GSM_MQTT.lib	Tue Apr 17 05:04:02 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/rcele_85/code/GSM_MQTT/#e7957e1745cb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Apr 17 05:04:02 2018 +0000
@@ -0,0 +1,62 @@
+/* =========================================================================================
+*                     GSM_MQTT == MQTT CLIENT LIBRARY FOR GPRS MODEM
+* SUPPORTED GPRS MODEM ==> SIM800, SIM900, SIM300
+* SUPPORTED MBED HARDWARE ==> Any hardware with two Hardware Serial port and 1 timer
+*
+* Developed By : Ravi Butani
+* Prof. Marwadi University, Rajkkot-INDIA
+* Contact: ravi_butani@yahoo.com
+*
+* License : This library released under CC-BY-SA 4.0 license
+* https://creativecommons.org/licenses/by-sa/4.0/legalcode.txt
+*
+* This library is derived from Arduino MQTT Client for SIM800 at 
+* https://github.com/elementzonline/SIM800_MQTT
+*============================================================================================*/
+
+#include "mbed.h"
+#include "GSM_MQTT.h"
+
+Serial SerialDBG(USBTX, USBRX);   // tx, rx for USB Debug on PC
+Serial Serial800(D8, D2);         // tx, rx for SIM800 Interfacing on UART
+
+string MQTT_HOST = "iot.eclipse.org";
+string MQTT_PORT = "1883";
+
+void GSM_MQTT::AutoConnect(void)
+{
+  connect("client657");
+}
+
+void GSM_MQTT::OnConnect(void)
+{
+  subscribe("ravibut");
+  publish("SampleTopic", "Hello");
+}
+
+void GSM_MQTT::OnMessage(char *Topic, int TopicLength, char *Message, int MessageLength)
+{
+  SerialDBG.printf("%d \r\n",TopicLength);
+  SerialDBG.printf("%s \r\n",Topic);
+  SerialDBG.printf("%d \r\n",MessageLength);
+  SerialDBG.printf("%s \r\n",Message);
+}
+
+GSM_MQTT MQTT(20);
+int main()
+{
+  SerialDBG.printf("Wait for 3 seconds to get SIM800 stabilized...\r\n");
+  wait(3);
+  MQTT.begin();
+  
+    while(1)
+    {
+        wait(3);
+        if (MQTT.available())
+        {
+            SerialDBG.printf("mqtt_ok\r\n");
+            MQTT.publish("SampleTopic", "Hello");
+        }
+        MQTT.processing();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Apr 17 05:04:02 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/fd96258d940d
\ No newline at end of file