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

Transfer GPX file as Route to Watch without movescount internet connection #252

Open
TheBlackRiderGBird opened this issue Jun 7, 2020 · 5 comments

Comments

@TheBlackRiderGBird
Copy link
Contributor

TheBlackRiderGBird commented Jun 7, 2020

Hi all,
I am interested into the possibility of transferring new routes from a PC/Smartphone onto my watch. Without having any internet connection present. This is a common usecase for offside locations. Where I would like to use the watch for navgiation of newly planned routes.
I think technically it should be possible, but are the any pitfalls which I didn't think of?

First of all I am thinking of the following steps.
Prepare GPX for watch. (e.g.: Limit to 1000 Points.)

  1. Find free memory location in watch
  2. Transform gpx into internal format .
  3. Copy via libambit to watch.

Is there any interference with movescount. So usually movescount keeps track which routes are transferred to the watch.
In case I will transfer my own routes without telling Movescount, what will happen to after reconnection to moveslink or openambit?
Will it just overwrite my own routes? I think this would be a tolerable behavior.

Had someone else already a similar plan?

Thanks in advance
Best Regards

@Gerold-R
Copy link

Gerold-R commented Jun 8, 2020

Hi

All I know is that when you add a route, BEGIN and END of the route are stored as WayPoint (52 Bytes) in the address space for WayPoints ($5000-$8FFF = 16.384 Bytes, same values for A2 and A3 series). Data for the route are stored in the address space for Routes ($14C080-$16BC4F = 130.000 Bytes for A3 series, A2 series starts at $041EB0 but same size).

You will find more detailed information in the ZIP file attached to the comment.

Guess writing the Waypoints is quite clear but we never looked further into the Routes data.

After adding a Route, the SHA checksums for Routes and WayPoints binary areas must be updated.

Regards
Gerold

A3 Routes and POIs from MC.zip

@Gerold-R
Copy link

Gerold-R commented Jun 9, 2020

Forgot to mention:

Is there any interference with movescount. So usually movescount keeps track which routes are transferred to the watch.
In case I will transfer my own routes without telling Movescount, what will happen to after reconnection to moveslink or openambit?
Will it just overwrite my own routes? I think this would be a tolerable behavior.

Yes, at least Moveslink/Suuntolink (don't know for OpenAmbit) will overwrite your Routes and Waypoints directly stored on the watch, so you should import the route into Movescount before etc. Before Moveslink syncs the watch, it reads the routes stored on the watch and downloads the routepoints for all routes stored on the watch. Guess something similar happens for the waypoints except the BEGIN/END waypoints for routes. Moveslink creates data arrays with the size of 16.384 Bytes for the Waypoints and 130.000 Bytes for the Routes and will write these number of bytes to the watch even if you have for example only one route with 2 waypoints to store on the watch. Data arrays are initialized with value $FF.

We have written a program in Delphi to read and store Waypoints from the watch as GPX files in case this is interessting for you. Works also under Linux with Wine or CrossOver.

@TheBlackRiderGBird
Copy link
Contributor Author

Hi Gerold-R,
thank you for your response. As this my first attempt to work with the source code of openambit it took some time to get familar.

Thank you for your data. I think with the combination of device_driver_ambit_navigation.c and device_driver_ambit_navigation.h which is already available for Ambit2 it is quite straight forward to enhance this to ambit3.

I found a command to read and write waypoints. But for routes there is only a write command.
How did you create this dat files?
Is it possible to read back the routes from the Watch to the PC?

I am not sure if your delphi program will help me. But as a reference it would be great if you can supply this. I am working on windows so running it shouldn't be a problem.

Best Regards

@Gerold-R
Copy link

Gerold-R commented Jul 16, 2020

Hi

To read the data for a route, use the command 0x0B 0x17. In "libambit" it's called "ambit_command_log_read" but you can read more than the log data with this command. It's maybe better to call this command "ambit_command_read_data" to make this clearer. Suunto's names are WritePmemRaw and ReadPmemRaw and you can not read (or write) the complete 8MB flash memory of your Ambit 3 with these commands. Only to memory addresses returned from the command 0x0B 0x21 ("Ambit_Command_Ambit3_Memory_Map"). Some of these addresses are also stored in the file "Devices.xml". Search for " storesize" and "storelocation".

It's important not to read or write more than 1024 Bytes at once. This limit is returned in the answer, when you use the command 0x00 0x00.

I am not sure, if the distance between 2 LAT/LON values is calculated the same way as Suunto does. I mean this code:

    for(int y=0;y<cur_ps->points_count;++y) {
        int32_t rel_x = (int32_t)(distance_calc((double)(cur_ps->mid_lat)/10000000, 
		                                        (double)(cur_ps->mid_lon)/10000000, 
												(double)(cur_ps->mid_lat)/10000000, 
												(double)(cur_ps->points[y].lon)/10000000)
												*1000);

        if(cur_ps->points[y].lon<cur_ps->mid_lon) {
            rel_x *= -1;
        }

        int32_t rel_y = (int32_t)(distance_calc((double)(cur_ps->mid_lat)/10000000, 
		                                        (double)(cur_ps->mid_lon)/10000000, 
												(double)(cur_ps->points[y].lat)/10000000, 
												(double)(cur_ps->mid_lon)/10000000)
												*1000);

        if(cur_ps->points[y].lat<cur_ps->mid_lat) {
            rel_y *= -1;
        }`

I am using another formula for calculating the distance of 2 LAT/LON coordinates which are close together (Delphi code):

// NAUTICEL_MILE = 1852 = 1.852m
// 3.141592741012573 / 180 = Degrees -> Radians
C := System.Cos(Center.Latitude * (3.141592741012573 / 180));
FDistToCenter.X := Trunc(C * ((FLongitude - Center.Longitude) * 60 * NAUTICEL_MILE));
FDistToCenter.Y := Trunc((FLatitude - Center.Latitude) * 60 * NAUTICEL_MILE);

You should check this out.

Gerold

@Gerold-R
Copy link

Do you know Suunto' API Zone?
https://apizone.suunto.com/route-description

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