traccar / traccar-client-ios

Traccar Client for iOS
https://www.traccar.org/client
Apache License 2.0
204 stars 304 forks source link

Extended Format ($TRCCR) Format Issue #16

Open usman427 opened 9 years ago

usman427 commented 9 years ago

Hi Traccar, Why there is no extended protocol ($TRCCR) for iPhone app ? I have implemented it but not working correctly, also it fetch the wrong longitude and latitude. For example if the long and lat is 54.34234, 25.3434. but in my extended format it fetch 5434.234 and 2534.34.

Can you please tell me where I am doing mistake?

return [NSString stringWithFormat:@"$TRCCR,%02d%02d%02d%02d%02d%02d.000,A,%02d%07.4f,%03d%07.4f,%.2f,%.2f,%.2f,%03d,00\r\n", (int) components.year, (int) components.month, (int) components.day, (int) components.hour, (int) components.minute, (int) components.second, (int) trunc(fabs(lat)), fmod(fabs(lat), 1.0) * 60.0, (int) trunc(fabs(lon)), fmod(fabs(lon), 1.0) * 60.0, (location.speed > 0) ? location.speed \ 1.943844 : 0.0, (location.course > 0) ? location.course : 0.0, 0.0,100]; //where 100 is for battery value

Can anyone tell me Is the string format is correct or not ?

tananaev commented 9 years ago

You need to send latitude and longitude in degrees.

usman427 commented 9 years ago

Can you tell me how to do it ? I have this string now stringWithFormat:@"$TRCCR,%02d%02d%02d%02d%02d%02d.000,A,%02d%08.4f,%03d%08.4f,%.2f,%.2f,%.2f,%03d,*00\r\n",

can you tell me what will be the format for sending in degrees ?

tananaev commented 9 years ago

I can point you to the documentation:

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/#//apple_ref/occ/clm/NSString/stringWithFormat:

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html

usman427 commented 9 years ago

Thanks for the help :)