wifi-station.sh

BeagleBone AI-64 (TI TDA4VM / J721E) · File : wifi-station.sh · Language : Bash · Use case : Connecter la carte au Wi-Fi en ligne de commande (NetworkManager)

NetworkManager is the standard tool of modern board distributions: two commands are enough to join a WPA2 access point and check the obtained IP. The script also lists visible networks with their security.

Hardware required

A BeagleBone AI-64 (TI J721E, 2 GHz) on the official Debian image, powered by 5 V/4 A USB-C, with its two 3.3 V P8/P9 cape headers. None: the radio is built into the board.

Wiring

No wiring. Antenna: keep the board in its case or fit the external antenna when the signal is weak.

How it works

nmcli detects the wireless interface, triggers a rescan, connects with the credentials then prints active connections and the IPv4 address. On Debian: sudo apt install gpiod python3-gpiod; gpiodetect lists the chips (main one is 600000.gpio). The P8/P9 pins are named in gpioinfo.

Going further

Create an offline profile (nmcli connection add ... wifi-sec.pri-key ...), or chain with the web server to check connectivity remotely.

wifi-station.sh

#!/bin/bash
# Connexion Wi-Fi station via nmcli (NetworkManager, standard des OS carte).
# Usage : ./wifi-station.sh "MonSSID" "cle-de-securite"

set -e
SSID="${1:?Usage: $0 SSID CLE}"
CLE="${2:?Usage: $0 SSID CLE}"

echo "== Interfaces reseau =="
ip -brief link

DEV=$(nmcli -t -f DEVICE,TYPE device | awk -F: '$2=="wifi"{print $1; exit}')
[ -n "$DEV" ] || { echo "aucune interface wifi trouvee"; exit 1; }

echo "== Scan (peut etre vide en mode AP masque) =="
sudo nmcli device wifi rescan 2>/dev/null || true
nmcli -f SSID,SIGNAL,SECURITY device wifi list | head -15

echo "== Connexion a "$SSID" via $DEV =="
nmcli device wifi connect "$SSID" password "$CLE" ifname "$DEV"

echo "== Etat =="
nmcli -f NAME,DEVICE,STATE connection show --active
ip -4 -brief addr show "$DEV"

← Back to the board