Hi, we are building a system in python for administrate the networks on Edison device, there is an web interface who receive the data of the network and create a file into the /etc/wpa_suplicant and then use the command for configure wifi with this new file.
For network scan we are using the command iwlist wlan0 scan this return a string and I process the text to find the network information
There is a better way to do it, for instance using the Edison configule cli ?? but how to do it with python
I apologize for the delay in our response, in order to manage the networks and configure them in your board using Python one good options would be using the wifi library.
In order to install this library you need to run the command pip install WiFi, if you have the latest image installed in your board it should work fine, if you are using another image you may need to install pip.
Take a look at the following links:
I have a problem with this library, the thing is when I use it, there is a problem with the /etc/network/interfaces, this file doesn't exist, then I created with touch but when I execute the command scheme.activate(), python throws an error
File "", line 1, in
File "/usr/lib/python2.7/site-packages/wifi/scheme.py", line 173, in activate
ifup_output = subprocess.check_output(['/sbin/ifup'] + self.as_args(), stderr=subprocess.STDOUT)
File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['/sbin/ifup', 'wlan0=wlan0-insite5.0', '-o', 'wpa-psk=PSKLINE', '-o', 'wpa-ssid=SSID', '-o', 'wireless-channel=auto']' returned non-zero exit status 1
what I should do ?
I have the same behavior you have while running a script that connects the board to WiFi with python, the problem is that the Edison do not use the /etc/network/interfaces by default (I had to create the file too) so there are some problems with this.
The error your code throws (Could you post a snippet of your code so we could test the same code?) is related with the scheme.py and while using the ifup command for the new ssid, you can modify this code in order to use ifconfig and make it work.
Another way to do this, is with os commands, in order to do system calls and connect the board with a specific ssid.
I haven't found another wifi library for python that works on the first go yet, but I will let you know if I find one.
The scan feature seems to work fine, and it shows all the available cells, please let me know if the only feature in this library that is not working for you is while connecting to a ssid.
Hi Charlie, currently I'm using the python file which is used for the configure_edison command, which is located in the root /. There I found how to scan networks and how to connect.
But I have other problem, I need to set the intel Edison as Add-Hock, then I used this command
os.system("ifconfig wlan0 up && iwconfig wlan0 mode ad-hoc && iwconfig wlan0 essid \""+essid+"\" && ifconfig wlan0 "+ip+" && killall dnsmasq && dnsmasq -7 /etc/dnmasq/")
when essid is my essid and the ip variable is the ip to the Edison, but I need to start a DCHP server for the other devices connected to the Edison, but I have no idea how to do it !
Do you receive an error message after using the command on the Terminal Console (without using the OS functions in Python? Or is it just that it doesn't work?
There are some links you could see regarding how to set the ad-hoc:
https://communities.intel.com/message/370335# 370335 https://communities.intel.com/message/370335# 370335
Try to set it first in Linux and then with the OS commands for Python.