Remote Writing IoT Data to Influx-DB over HTTP-API.

Dependencies:   FXOS8700CQ mbed

Fork of AvnetATT_shape_hackathon by Demo Software for Avnet+AT&T IoT kit.

Files at this revision

API Documentation at this revision

Comitter:
fkellermavnet
Date:
Thu Jul 21 15:26:42 2016 +0000
Parent:
32:8ba73eab6c72
Child:
34:029e07b67a41
Commit message:
Changed sock read so it clears out the return data string upon call. If data is obtained then it puts it in the cleared string. Changed sock read so that it returns how many bytes/chars it received from the read.

Changed in this revision

wnc_control.cpp Show annotated file Show diff for this revision Revisions of this file
wnc_control.h Show annotated file Show diff for this revision Revisions of this file
--- a/wnc_control.cpp	Thu Jul 21 01:51:59 2016 +0000
+++ b/wnc_control.cpp	Thu Jul 21 15:26:42 2016 +0000
@@ -104,8 +104,10 @@
       puts("Socket is closed for write!\r\n");
 }
 
-void sockread_mdm(string * sockData, int len, int retries)
+unsigned sockread_mdm(string * sockData, int len, int retries)
 {
+    // Clear out any possible old data
+    sockData->erase();
     if (socketOpen == 1)
     {
     do
@@ -123,6 +125,8 @@
     }
     else
       puts("Socket is closed for read\r\n");
+      
+    return (sockData->size());
 }
 
 void sockclose_mdm(void)
@@ -322,6 +326,10 @@
   unsigned i;
   string * pRespStr;
   string cmd_str("AT@SOCKREAD=1,");
+  
+  // Don't assume clean slate:
+  pS->erase();
+  
   if (n <= 1500)
   {
     char num2str[6];
@@ -344,7 +352,6 @@
       {
         retries = 0;  // If any data found stop retrying
         string byte;
-        pS->erase();
         while (pos_start < pos_end)
         {
           byte = pRespStr->substr(pos_start, 2);
--- a/wnc_control.h	Thu Jul 21 01:51:59 2016 +0000
+++ b/wnc_control.h	Thu Jul 21 15:26:42 2016 +0000
@@ -21,7 +21,7 @@
 extern void resolve_mdm(void);
 extern void sockopen_mdm(void);
 extern void sockwrite_mdm(const char * s);
-extern void sockread_mdm(string * sockData, int len, int retries);
+extern unsigned sockread_mdm(string * sockData, int len, int retries);
 extern void sockclose_mdm(void);
 
 #endif