Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FXOS8700Q
Revision 46:b5c571a9a5f5, committed 2019-03-20
- 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
--- 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);