Community discussions

MUM Europe 2020
 
User avatar
MaHr
just joined
Topic Author
Posts: 21
Joined: Wed Apr 22, 2009 2:59 am
Location: Czech Republic

API wireless scan

Sun Nov 29, 2009 2:49 am

Hello,
1/ I am testing API on routerOS v3.33 and I receive not same values as If scan was running on telnet connection, exactly I see Adress, ssid, level, noise, sn, radioname, but not Flags (if scanned APs are active, or if is it Bridge and so on). In telnet is possible to see which APs are still active (A flags) but in API not. This is problem for me, therefore I put this APs to own list, which is still refreshed and in !re response is possible to see also AP which is not active and I can not to know which from this list is active or not ;-(
Can somebody help me with this, how to simply solve it?
2/ If wireless scan have in list aprox. more than 20 items, scan is looking that still running, but is not true (maybe the problem is, that more than 15 APs are inactive and still in list). Only restart scan is solution ;-( Question is, why in Winbox this scan working continuously for all the time if scan running :-)
Thanks in advance
Kind Regards
Martin



--
Everythink is possible, but the time what we spend on this is more than we want ...
 
igorlor
just joined
Posts: 5
Joined: Mon Jul 11, 2011 11:23 am

Re: API wireless scan

Mon Jul 11, 2011 11:43 am

Hey,

could you tell me what command do you use to scan wireless networks using the API? I am trying to develop an app using the API but i don´t find the correct command.

Thanks,

Igorlor
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API wireless scan

Tue Jul 12, 2011 1:21 pm

use something like this - scan using interface wlan1
/interface/wireless/scan
=.id=wlan1
 
igorlor
just joined
Posts: 5
Joined: Mon Jul 11, 2011 11:23 am

Re: API wireless scan

Wed Jul 13, 2011 9:47 am

I use this code:
       ret.sendCommand("/interface/wireless/scan");
       ret.sendCommand("=.id=wlan1");
       ret.sendCommand("=duration=3");
I dont know what could be wrong but the response is this one:
Mikrotik:
!trap
=message=no such item (4)
Mikrotik:
!done
Mikrotik:
!trap
=message=no such command prefix
Mikrotik:
!done
Mikrotik:
!trap
=message=no such command prefix
Mikrotik:
!done
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API wireless scan

Wed Jul 13, 2011 10:10 am

check if you are correctly sending in commands, as some of implementations require you to set additional variable to indicate that new line will follow.

Also, my suggestion would be to upgrade to version 5.x, I tested the command on 5.5 and 5.6
 
mysz0n
Member Candidate
Member Candidate
Posts: 125
Joined: Tue Mar 03, 2009 2:14 am

Re: API wireless scan

Mon Sep 19, 2011 2:12 pm

i got the same problem:
$API->write('/interface/wireless/scan');
$API->write('=.id=wlan1');
$API->write("=duration=3");
$skan = $API->read();
and i got error
Array ( [!trap] => Array ( [0] => Array ( [message] => no such command prefix ) [1] => Array ( [message] => no such command prefix ) [2] => Array ( [message] => no such item (4) ) ) )
RB711 with 5.7 ros
 
tnakir
Frequent Visitor
Frequent Visitor
Posts: 54
Joined: Thu Aug 19, 2010 4:29 pm

Re: API wireless scan

Mon Sep 19, 2011 4:02 pm

Janisk, when i do /interface/wireless/scan bla bla through the api, i get maximum one or two lines back. I set duration for 10 seconds. When i do scan over winbox i get over 15 networks.

I've been struggleing with this scan for quite some time now. Could you please be helpful?

The code is (using C# api):
Console.Write("Connecting to Mikrotik... ");
MK myTik = new MK("192.168.168.188");
Console.WriteLine("OK");
Console.WriteLine("Logging in...");
myTik.Login("admin", "");
Console.WriteLine("Loged in...");
Console.WriteLine("Performing scan...");
myTik.Send("/interface/wireless/scan");
myTik.Send("=.id=wlan1");
myTik.Send("=duration=5", true);
//System.Threading.Thread.Sleep(4500);
Console.WriteLine("Scan complete...");
List<String> Result = myTik.Read();
 
User avatar
astounding
Member Candidate
Member Candidate
Posts: 121
Joined: Tue Dec 16, 2008 12:17 am

Re: API wireless scan

Sat Oct 15, 2011 2:48 am

Is it possible that the duration parameter is not being interpreted as seconds, but perhaps tenths of seconds or some other unit of time? Testing using the Ruby API library and connecting to a RB411 running version RouterOS version 4.11 (I didn't realize, I'm running 4.11 on a 411... *chuckle*), when I set the duration to anything less than about 40, I would get a reply sentence back telling me my command was done, but no other output. When I used longer durations, the API would return multiple sentences showing me replies that I would expect.
$ tikcli hostname user password

... login sequence output omitted ...

Command (/quit to end): /interface/wireless/scan =.id=wlan1 =duration=20
=== COMMAND: /interface/wireless/scan
<<< '/interface/wireless/scan' (24)
<<< '=.id=wlan1' (10)
<<< '=duration=20' (12)
<<< '.tag=9' (6)
<<< END-OF-SENTENCE

>>> '!done' (5)
>>> '.tag=9' (6)
>>> END-OF SENTENCE


Command (/quit to end): /interface/wireless/scan =.id=wlan1 =duration=40
=== COMMAND: /interface/wireless/scan
<<< '/interface/wireless/scan' (24)
<<< '=.id=wlan1' (10)
<<< '=duration=40' (12)
<<< '.tag=2' (6)
<<< END-OF-SENTENCE

>>> '!re' (3)
>>> 'address=00:01:DE:AD:BE:EF' (25)
>>> 'ssid=' (5)
>>> 'band=5ghz-h' (11)
>>> 'freq=9999' (9)
>>> 'sig=-79' (7)
>>> 'nf=-102' (7)
>>> 'snr=23' (6)
>>> 'radio-name=BogusAP' (18)
>>> '.tag=2' (6)
>>> END-OF SENTENCE

>>> '!done' (5)
>>> '.tag=2' (6)
>>> END-OF SENTENCE
When I specified durations in the range 5 to 20, on average, I would receive the "!done" sentence back (with no other replies) in approximately two seconds. That is why I wonder exactly what units the duration is specifying.

It's possible there is a bug in the RouterOS versions you and I used. I don't know if this is a bug or a feature. And my web searches didn't point me to a Wiki page documenting what units duration specifies for the /interface/wireless/scan command.

Wondering,
Aaron out.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API wireless scan

Mon Oct 17, 2011 3:06 pm

this problem will be fixed in 5.8.

for previous versions one has to enter value in deka seconds. :(

Who is online

Users browsing this forum: No registered users and 19 guests