intel-ax-wifi-scan-connect-6.ino

BIOSSTAR BIWCL-PAT: 3.5" Industrial SBC with Intel Wildcat Lake · File : intel-ax-wifi-scan-connect-6.ino · Language : python · Use case : Scan et connexion Wi-Fi via le module M.2 E-Key intégré.

Python script driving Nmcli and iw to scan and connect to Wi-Fi networks via the integrated network interface.

Hardware: Wi-Fi module (Intel AX210/AX211 type) inserted into the M.2 E-Key slot of the BIWCL-PAT, antennas connected. Prerequisites: Ubuntu 24.04 with NetworkManager and iw-tools installed (sudo apt install network-manager iw). This script requires no compilation. It first lists visible SSIDs via nmcli, then connects to a network provided as arguments. Suitable for network initialization automation in edge mode.

intel-ax-wifi-scan-connect-6.ino

#!/usr/bin/env python3
import subprocess
import sys
import time

def run_cmd(cmd):
    try:
        result = subprocess.run(cmd, check=True, capture_output=True, text=True)
        return result.stdout
    except subprocess.CalledProcessError as e:
        print(f"Erreur commande {cmd}: {e.stderr}")
        sys.exit(1)

def scan_networks():
    print("Scan des réseaux Wi-Fi (biwcl e-key module)...\n")
    # iw dev <iface> scan
    # Remplacer 'wlan0' par le nom de l'interface réel (ip link show)
    output = run_cmd(["iw", "dev", "wlan0", "scan"])
    
    networks = []
    current_ssid = None
    for line in output.split('\n'):
        if 'SSID:' in line:
            current_ssid = line.split('SSID:')[1].strip()
        elif 'signal:' in line and current_ssid:
            # Format: signal: -50.00 dBm
            # Simple parsing to avoid external libs
            pass
    
    # Alternative plus robuste pour lister les SSID visibles
    print("Réseaux détectés (nom seulement) :")
    run_cmd(["nmcli", "device", "wifi", "list"])

def connect_to_wifi(ssid, password):
    print(f"Connexion à {ssid}...")
    # Utilisation de NetworkManager CLI
    cmd = ["nmcli", "device", "wifi", "connect", ssid, "password", password]
    run_cmd(cmd)
    time.sleep(2)
    print("Statut de la connexion :")
    run_cmd(["nmcli", "connection", "show", "active"])

if __name__ == "__main__":
    if len(sys.argv) < 2:
        scan_networks()
        print("\nPour se connecter : python wifi_tool.py <SSID> <MotDePasse>")
    else:
        connect_to_wifi(sys.argv[1], sys.argv[2])

← Back to the board