1. First (after login) it needs to add required units to session via request svc=events/update_units
http://sdk.wialon.com/wiki/en/sidebar/r … date_units
https://hst-api.wialon.com/wialon/ajax.html?svc=events/update_units¶ms={"mode":"add","units":[{"id":23130642,"detect":{"counters":0}},{"id":21728414,"detect":{"counters":0}}]}&sid=0277a2aae551196a2eba9160ea3ab0b
"units" - units array where 'id' - unit's id, 'detect' - required events types, in our case only "counters":0 means to all counters data
2. After required units has been added to session, we can get online the mileage update via request events/check_updates which can be executed for example every 2 sec or rarely , it depends on how often the device sends data to the server
https://hst-api.wialon.com/wialon/ajax.html?svc=events/check_updates¶ms={"detalization":3}&sid=0277a2aae551196a2eba9160ea3ab0b5
First response returns the latest data (the latest message)
{
"21728414": [
{
"counters": {
"from": {
"t": 1618315947,
"y": 45.8113670349,
"x": 15.9847402573
},
"to": {
"t": 1618315947,
"y": 45.8113670349,
"x": 15.9847402573
},
"m": 1618315947,
"f": 0,
"engine_hours": 720000,
"mileage": 981000,
"bytes": 77272248
}
}
]
}
Next - empty response as there is not yet new messages coming
{}
New message coming
{
"21728414": [
{
"counters": {
"from": {
"t": 1618316007,
"y": 45.8113670349,
"x": 15.9847402573
},
"to": {
"t": 1618316007,
"y": 45.8113670349,
"x": 15.9847402573
},
"m": 1618316007,
"f": 0,
"engine_hours": 720000,
"mileage": 981000,
"bytes": 77272248
}
}
]
}
Next new messages, and mileage has been changed -
{
"21728414": [
{
"counters": {
"from": {
"t": 1618316172,
"y": 41.8631362915,
"x": 15.1339998245
},
"to": {
"t": 1618316172,
"y": 41.8631362915,
"x": 15.1339998245
},
"m": 1618316172,
"f": 0,
"engine_hours": 720000,
"mileage": 1048965,
"bytes": 77277336
}
}
]
}
{
"21728414": [
{
"counters": {
"from": {
"t": 1618316472,
"y": 41.8631362915,
"x": 11.1339998245
},
"to": {
"t": 1618316472,
"y": 41.8631362915,
"x": 11.1339998245
},
"m": 1618316472,
"f": 0,
"engine_hours": 720000,
"mileage": 1825490,
"bytes": 77277336
}
}
]
}
So you can calculated difference between messages for parameter 'mileage' (in meters)
In example above the total difference is (1825490 - 981000 ) / 10000 = 844.49 km