Page 1 of 1
TX-power value ouput using API
Posted: Thu Apr 18, 2013 2:06 pm
by iq25
Hi all!
I am using PEAR2/Net/RouterOS and PHP to get some monitoring information. I can't figure out how to get specific info from wireless interface. How to write a request to get tx-power of wireless card. I am able to get current-tx-power which is long string, but not tx-power integer value.
Thanks
Re: TX-power value ouput using API
Posted: Thu Apr 18, 2013 3:33 pm
by boen_robot
I'm not sure I follow... how would you do that from terminal? How does the long string differ from the integer value?
Re: TX-power value ouput using API
Posted: Thu Apr 18, 2013 3:44 pm
by iq25
When I issue command in terminal
/interface wireless> :put [get 0 tx-power]
I get value of transmit power which I have entered in wireless card's Tx Power tab previously.
It would be nice to get this number without parsing current-tx-power
Re: TX-power value ouput using API
Posted: Thu Apr 18, 2013 3:58 pm
by boen_robot
Assuming the interface's name is "wlan1", you should be able to get the tx power like:
$printRequest = new RouterOS\Request('/interface wireless print', RouterOS\Query::where('name', 'wlan1'));
$txPower = $client($printRequest)->getArgument('tx-power');
If that alone doesn't work, try adding "detail" and/or "stats", e.g.
$printRequest = new RouterOS\Request('/interface wireless print detail="" stats', RouterOS\Query::where('name', 'wlan1'));
$txPower = $client($printRequest)->getArgument('tx-power');
Re: TX-power value ouput using API
Posted: Thu Apr 18, 2013 4:18 pm
by iq25
Unfortunately it doesn't work for me. It returns empty string.
BTW I am using ROS v6.0rc11
Re: TX-power value ouput using API
Posted: Thu Apr 18, 2013 4:23 pm
by boen_robot
What does
$printRequest = new RouterOS\Request('/interface wireless print detail="" stats', RouterOS\Query::where('name', 'wlan1'));
var_dump($client($printRequest)->getAllArguments());
output?
Re: TX-power value ouput using API
Posted: Thu Apr 18, 2013 4:41 pm
by iq25
I am not very strong in PHP
I hope did everything right.
Output:
array (size=1)
'message' => string 'unknown parameter' (length=17)
Looks like command doesnt like 'stats'
Once again output:
array (size=28)
'.id' => string '*4' (length=2)
'name' => string 'wlan1' (length=5)
'mtu' => string '1500' (length=4)
'l2mtu' => string '2290' (length=4)
'mac-address' => string 'xx:xx:xx:xx:xx:xx' (length=17)
'arp' => string 'enabled' (length=7)
'interface-type' => string 'Atheros AR92xx' (length=14)
'mode' => string 'ap-bridge' (length=9)
'ssid' => string 'xxx' (length=6)
'frequency' => string '2412' (length=4)
'band' => string '2ghz-b/g' (length=8)
'channel-width' => string '20mhz' (length=5)
'scan-list' => string 'default' (length=7)
'wireless-protocol' => string '802.11' (length=6)
'wds-mode' => string 'disabled' (length=8)
'wds-default-bridge' => string 'none' (length=4)
'wds-ignore-ssid' => string 'false' (length=5)
'bridge-mode' => string 'enabled' (length=7)
'default-authentication' => string 'true' (length=4)
'default-forwarding' => string 'true' (length=4)
'default-ap-tx-limit' => string '0' (length=1)
'default-client-tx-limit' => string '0' (length=1)
'hide-ssid' => string 'false' (length=5)
'security-profile' => string 'xxxx' (length=14)
'interworking-profile' => string 'disabled' (length=8)
'compression' => string 'false' (length=5)
'running' => string 'false' (length=5)
'disabled' => string 'false' (length=5)
Now I dont know from where it takes this value I can see in terminal.
Re: TX-power value ouput using API
Posted: Thu Apr 18, 2013 5:30 pm
by janisk
for wireless you have to use
and tx-power will not be reported if tx-power-mode=default
and tx-power mode only can safely be used if you have to reduce tx-power of the card.
Re: TX-power value ouput using API
Posted: Thu Apr 18, 2013 5:56 pm
by iq25
Paldies janisk!
My tx-power-mode=all-rates-fixed.
I tried command you suggested in terminal. Now I see tx-power among lot of parameters. But question is does php API allows me to use the command because var_dump returned:
array (size=1)
'message' => string 'no such command' (length=15)
Edited later:
Thank you both again. I got it working using this code.
$printRequest = new RouterOS\Request('/interface wireless print advanced=""', RouterOS\Query::where('name', 'wlan1'));
$txPower = $client($printRequest)->getArgument('tx-power');
Re: TX-power value ouput using API
Posted: Fri Apr 19, 2013 12:30 pm
by janisk
using demo python api:
/interface/wireless/print
=advanced=
=.proplist=tx-power
<<< /interface/wireless/print
<<< =advanced=
<<< =.proplist=tx-power
<<<
>>> !re
>>> =tx-power=17
>>>
>>> !done
>>>
and for comparison:
/interface/wireless/print
=.proplist=tx-power
<<< /interface/wireless/print
<<< =.proplist=tx-power
<<<
>>> !re
>>>
>>> !done
>>>
maybe boen_robot can shed some light on use of PHP API
Re: TX-power value ouput using API
Posted: Fri Apr 19, 2013 12:57 pm
by boen_robot
maybe boen_robot can shed some light on use of PHP API
iq25 figured it out already ^_^ .
If .proplist is to be included, it's as simple as
$printRequest = new RouterOS\Request('/interface wireless print .proplist=tx-power advanced', RouterOS\Query::where('name', 'wlan1'));
Re: TX-power value ouput using API
Posted: Fri Apr 19, 2013 4:22 pm
by janisk
.proplist was used to give useful example of the result. Other way it would be overcrowded with irrelevant data.