Community discussions

MikroTik App
 
iq25
just joined
Topic Author
Posts: 17
Joined: Wed Mar 13, 2013 2:38 pm

TX-power value ouput using API

Thu Apr 18, 2013 2:06 pm

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
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: TX-power value ouput using API

Thu Apr 18, 2013 3:33 pm

I'm not sure I follow... how would you do that from terminal? How does the long string differ from the integer value?
 
iq25
just joined
Topic Author
Posts: 17
Joined: Wed Mar 13, 2013 2:38 pm

Re: TX-power value ouput using API

Thu Apr 18, 2013 3:44 pm

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
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: TX-power value ouput using API

Thu Apr 18, 2013 3:58 pm

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'); 
 
iq25
just joined
Topic Author
Posts: 17
Joined: Wed Mar 13, 2013 2:38 pm

Re: TX-power value ouput using API

Thu Apr 18, 2013 4:18 pm

Unfortunately it doesn't work for me. It returns empty string.
BTW I am using ROS v6.0rc11
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: TX-power value ouput using API

Thu Apr 18, 2013 4:23 pm

What does
$printRequest = new RouterOS\Request('/interface wireless print detail="" stats', RouterOS\Query::where('name', 'wlan1'));
var_dump($client($printRequest)->getAllArguments()); 
output?
 
iq25
just joined
Topic Author
Posts: 17
Joined: Wed Mar 13, 2013 2:38 pm

Re: TX-power value ouput using API

Thu Apr 18, 2013 4:41 pm

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.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: TX-power value ouput using API

Thu Apr 18, 2013 5:30 pm

for wireless you have to use
print advanced
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.
 
iq25
just joined
Topic Author
Posts: 17
Joined: Wed Mar 13, 2013 2:38 pm

Re: TX-power value ouput using API

Thu Apr 18, 2013 5:56 pm

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');
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: TX-power value ouput using API

Fri Apr 19, 2013 12:30 pm

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
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: TX-power value ouput using API

Fri Apr 19, 2013 12:57 pm

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')); 
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: TX-power value ouput using API

Fri Apr 19, 2013 4:22 pm

.proplist was used to give useful example of the result. Other way it would be overcrowded with irrelevant data.

Who is online

Users browsing this forum: No registered users and 8 guests