Avatar

Assign Route To Device

1

Here is my code. Please let me now what I am doing wrong. Thanks 

API api = new API(strUser, strPassword, null, strDatabase, strServer); 
Device messageRecipient = api.Call("GetDevice", new { serialNo = "G69220CCE698" });
List zones = api.Call<list>("GetZones", new { includeHiddenZones = false, includeNameComment = true, allNodes = new Zone[0] }) ?? new List(); 


List routePlanItems = new List(); 
for (int i = 0; i < zones.Count; i++) 

routePlanItems.Add(new RoutePlanItem( 
null, 
new Zone { EntityIdentifier = zones.EntityIdentifier }, 
null, 
i, 
DateTime.MinValue, 
DateTime.MaxValue)); 



Route route = new Route(null, "MyGarminRoute", "Comment", routePlanItems); 
route.Device = messageRecipient; 
api.Call("Add", typeof(Route), new { entity = route });

 

The above piece of code goes through but does not assign the route to the device. Why?

Mauricio Muniz

Please sign in to leave a comment.

4 comments

Avatar

I think there is a little misunderstanding. 

As I mentioned in this post: 
https://geotab.zendesk.com/entries/22657879-Routes-Example


A route is not sent to a device that is assigned to it. You can send a set of route stops to a device by sending a set of TextMessages (RouteMessages) to that Device. 

Also note the Distinction between a Route and a Route Plan. You can see these in MyGeotab under Zones & Messages -> Routes... -> Routes. Notice, under options at the top of the page you can search for Routes or Route Plans. The distinction being, a Route is a set of waypoints where a Route Plan is a Route that has certain expectations, like time, distance, etc for a Device. Create a route and route plan in MyGeotab and the differences will become more clear. 

 

0
Comment actions Permalink
Geotab Developers 0 votes
Avatar

I already sent the clear all stops and added new stops to the device. I guess I wanted to send the waypoints (Route) to the Device. 
Is there a way to send a Route to a device? That is probably the question.

0
Comment actions Permalink
Mauricio Muniz 0 votes
Avatar

You will not send the actual Route object to a device. To clarify, the process of creating and sending a route to a device is: 

1. Create a route 
2. Send a clear all stops message to the device 
3. For each route plan item (waypoint) of the route send a text message with route message content to the device 

The device should have a text messaging device (Garmin) attached as well. 

Thanks, 

Steve

0
Comment actions Permalink
Geotab Developers 0 votes
Avatar

It doesn't appear the API provides a way to intercept the text (route) messages in the Drive app on the tablet so that I can parse them and then display the route for the driver in Google Maps for example. However, all the messages sent are stored in the database on your server so I can get them from there, correct?

I should also be able to create a message that has all stops in one message rather than a message per stop. Is that right?

0
Comment actions Permalink
Michael Ray 0 votes