J L / Mbed OS MQTT_Integration

Dependencies:   X_NUCLEO_IKS01A2

Files at this revision

API Documentation at this revision

Comitter:
ga58bin
Date:
Thu Jan 07 14:32:21 2021 +0000
Parent:
0:0f878e3e5401
Commit message:
Updated json

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
wifi-x-nucleo-idw01m1.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 0f878e3e5401 -r ba4c33393a52 main.cpp
--- a/main.cpp	Thu Nov 05 19:07:22 2020 +0000
+++ b/main.cpp	Thu Jan 07 14:32:21 2021 +0000
@@ -1,4 +1,5 @@
 #include "mbed.h"
+#include <math.h>
 
 #include <MQTTClientMbedOs.h>
 #include "SpwfSAInterface.h"
@@ -40,7 +41,7 @@
     TCPSocket socket;
     MQTTClient client(&socket);
     socket.open(&wifi);
-    int rc = socket.connect("mqtt.eclipse.org", 1883);
+    int rc = socket.connect("192.168.178.21", 1883);
     
     if (rc == 0)
         printf("Connection Successful");
@@ -51,8 +52,8 @@
     
     data.MQTTVersion = 4;
     data.struct_version=0;
-    data.clientID.cstring = "clientId-Scf7TcRtbgasdseg";
-    data.username.cstring = "bob";
+    data.clientID.cstring = "clientId-ACC2";
+    data.username.cstring = "jlenz";
     data.password.cstring = "123";
 
     rc = client.connect(data);
@@ -70,16 +71,19 @@
             
         acc_gyro->get_x_axes_raw(axes);
         MQTT::Message message;
-        char* pubTopic = "SLG/ACC";
+        char* pubTopic = "SLG/ACC2";
         char buf[MQTT_MAX_PAYLOAD_SIZE];
-        sprintf(buf,"%d,%d,%d",axes[0],axes[1],axes[2]);
+        auto normAxe = axes[0]*axes[0] + axes[1]*axes[1] + axes[2]*axes[2];
+        sprintf(buf,"%d",normAxe);
         message.qos = MQTT::QOS0;
         message.retained = false;
         message.dup = false;
         message.payload = (void*)buf;
         message.payloadlen = strlen(buf);
         client.publish(pubTopic, message);
-        printf("%d,%d,%d \n",axes[0],axes[1],axes[2]);
+        printf("%d \n",normAxe);
+        printf("%d \n",axes[0]);
+        
     }
 
 
diff -r 0f878e3e5401 -r ba4c33393a52 mbed-os.lib
--- a/mbed-os.lib	Thu Nov 05 19:07:22 2020 +0000
+++ b/mbed-os.lib	Thu Jan 07 14:32:21 2021 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#aa70f680bb5755e8fea3f93fc6e04d9b3de235bb
+https://github.com/ARMmbed/mbed-os/#e642a7d8b3609a7c903e042cd772f00a5d299088
diff -r 0f878e3e5401 -r ba4c33393a52 mbed_app.json
--- a/mbed_app.json	Thu Nov 05 19:07:22 2020 +0000
+++ b/mbed_app.json	Thu Jan 07 14:32:21 2021 +0000
@@ -6,11 +6,11 @@
 	},
         "wifi-ssid": {
             "help": "WiFi SSID",
-            "value": "\"ViveLaFrance\""
+            "value": "\"-ENTER SSID-\""
         },
         "wifi-password": {
             "help": "WiFi Password",
-            "value": "\"C0mplic@edP4ssw0rd!\""
+            "value": "\"-ENTER PASSWORD HERE-\""
         },
         "wifi-tx": {
             "help": "TX pin for serial connection to external device",
diff -r 0f878e3e5401 -r ba4c33393a52 wifi-x-nucleo-idw01m1.lib
--- a/wifi-x-nucleo-idw01m1.lib	Thu Nov 05 19:07:22 2020 +0000
+++ b/wifi-x-nucleo-idw01m1.lib	Thu Jan 07 14:32:21 2021 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/wifi-x-nucleo-idw01m1/#5871f7011d7ff2c50e3faf992ebab88e9f69dc95
+https://github.com/ARMmbed/wifi-x-nucleo-idw01m1.git/#90ba1f95ce7d6f6e4e0ead265152ce0c728cbdad