issue with send_message

Dependencies:   FXOS8700Q

Files at this revision

API Documentation at this revision

Comitter:
zer044
Date:
Wed Mar 20 20:56:02 2019 +0000
Parent:
45:fc90043ed811
Commit message:
Changed how the output string is received then did some casting to get data out.

Changed in this revision

SensorData.cpp Show annotated file Show diff for this revision Revisions of this file
SensorData.h 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
--- a/SensorData.cpp	Wed Mar 20 15:56:25 2019 +0000
+++ b/SensorData.cpp	Wed Mar 20 20:56:02 2019 +0000
@@ -16,17 +16,16 @@
 }
 
 
-string SensorData::run()
+void SensorData::run()
 {
     pc.printf("hey");
     //initialise();
-    if (s_com.readable()) {
+    if (s_com.readable()) 
+    {
         stringstream ss;
         ss << readData() << sensor_data();
         alldata = ss.str();
         pc.printf(alldata.c_str());
-        return alldata.c_str();
-        
     }
 }
 
--- a/SensorData.h	Wed Mar 20 15:56:25 2019 +0000
+++ b/SensorData.h	Wed Mar 20 20:56:02 2019 +0000
@@ -16,7 +16,7 @@
     
     void initialise();
     
-    string run();
+    void run();
     
     //Read in serial line and send it to log_data
     string readData();
--- a/main.cpp	Wed Mar 20 15:56:25 2019 +0000
+++ b/main.cpp	Wed Mar 20 20:56:02 2019 +0000
@@ -176,7 +176,8 @@
     int16_t retcode;
     //float sensor_value; //value was a ffloat before i changed anything 
     string sensor_value; //i added this
-    sensor_value = mySensor.run(); //also this 
+    mySensor.run(); //also this
+    sensor_value = mySensor.getDataString(); 
 
     
     
@@ -196,10 +197,11 @@
     
     
     
-    packet_len = sprintf((char*) tx_buffer, 
-                    sensor_value);
+//    packet_len = sprintf((char*) tx_buffer, 
+//                    sensor_value);
+    packet_len = sensor_value.length();
 
-    retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,
+    retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, (uint8_t*)(sensor_value.data()), packet_len,
                            MSG_CONFIRMED_FLAG);
                            
     printf("\r\n"+packet_len);