OpenWrt Forum Archive

Topic: [noob] iwconfig or iw: can't get wifi info!

The content of this topic has been archived on 4 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi to all!

I'm trying to do some experiment but i'm stucked.

I have a TP-Link WR842ND with OpenWrt well installed and operating.

Wifi is on as AP and i have one station linked as client (an android phone), so via LUCI i can see it and get infos about the link quality and signal strenght. All is ok.

luciwifi
http://montebue.altervista.org/luciinfo.PNG

Now i want to get these identical infos from shell but something doesn't work (i'm noob, maybe i do a mistake greater than an house!):

root@OpenWrt:~# iwconfig wlan0
wlan0     IEEE 802.11bgn  Mode:Master  Tx-Power=21 dBm
          RTS thr:off   Fragment thr:off
          Power Management:on

root@OpenWrt:~# iw dev wlan0 station dump
Station 00:92:cc:04:95:0f (on wlan0)
        inactive time:  3590 ms
        rx bytes:       10763
        rx packets:     282
        tx bytes:       7627
        tx packets:     98
        tx retries:     3
        tx failed:      0
        signal:         -44 [-61, -44] dBm
        signal avg:     -43 [-59, -43] dBm
        tx bitrate:     43.3 MBit/s MCS 4 short GI
        rx bitrate:     24.0 MBit/s
        authorized:     yes
        authenticated:  yes
        preamble:       long
        WMM/WME:        yes
        MFP:            no
        TDLS peer:      no
root@OpenWrt:~# cat /proc/net/wireless
Inter-| sta-|   Quality        |   Discarded packets               | Missed | WE
 face | tus | link level noise |  nwid  crypt   frag  retry   misc | beacon | 22
 wlan0: 0000    0     0     0        0      0      0      0      0        0
root@OpenWrt:~#

With IWCONFIG and in /proc/net/wireless i can't get any information about connection!
Only using iw i can get some infos about each station linked.

Why i can't get the same infos as printed in LUCI, using iwconfig?

Many thanx!

Does iwlist give any more info?
I have this thought in the back of my head that iwconfig is not fully implemented, or maybe differently to standard linux.
What is in /proc/net/wireless? (eg cat,  ls, etc)

iwlist doesn't give more information and seems that is not compatible (?)

root@OpenWrt:~# iwlist wlan0 txpower
wlan0     unknown transmit-power information.

In /proc/net/wireless as i posted before no result!!

root@OpenWrt:~# cat /proc/net/wireless
Inter-| sta-|   Quality        |   Discarded packets               | Missed | WE
 face | tus | link level noise |  nwid  crypt   frag  retry   misc | beacon | 22
 wlan0: 0000    0     0     0        0      0      0      0      0        0

but in LUCI all data info are ok!!! how can i get it?

From iwconfig the same result...

root@OpenWrt:~# iwconfig wlan0
wlan0     IEEE 802.11bgn  Mode:Master  Tx-Power=21 dBm
          RTS thr:off   Fragment thr:off
          Power Management:on

:-(

LuCI uses a custom library which assembles information from various places. You can install a CLI frontend to this library with "opkg update; opkg install iwinfo", then call "iwinfo wlan0"

Many thanx jow, i have just done it:

root@OpenWrt:~# iwinfo wlan0 info
wlan0     ESSID: "Piane di Sopra"
          Access Point: F8:D1:11:BE:51:E4
          Mode: Master  Channel: 11 (2.462 GHz)
          Tx-Power: 21 dBm  Link Quality: 60/70
          Signal: -50 dBm  Noise: -95 dBm
          Bit Rate: 43.3 MBit/s
          Encryption: WPA2 PSK (CCMP)
          Type: nl80211  HW Mode(s): 802.11bgn
          Hardware: 168C:002E 168C:A199 [Generic MAC80211]
          TX power offset: unknown
          Frequency offset: unknown
          Supports VAPs: yes

Now i can get info and parse it for a sh script....but the question remains: why iwconfig and /proc/net/wireless don't work???
Thanx!

Because they use deprecated APIs which are scheduled for removal.

Oh! now it's clear... someone in the next future will must update wiki reference to iwconfig.

Many many thanx!

--------
For anyone that came here trying use iwconfig to get quality link, this script will help:

#Read iwinfo return datas
reading=$(iwinfo wlan0 info | grep -i quality)
#Extract only interesting char
sig=${reading:42:2}
max=${reading:45:2}
qual=$((sig*100))
qual=$((qual/max))
echo Signal Quality WiFi $sig/$max = $qual%

I added a quick note and a link to here in the wireless utilities wiki page.

Perfect!
Thanx to all!

The discussion might have continued from here.