summaryrefslogtreecommitdiff
path: root/scripts/setup_wlan.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/setup_wlan.sh')
-rwxr-xr-xscripts/setup_wlan.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/setup_wlan.sh b/scripts/setup_wlan.sh
new file mode 100755
index 0000000..8621bf0
--- /dev/null
+++ b/scripts/setup_wlan.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+set -x
+PORT=$1
+CONFIGFILE=$2
+
+HOST=$(python3 ../scripts/read_config.py CONFIG_DHCP_HOSTNAME)
+SSID=$(python3 ../scripts/read_config.py CONFIG_WPA_SSID)
+PASS=$(python3 ../scripts/read_config.py CONFIG_WPA_KEYPHRASE)
+
+cat $PORT &
+PRINTER_PID=$!
+
+# interrupt
+echo -e -n "\003" >$PORT
+
+# Enter RAW Repl
+echo -e -n "\001" >$PORT
+
+echo -e -n "import network\004" >$PORT
+echo -e -n "wlan = network.WLAN(network.STA_IF)\004" >$PORT
+echo -e -n "wlan.active(True)\004" >$PORT
+echo -e -n "wlan.config(dhcp_hostname='$HOST')\004" >$PORT
+echo -e -n "wlan.connect('$SSID', '$PASS')\004" >$PORT
+echo -e -n "ap = network.WLAN(network.AP_IF)\004" >$PORT
+echo -e -n "ap.active(False)\004" >$PORT
+echo -e -n "\002" >$PORT
+
+sleep 3
+
+kill $PRINTER_PID