Sending DateTime via mbed
- This topic has 0 replies, 1 voice, and was last updated 9 years, 1 month ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
I am trying to send datetime from my mdot to my conduit via mbed code.
I am using the mDot_LoRa_Connect_Example
I can’t figure out how to convert my time char[] to a vector. C++ is not my native tongue.
#include "mbed.h"
#include "mDot.h"
#include <string>
#include <vector>
int main() {
int32_t ret;
mDot* dot;
std::vector<uint8_t> data;
time_t seconds = time(NULL);
char tim[32];
strftime(tim, 32, "%I:%M %p\n", localtime(&seconds));
for (std::string::iterator it = tim.begin(); it != tim.end(); it++)
data.push_back((uint8_t) *it);
while (true) {
if ((ret = dot->send(data)) != mDot::MDOT_OK) {
log_error(dot, "failed to send", ret);
} else {
printf("successfully sent data to gateway\r\n");
}
wait(5);
}
return 0;
}