rimes rimes - 6 months ago 31
Linux Question

Linux -OpenWrt- (Unwired One) python wlan interface scan error

The thing I am trying to achive, I want my android app to get a list of all available wlan connections within the range of a device with a wlan (at that point the device is an access point). Then I want to tell that device to which network to connect. So far so good.

I am trying to access the wlan module on my openwert device via python. I am using this [1] python module. When I execute the following example code

python iwlist.py wlan0 scanning


i get the error

Interface does not support scanning


Then I started to dig inside of the code, and the real error message is this one:

Argument list too long


and this error is comming from the module (from the file iwlibs.py). The exact code snippet (class Iwrange, update()) where it is comming from :

buff, s = iwstruct.pack_wrq(640)
print "Now comes the error"
status, result = iwstruct.iw_get_ext(self.ifname,
pythonwifi.flags.SIOCGIWRANGE,
data=s)


I dont know if it is of any help, but I also checked the buff variable and it just says 0x00 (I guess there should be some other stuff too bcz it is indicating some address in the memory, but of course I could be wrong too and the buffer is just being initialized there).

So, I am not sure what the problem is, it seems to me, maybe, that the reserver space (or buffer?) is too small for the stuff that is being returnd.
Does anybody know what else I could try in order to get this working ?

And one more thing, I also downloaded wireless_tools and now I can use iwlist. I can also scan and get the list of all surrounding wlan networks. So it seems the hardware is working fine, I am just not accessing it properly with python

[1] https://pypi.python.org/pypi/python-wifi/0.6.1

Answer

Just as an info, i solved my issue by changing the module I have been using. Now I am using [1]. When I execute this code

from wifi import Cell, Scheme
print "%s" %(Cell.all('wlan0'))

I get a list with all surrounding networks. Then I have just to choose one of them (by the SSID) and make my connection

[1]https://wifi.readthedocs.io/en/latest/