Hello Everyone ,basically want help in decoding payload to get gps information like latitude and longitude.
payload
{"applicationID":"1","applicationName":"cloud","data":"YgAlYSgAHbo2AGR8QFocrwASACYD4gAC","devEUI":"f06a5fffff0f549e","deviceName":"lw004pb-1","fCnt":18,"fPort":222,"rxInfo":[{"altitude":0,"latitude":0,"loRaSNR":11.5,"longitude":0,"mac":"24e124fffef0a78e","name":"24e124fffef0a78e","rssi":-63,"time":"2021-01-22T10:28:43.328275Z"}],"time":"2021-01-22T10:28:43.328275Z","txInfo":{"adr":false,"codeRate":"4/5","dataRate":{"bandwidth":125,"modulation":"LORA","spreadFactor":12},"frequency":865985000}}
I have used buffer parser acc to manual to extract latitude and longitude check if its correct.Now acc to it is in little endian format means least significant byte is stored in lower memory address.after this need some guidance like simply converting hexadecimal to decimal would work.
char hex[17];
int decimal, place;
int i = 0, val, len;
decimal = 0;
place = 1;
/* Find the length of total number of hex digit */
len = strlen(hex);
len--;
for(i=0; hex[i]!='\0'; i++)
{
/* Find the decimal representation of hex[i] */
if(hex[i]>='0' && hex[i]<='9')
{
val = hex[i] - 48;
}
else if(hex[i]>='a' && hex[i]<='f')
{
val = hex[i] - 97 + 10;
}
else if(hex[i]>='A' && hex[i]<='F')
{
val = hex[i] - 65 + 10;
}
decimal += val * pow(16, len);
len--;
}
console.log(decimal);