Created
April 3, 2016 21:45
-
-
Save artizirk/cd3980c8ff870eb0bfce68bc26a2676b to your computer and use it in GitHub Desktop.
A small example of connecting to wpa_supplicant daemon control socket that is also used by wpa_cli with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import select | |
import socket | |
interface = "wlan1" | |
wpa_send_path = "/run/wpa_supplicant/"+interface | |
wpa_recv_path = "/tmp/wpa_ctrl_{pid}-{count}".format(pid=os.getpid(), count=1) | |
soc = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM, 0) | |
soc.bind(wpa_recv_path) | |
soc.connect(wpa_send_path) | |
print("> PING") | |
soc.send(b"PING") | |
print("<", soc.recv(4096).decode().strip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment