wifi-station.sh

BeaglePlay (TI Sitara AM6254 / AM625) · 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 BeaglePlay (TI AM625) on the official Debian image, powered by 5 V/3 A USB-C, with its mikroBUS socket, Grove connector and five user LEDs. 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: the five user LEDs (USR0-4) are driven by gpio-leds with triggers (heartbeat, disk…); for raw I/O use libgpiod (gpiochip0) on a free mikroBUS line.

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