Тема: 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?
Вы не вошли. Пожалуйста, войдите или зарегистрируйтесь.
hi there
Can anyone help us how to get device connection state (http://docs.wialon.com/en/hosting/user/ … tion_state) using remote API?
hhamedk, you can check time of unit's last message and if it is older than 10 minutes mark it as not connected.
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.
hhamedk, you can use this method - if any "tcp" or "udp" command is available - then unit has active GPRS connection to server.
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.
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.
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?
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.
Thank you deal , I am really grateful.