converting INT to Vector – sending data

Home Forums mDot/xDot converting INT to Vector – sending data

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #12429
    Eric Tsai
    Participant

    Hello,
    It seems like all the mDot LoRa examples are sending static strings to the gateway. They all send this:

    std::string data_str = "hello!";

    How do you send data rather than static strings? Say, an int counter? I tried adding this code to the <mDot_LoRa_Connect_Example>, but I got empty payloads.

    int32_t myCounter = 1;
    std::vector<uint8_t> data;
    ...
    myCounter++
    data.push_back(myCounter);
    data.push_back(myCounter >> 8);
    data.push_back(myCounter >> 16);
    data.push_back(myCounter >> 24);
    

    [TRACE] MIC: cf1b4c3d RX_MIC: cf1b4c3d
    [INFO] ACK Received
    [TRACE] Empty payload
    [INFO] successfully sent data to gateway

    Eventually, I’d like to be able to assemble a JSON formatted LoRa packet with all the sensor data on the mDot, which would require concatenating strings and INT and floats. But as a step one, I’m looking at just converting a single int.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.