1

Device Connection State

Topic: Device Connection State

hi there

Can anyone help us how to get device connection state (http://docs.wialon.com/en/hosting/user/ … tion_state) using remote API?

2

Device Connection State

Re: Device Connection State

hhamedk, you can check time of unit's last message and if it is older than 10 minutes mark it as not connected.

Head of Wialon Local Department
Gurtam
3

Device Connection State

(edited by hhamedk 30/04/2016 08:14:51)

Re: Device Connection State

Hi there!

Is there any way to check TCP connection state between device and server? As i understood the connection state you show in monitoring panel is based on last message time and can't exactly explain if TCP connection is established or not.

4

Device Connection State

Re: Device Connection State

hhamedk, you can use this method - if any "tcp" or "udp" command is available - then unit has active GPRS connection to server.

At the dark side of telematics...
5

Device Connection State

Re: Device Connection State

Hi!

I am using the API javascript but, is there any way of get or know the state of device online or offline?

Suggest please and thanks.

6

Device Connection State

Re: Device Connection State

Denisse, for now You can do it like this:
1. set Available commands data flag (https://sdk.wialon.com/wiki/en/sidebar/ … e_commands)
2. then You can get unit's currently available commands:
unit.getCommands()
3. in resulting array check if any command contains "tcp" or "udp" value in "t" parameter (for example "tcp,gsm").
If contains - unit has active GPRS connection.

Head of Wialon Local Department
Gurtam
7

Device Connection State

Re: Device Connection State

deal

Can you only get them that way ?, because I need to get all the devices of my own, that is, those who have few online or offline or can create a report and then know that teams are presented disconnect?

8

Device Connection State

Re: Device Connection State

Denisse, You can do it in cycle for all units.
Like this:

var onlineUnits = [];
var units = wialon.core.Session.getInstance().getItems("avl_unit");
for (var i = 0; i < units.length; i++) {
var unit = units[i];
if (!unit)
continue;
var cmds = unit.getCommands();
if (!cmds)
continue;
for (var j = 0; j < cmds.length; j++) {
var cmd = cmds[j];
if (cmd.t.indexOf("tcp") >=0 || cmd.t.indexOf("udp") >=0)
onlineUnits.push(unit.getId());
}
}

This way is not very convenient but soon there will be available additional unit's paramter which will indicate is unit online or offline.

Head of Wialon Local Department
Gurtam
9

Device Connection State

Re: Device Connection State

Thank you deal , I am really grateful.