Convert iwinfo output [Solve]

hi all,
i want to covert output of iwinfo wifi1 scan

Cell 01 - Address: 50:0F:80:6B:9C:7F
          ESSID: unknown
          Mode: Master  Channel: 153
          Signal: -82 dBm  Quality: 31/94
          Encryption: WPA2 PSK (CCMP)

Cell 02 - Address: 50:0F:80:6B:9C:7G
          ESSID: unknown
          Mode: Master  Channel: 153
          Signal: -82 dBm  Quality: 31/94
          Encryption: WPA2 PSK (CCMP)

to this json format:

[
 {
   "Address": "50:0F:80:6B:9C:7F",
   "ESSID": "unknown",
   "Mode": "Master",
   "Channel": "153",
   "Signal": "-82 dBm",
   "Quality": "31/94"
   "Encryption": "WPA2 PSK (CCMP)"
 },
 {
   "Address": "50:0F:80:6B:9C:7G",
   "ESSID": "unknown",
   "Mode": "Master",
   "Channel": "153",
   "Signal": "-82 dBm",
   "Quality": "31/94"
   "Encryption": "WPA2 PSK (CCMP)"
 }
]

Anyone have an idea for me to do that?

ubus call iwinfo scan '{ "device": "wifi1" }'

in my device ubus command available only this :

user@GL-B1300:~# ubus list
glcrond
log
mwan3
network
network.device
network.interface
network.interface.guest
network.interface.lan
network.interface.loopback
network.interface.wan
network.wireless
service
session
system
uci

when i run that command :

user@GL-B1300:~# ubus call iwinfo scan '{ "device": "wifi1" }'
Command failed: Not found

You could install rpcd-mod-iwinfo to get iwinfo ubus procedures.

Alternative Lua solution:

lua -liwinfo -lluci.jsonc -e 'print(luci.jsonc.stringify(iwinfo.nl80211.scanlist("wifi1")))'

1 Like

i try install it. but same, iwinfo still not found :

user@GL-B1300:~# opkg install rpcd-mod-iwinfo_2016-06-30-23417e94d25570e6d62542bac46edd51e8e0243a_ipq.ipk
Installing rpcd-mod-iwinfo (2016-06-30-23417e94d25570e6d62542bac46edd51e8e0243a) to root...
Configuring rpcd-mod-iwinfo.
user@GL-B1300:~# ubus list
glcrond
log
mwan3
network
network.device
network.interface
network.interface.guest
network.interface.lan
network.interface.loopback
network.interface.wan
network.wireless
service
session
system
uci
user@GL-B1300:~# ubus call iwinfo scan '{ "device": "wifi1" }'
Command failed: Not found

Try a service rpcd restart

thanks a lot. its solve. :grinning:

sory dude, how do you get object nl80211 on iwinfo.nl80211.scanlist("wifi1")) ?

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.