Skip to main content

A cross-platform module for manipulating WiFi devices.

Project description

pywifi

Build Status PyPI version

pywifi provides a cross-platform Python module for manipulating wireless interfaces.

  • Easy to use
  • Supports Windows and Linux

Prerequisites

On Linux, you will need to run wpa_supplicant to manipulate the wifi devices, and then pywifi can communicate with wpa_supplicant through socket.

On Windows, the Native Wifi component comes with Windows versions greater than Windows XP SP2.

Installation

After installing the prerequisites listed above for your platform, you can use pip to install from source:

cd pywifi/
pip install .

Documentation

For the details of pywifi, please refer to Documentation.

Example

import pywifi

wifi = pywifi.PyWiFi()

iface = wifi.interfaces()[0]

iface.disconnect()
time.sleep(1)
assert iface.status() in\
    [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]

profile = pywifi.Profile()
profile.ssid = 'testap'
profile.auth = const.AUTH_ALG_OPEN
profile.akm.append(const.AKM_TYPE_WPA2PSK)
profile.cipher = const.CIPHER_TYPE_CCMP
profile.key = '12345678'

iface.remove_all_network_profiles()
tmp_profile = iface.add_network_profile(profile)

iface.connect(tmp_profile)
time.sleep(30)
assert iface.status() == const.IFACE_CONNECTED

iface.disconnect()
time.sleep(1)
assert iface.status() in\
    [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]

(C) Jiang Sheng-Jhih 2019, MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywifi-1.1.12.tar.gz (13.1 kB view hashes)

Uploaded Source

Built Distribution

pywifi-1.1.12-py3-none-any.whl (15.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page