I want to operate a WiFi dongle with RaspberryPi, (it\'s like a CPU without built-in WiFi). I need to write a python script which automatically scan for WiFi networks and a conn
wifi is a python library for scanning and connecting to wifi networks on linux. You can use it to scan and connect to wireless networks.
It doesn't have any built-in support for connecting automatically to a network, but you could easily write a script to do that. Here's an example of a basic idea for how to do this.
#!/usr/bin/python
from __future__ import print_function
from wifi import Cell, Scheme
# get all cells from the air
ssids = [cell.ssid for cell in Cell.all('wlan0')]
schemes = list(Scheme.all())
for scheme in schemes:
ssid = scheme.options.get('wpa-ssid', scheme.options.get('wireless-essid'))
if ssid in ssids:
print('Connecting to %s' % ssid)
scheme.activate()
break
I just wrote it and it seems to work. Just so you know, I wrote the wifi library. If you want me to add this feature to that library, I could.