Reputation: 38
I am working raspberry pi to find and connect all available wifi connections. How can I find and list all WIFI Networks available using python. Can we print all available wifi connections by using python sockets. If sockets can't do this job then which library can we use to do so?
Upvotes: 0
Views: 12001
Reputation: 993
I think one of the best modules for wifi manipulation in python is the wifi package.
pip install wifi
Simple use case is; (replace "wlan0" with your wireless device id)
from wifi import Cell, Scheme
list(Cell.all('wlan0'))
This will return a list of Cell objects. Each object will have the following attributes:
For cells that have encrypted as True, there will also be the following attributes:
To connenc to an AP;
cell = list(Cell.all('wlan0'))[0]
scheme = Scheme.for_cell('wlan0', 'home', cell, passkey)
scheme.save()
scheme.activate()
scheme = Scheme.find('wlan0', 'home')
scheme.activate()
for more info goto https://wifi.readthedocs.io/en/latest/
Upvotes: 2