initial version / sends time + 012345689
Dependencies: libmDot mbed-rtos mbed
Fork of wotiolora by
Revision 4:e38ff62eb19e, committed 2015-11-17
- Comitter:
- yiuwotio
- Date:
- Tue Nov 17 18:50:57 2015 +0000
- Parent:
- 3:689fbc447181
- Commit message:
- initial version - loops and sends time + 0123456789
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 09 23:33:43 2015 +0000
+++ b/main.cpp Tue Nov 17 18:50:57 2015 +0000
@@ -8,7 +8,7 @@
// these options must match the settings on your Conduit
// uncomment the following lines and edit their values to match your configuration
static std::string config_network_name = "wotioloranetwork";
-static std::string config_network_pass = "<INSERT_PASSPHRASE>";
+static std::string config_network_pass = "<PASSWORD HERE>";
static uint8_t config_frequency_sub_band = 7;
@@ -31,8 +31,8 @@
int main() {
int32_t ret;
mDot* dot;
- std::vector<uint8_t> data;
- std::string data_str = "LoRa->wotio";
+
+ std::string data_str = "1234567890";
// get a mDot handle
@@ -74,7 +74,7 @@
// in the 915 (US) frequency band, spreading factors 7 - 10 are available
// in the 868 (EU) frequency band, spreading factors 7 - 12 are available
logInfo("setting TX spreading factor");
- if ((ret = dot->setTxDataRate(mDot::SF_10)) != mDot::MDOT_OK) {
+ if ((ret = dot->setTxDataRate(mDot::SF_8)) != mDot::MDOT_OK) {
logError("failed to set TX datarate %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
}
@@ -101,11 +101,22 @@
osDelay(std::max((uint32_t)1000, (uint32_t)dot->getNextTxMs()));
}
- // format data for sending to the gateway
- for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++)
- data.push_back((uint8_t) *it);
+ while (true) {
+ // empty data array before compiling next message
+ std::vector<uint8_t> data;
+
+ time_t seconds = time(NULL);
+
+ char buffer[32];
+ strftime(buffer, 32, "%Y-%m-%d %H:%M:%S: ", localtime(&seconds));
+ for (int i = 0; i < strlen(buffer); i++) {
+ data.push_back((uint8_t) buffer[i]);
+ }
- while (true) {
+ // format data for sending to the gateway
+ for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++)
+ data.push_back((uint8_t) *it);
+
// send the data to the gateway
if ((ret = dot->send(data)) != mDot::MDOT_OK) {
logError("failed to send", ret, mDot::getReturnCodeString(ret).c_str());
@@ -118,6 +129,6 @@
// in the 868 (EU) frequency band, we need to wait until another channel is available before transmitting again
osDelay(std::max((uint32_t)5000, (uint32_t)dot->getNextTxMs()));
}
-
+
return 0;
}
