Sending DateTime via mbed

Home Forums mDot/xDot Sending DateTime via mbed

Tagged: ,

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #11835
    Terrence Spencer
    Participant

    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;
    }
    
    
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.