Insert GPS on LMIC

Dear Sir, I’d like to use LMIC also to send GPS data. I have implented a little code for managing NeoGps on LMIC. My aim is to replace “hello world” with gps data in order to send on TTN this values.
I have the Gps information on two different float variables a= latitude() and b= longitude().
How can insert on mydata these values instead of “hello world” ? Thanks Daniele

The job of LMIC is to get the data across using the LoRaWAN protocol. What data you send is up to you.

You can build up a buffer of bytes containing the coordinates and send that instead of the “hello world” message. If you encode it as Cayenne LPP, the console can decode a preview of the data for you. See for example:
https://www.thethingsnetwork.org/docs/applications/cayenne/

With LMIC, the part that (prepares to) send the data, would be something like this:

    if ((LMIC.opmode & (OP_TXDATA | OP_TXRXPEND)) == 0) {
        LMIC_setTxData2(1, lpp.getBuffer(), lpp.getSize(), 0);
    }

Also see:

https://www.thethingsnetwork.org/docs/devices/bytes/

We STRONGLY recommend that you turn floats in to integers by multiplying it be 10, 100, 1000 or whatever, as they are so much easier to encode and then at the application end you divide by the multiplier you used.

Have a look at the code for a TTN Mapper node TTN Mapper gps node examples contains links to several different examples.

1 Like

thank you all