PHP API Wireless scan

I am trying to use the PHP API (http://wiki.mikrotik.com/wiki/API_PHP_package) to issue ‘/interface wireless scan duration=20 number=0’ command. I am issuing the command from the Ethernet port so I am not worried about disconnecting the API.

The start of my code:

<?php use PEAR2\Net\RouterOS; use PEAR2\Net\Transmitter; require_once 'PEAR2/Autoload.php'; $client = new RouterOS\Client('192.168.88.1', 'admin', ''); $mydata = $client->sendSync(new RouterOS\Request('/interface wireless scan duration=20 number=0'))->getAllOfType(RouterOS\Response::TYPE_DATA); print_r($mydata); ?>

The command comes back way too fast to have done the scan. If I issue a command like ‘/system leds print’ I get the expected data returned. Does anyone have a working example? thanks

Chances are there was an error that terminated the command prematurely, if not instantaneously.

Normally, I’d suggest looking at the full responses (i.e. with the part “getAllOfType(RouterOS\Response::TYPE_DATA)” removed) for the error message(s), but in this case, the problem is clear already.

The “number” argument doesn’t accept a number. It accepts an ID or name of interface. So replace

number=0

with

number=wlan1

or whatever the name of the wireless interface is.

Thanks boen_robot! replacing the number=wlan1 did the trick.

Another question - below I have the response output. I do not see the “Flags” details - when I run the scan from the command line the first column has the “APRNTWB” flags.

Command line output:
ADDRESS SSID BAND CHA.. FREQ SIG NF SNR RADIO-NAME
A 54:35:30:51:98:41 HP-Print… 2ghz-n 20mhz 2432 -59 -95 36

PHP API Output:
PEAR2\Net\RouterOS\ResponseCollection Object
(
[responses:protected] => Array
(
[0] => PEAR2\Net\RouterOS\Response Object
(
[unrecognizedWords:protected] => Array
(
)
[_type:PEAR2\Net\RouterOS\Response:private] => !re
[attributes:protected] => Array
(
[address] => 54:35:30:51:98:41
[ssid] => HP-Print-41-Daddy’s Office
[band] => 2ghz-n
[channel-width] => 20mhz
[freq] => 2432
[sig] => -59
[nf] => -95
[snr] => 36
)


[_tag:PEAR2\Net\RouterOS\Message:private] =>
)

I’m guessing this is a RouterOS bug. Report it to support.

(I don’t have WiFi on my router to actually test…)

The only other possible option is that flags are applicable to the entire scan, and not per-AP, in which case they should be in the Response::TYPE_FINAL response. To absolutely make certain, remove “->getAllOfType(RouterOS\Response::TYPE_DATA)”, and check the output of that. If the flags are not there, it’s a RouterOS bug.

Thanks boen_robot - I am told that the issue is a bug…