Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable "fake gps" when coordinates are 0,0. #17

Open
jpmeijers opened this issue May 15, 2017 · 1 comment
Open

Disable "fake gps" when coordinates are 0,0. #17

jpmeijers opened this issue May 15, 2017 · 1 comment

Comments

@jpmeijers
Copy link

When the coordinates are set to lat=0, lon=0, the status packet that are sent looks like:

{"stat":{"time":"2017-05-15 14:29:06 GMT","lati":0.00000,"long":0.00000,"alti":10,"rxnb":0,"rxok":0,"rxfw":0,"ackr":0.0,"dwnb":0,"txnb":0,"pfrm":"Single Channel Gateway","mail":"[email protected]","desc":"My gateway"}}

but on the TTN NOC I see

{"id":"eui-b827ebffff706141","status":{"time":"1494859297251862030","gps":{"latitude":0.0000012673606,"longitude":0.000002682209,"altitude":10}

Which means we get a floating point rounding error.

What we expected was that the coordinates remain 0, and are then replaced by the coordinates from the TTN Console.

Recommendation:
If the coordinates are set to 0,0, do not add them to the status message. In other words, replace line 368 of main.cpp with (untested):

int j;

if(lat==0 || lon==0)
{
  j = snprintf((char *)(status_report + stat_index), STATUS_SIZE-stat_index, "{\"stat\":{\"time\":\"%s\",\"rxnb\":%u,\"rxok\":%u,\"rxfw\":%u,\"ackr\":%.1f,\"dwnb\":%u,\"txnb\":%u,\"pfrm\":\"%s\",\"mail\":\"%s\",\"desc\":\"%s\"}}", stat_timestamp, cp_nb_rx_rcv, cp_nb_rx_ok, cp_up_pkt_fwd, (float)0, 0, 0,platform,email,description);
}
else
{
  j = snprintf((char *)(status_report + stat_index), STATUS_SIZE-stat_index, "{\"stat\":{\"time\":\"%s\",\"lati\":%.5f,\"long\":%.5f,\"alti\":%i,\"rxnb\":%u,\"rxok\":%u,\"rxfw\":%u,\"ackr\":%.1f,\"dwnb\":%u,\"txnb\":%u,\"pfrm\":\"%s\",\"mail\":\"%s\",\"desc\":\"%s\"}}", stat_timestamp, lat, lon, (int)alt, cp_nb_rx_rcv, cp_nb_rx_ok, cp_up_pkt_fwd, (float)0, 0, 0,platform,email,description); 
}
@Paul-B
Copy link

Paul-B commented May 15, 2017

I have tried this fix on my pi and can confirm that it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants