summaryrefslogtreecommitdiff
path: root/scripts/setup_wlan.sh
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2018-08-02 17:21:14 +0200
committerYves Fischer <yvesf-git@xapek.org>2018-08-02 17:59:06 +0200
commit74973624deed05d1cc8b297fb1d877cadad50969 (patch)
tree8304000f99a4dc0e0fad263fc9928d8e5ad6366c /scripts/setup_wlan.sh
downloadesp8266-master.tar.gz
esp8266-master.zip
new commit-history root - cleaned off passwordsHEADmaster
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