1

What's new in Wialon API

Тема: What's new in Wialon API

On this topic we will publish new additional methods in API, new custom parameters, what can be changed or not actual yet. The changes with API happen seldom, but sometimes it needs to post about something new.

Diana Cheley
Wialon Hosting Expert
Gurtam
2

What's new in Wialon API

Re: What's new in Wialon API

Upcoming update will include the following  :

There are new extra parameters in parameter "c" (configuration) in sensor's settings :
1. "calc_fuel"  - all fuel sensors will have this parameter to activate fuel calculation in report. The action is the same as flag activation via request
https://sdk.wialon.com/wiki/en/sidebar/ … calc_types
2. The fuel sensors will have extra parameters  :
- "fuel_params" - the fuel level settings, the same as via request  https://sdk.wialon.com/wiki/en/sidebar/ … vel_params

For example, FLS sensor can have the following:

"fuel_params":{\"flags\":1728,\"ignoreStayTimeout\":20,\"minFillingVolume\":21,\"minTheftTimeout\":0,\"minTheftVolume\":15,\"filterQuality\":0,\"fillingsJoinInterval\":300,\"theftsJoinInterval\":300,\"extraFillingTimeout\":0}

- "engine_sensors" : new parameter for FLS sensor, which shows Engine sensors (list of id) bound to FLS ( time-based calculation of fuel consumption
- "engine_efficiency": parameter which shows bound Engine efficiency sensors (list of id)  to Engine Sensor

Diana Cheley
Wialon Hosting Expert
Gurtam
3

What's new in Wialon API

Re: What's new in Wialon API

Upcoming update will include the new action type "Upload video" for notifications functional

- "video_service" , parameters are optional. The new method allows to upload video file from device (videoservice)

Example

"act":[{"t":"video_service","p":{"channel_mask":1,"duration":15,"base_url":"http://hst-api.qa.wdc.dc/"}}]
Diana Cheley
Wialon Hosting Expert
Gurtam
4

What's new in Wialon API

Re: What's new in Wialon API

The new following request to work with video settings for unit

1.  unit/update_video_settings  - to update video settings

{
"itemId":long,
"settings":[{"name":"cam","flags":1},{"name":"cam1","flags":0}...]}

Empty JSON in case request successfully.

 {} 

2. To get such settings via request unit/get_video_settings

{"itemId": long}

Response

{"settings":[{"flags":1,"name":"cam"},{"flags":0,"name":"cam1"}...]}
Diana Cheley
Wialon Hosting Expert
Gurtam
5

What's new in Wialon API

Re: What's new in Wialon API

Good day!

Upcoming update will include the new API request

1.
Library unit types -

 svc=file/type_library&params={"lang":"text"}

Parameter "lang" is optional. By default  the langues from user session.

Response returns JSON with the full list of unit's types

2.
Add new field "vehicle_class" (param 'n') into request  item/update_profile_field. (The old field  "vehicle_type"  which created early is used)
The value (param "v") takes names as the last level from Library unit types

Example

svc=item/update_profile_field&params={"itemId":4958071,"n":"vehicle_class","v":"empty_compressor"}

Response
[
    2,
    {
        "id": 2,
        "n": "vehicle_class",
        "v": "empty_compressor"
    }
]
If the not correct value 'v', the response returns the error with description 
Example

{
    "error": 4,
    "reason": "Invalid vehicle_class value"
}

3.
Also it's possible to apply value for "vehicle_class" into request svc=core/search_items to search units/

For example, to get units with vehicle class 'van'
"propName":"profilefield"
"propValueMask":"van"

hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"avl_unit","propName":"profilefield","propValueMask":"van","sortType":"sys_name","propType":"profilefield"},"force":1,"flags":8388609,"from":0,"to":200}}],"flags":0}&sid=02673bc10dcf516e0d6647acf35331ce
Diana Cheley
Wialon Hosting Expert
Gurtam
6

What's new in Wialon API

Re: What's new in Wialon API

Hi Diana

The new 'vehicle type' feature in the Profile tab in 'Unit Properties' is great, but I can't get my head around on how I could get the vehicle type.  I am not sure what libraries I should load (eg session.loadLibrary("itemIcon") for Icons) and what dataflags I should set eg: (let unitflags = wialon.item.Item.dataFlag.base  |  wialon.item.Unit.dataFlag.lastMessage;), also for session.updateDataFlags(
            [{ type: "type", data: "avl_unit", flags: unitflags, mode: 0 }],...... what should the "type" and "data" be? And also what would the Javascript equivalent be: unit.getTypeLibrary or maybe unit.getLibrary?

Could you please give me a Javascript example on how to get the 'vehicle type'.  I've specified vehicles as "Passenger Transport -> Bus" and "Cargo Transport - Heavy Truck" and need to retrieve this info to use in my custom app.

Thank you in advance.

Best regards
Annanda

7

What's new in Wialon API

Re: What's new in Wialon API

Hello Annanda!

To get "vehicle_class" (the new field for vehicle type)  or "vehicle_type" (old property)  from Profile fields  you need to add library itemProfileFields  as session property, and included flags 8388608  to get profile fields

var sess = wialon.core.Session.getInstance();
sess.loadLibrary("itemProfileFields");
var flags = 1 + 8388608; //bacis flag + profile fields

  sess.updateDataFlags( // load items to current session
    [{type: "type", data: "avl_unit", flags: flags, mode: 0}], // Items specification
        function (code) { // updateDataFlags callback
            .....
.......
.....
        }
    );

Please look here the full list of libraries -  https://forum.gurtam.com/viewtopic.php? … 13#p161813

Diana Cheley
Wialon Hosting Expert
Gurtam
8

What's new in Wialon API

Re: What's new in Wialon API

Perfect! Thank you Diana.