1

Remote API - how to get units with last position in one shot?

Тема: Remote API - how to get units with last position in one shot?

Hi there!
Is there any way to get all the units with their respective last positions in one shot, using the Remote API?
So far it looks to me that I need to do a round-trip per unit to get the last position and its timestamp.
Is there at least a way to get those given a list of unit ids, in just one round-trip?
Actually, this last variant would be nice to refresh the displaying of their positions and timestamps only, client-side.
Any help on this?
Thanks in advance!

2

Remote API - how to get units with last position in one shot?

Re: Remote API - how to get units with last position in one shot?

Unit has flag 0x400 which contains  latest message and position of it. You can use search_items or update_data_flags with flags=0x1|0x400=1025(Decimal). Example of search_items params:

params={
    "spec":    {
        "itemsType":"avl_unit",    /* type of object to look for - unit */
        "propName":"sys_name",    /* search by name - "sys_name" */
        "propValueMask":"*",    /* asterisk means to find units with any names  */
        "sortType":""        /* empty value means to sort results by name */
    },
    "force":1,            /* cache is not used */
    "flags":1025,            /* object flags to be returned */
    "from":0,            /* starting index for returning result */
    "to":0                /* return maximum number of objects */
}

update_data_flags params example:

params={
    "spec":[            /* array of requests to the server */
        {
            "type":"type",        /* get objects by type */
            "data":"avl_unit",    /* type is set to "avl_unit" (so, get units) */
            "flags":1025,        /* get common information */
            "mode":0        /* set flags */
        }
    ]
}

Search_items always returns data, but  update_data_flags should be called once and after you can get events at avl_evts request. In the documentation we have an example of  Get Objects.

Mobile Development
Gurtam
3

Remote API - how to get units with last position in one shot?

Re: Remote API - how to get units with last position in one shot?

Thanks you. This worked from the first shot.
Thanks again!