Skip to content

Commit

Permalink
add a crude wifi network setup tool
Browse files Browse the repository at this point in the history
  • Loading branch information
anzz1 committed May 6, 2023
1 parent b1960fe commit 21366c4
Show file tree
Hide file tree
Showing 10 changed files with 437 additions and 22 deletions.
69 changes: 47 additions & 22 deletions extras/Tools/WiFi Setup.pak/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,58 @@ cd "$DIR"

mkdir -p "$USERDATA_PATH/.wifi"

show confirm.png
if [ -f "$USERDATA_PATH/.wifi/wifi_on.txt" ]; then
WIFI_ON=1
say "WiFi: Enabled"
else
WIFI_ON=0
say "WiFi: Disabled"
CONFIRM=0
WIFI_SSID="$(keyboard "Enter WiFi network name:" 32)"

if [ $? -eq 0 ] && [ ! -z "$WIFI_SSID" ]; then
show confirm.png
say "WiFi network name set:"$'\n'"${WIFI_SSID:0:16}"$'\n'"${WIFI_SSID:17}"
if confirm; then
CONFIRM=1
fi
fi

while confirm; do
if [ $CONFIRM == 0 ]; then
show okay.png
say "WiFi network settings were not changed"$'\n'"Exiting setup ..."
sleep 3
exit 0
fi

CONFIRM=0
WIFI_PASS="$(keyboard "Enter WiFi network pass:" 63)"

if [ $? -eq 0 ]; then
show confirm.png
if [ $WIFI_ON == 1 ]; then
WIFI_ON=0
say "WiFi: Disabled"
if [ ! -z "$WIFI_PASS" ]; then
say "WiFi network password set:"$'\n'"${WIFI_PASS:0:16}"$'\n'"${WIFI_PASS:17:16}"$'\n'"${WIFI_PASS:33:16}"$'\n'"${WIFI_PASS:48}"
else
WIFI_ON=1
say "WiFi: Enabled"
say "WiFi network password set to empty"
fi
sleep 1
done

if [ -f "$USERDATA_PATH/.wifi/wifi_on.txt" ]; then
if [ $WIFI_ON == 0 ]; then
LD_PRELOAD= ./wifioff.sh > /dev/null 2>&1 &
if confirm; then
CONFIRM=1
fi
fi

if [ $CONFIRM == 0 ]; then
show okay.png
say "WiFi network settings were not changed"$'\n'"Exiting setup ..."
sleep 3
exit 0
fi

echo "ctrl_interface=/var/run/wpa_supplicant" > /appconfigs/wpa_supplicant.conf
echo "update_config=1" >> /appconfigs/wpa_supplicant.conf
echo $'\n'"network={" >> /appconfigs/wpa_supplicant.conf
echo $'\tssid="'"$WIFI_SSID"$'"' >> /appconfigs/wpa_supplicant.conf
if [ ! -z "$WIFI_PASS" ]; then
echo $'\tpsk="'"$WIFI_PASS"$'"' >> /appconfigs/wpa_supplicant.conf
else
if [ $WIFI_ON == 1 ] && [ -f /mnt/SDCARD/.system/paks/WiFi.pak/8188fu.ko ] && [ -f /appconfigs/wpa_supplicant.conf ]; then
LD_PRELOAD= ./wifion.sh > /dev/null 2>&1 &
fi
echo $'\t'"key_mgmt=NONE" >> /appconfigs/wpa_supplicant.conf
fi
echo "}" >> /appconfigs/wpa_supplicant.conf

show okay.png
say "WiFi network settings saved"$'\n'"Exiting setup ..."
sleep 3
exit 0
37 changes: 37 additions & 0 deletions extras/Tools/WiFi.pak/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

DIR=$(dirname "$0")
cd "$DIR"

mkdir -p "$USERDATA_PATH/.wifi"

show confirm.png
if [ -f "$USERDATA_PATH/.wifi/wifi_on.txt" ]; then
WIFI_ON=1
say "WiFi: Enabled"
else
WIFI_ON=0
say "WiFi: Disabled"
fi

while confirm; do
show confirm.png
if [ $WIFI_ON == 1 ]; then
WIFI_ON=0
say "WiFi: Disabled"
else
WIFI_ON=1
say "WiFi: Enabled"
fi
sleep 1
done

if [ -f "$USERDATA_PATH/.wifi/wifi_on.txt" ]; then
if [ $WIFI_ON == 0 ]; then
LD_PRELOAD= ./wifioff.sh > /dev/null 2>&1 &
fi
else
if [ $WIFI_ON == 1 ] && [ -f /mnt/SDCARD/.system/paks/WiFi.pak/8188fu.ko ] && [ -f /appconfigs/wpa_supplicant.conf ]; then
LD_PRELOAD= ./wifion.sh > /dev/null 2>&1 &
fi
fi
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ core:
cd ./src/confirm && make
cd ./src/say && make
cd ./src/blank && make
cd ./src/keyboard && make
cd ./src/oss && make

emu:
cd ./third-party/picoarch && make platform=miyoomini -j
Expand Down Expand Up @@ -105,6 +107,8 @@ payload:
cp ./src/confirm/confirm ./build/PAYLOAD/.system/bin/
cp ./src/say/say ./build/PAYLOAD/.system/bin/
cp ./src/blank/blank ./build/PAYLOAD/.system/bin/
cp ./src/keyboard/keyboard ./build/PAYLOAD/.system/bin/
cp ./src/oss/oss ./build/PAYLOAD/.system/bin/
cp ./src/say/say ./build/PAYLOAD/miyoo354/app/
cp ./src/blank/blank ./build/PAYLOAD/miyoo354/app/
cp ./third-party/picoarch/output/picoarch ./build/PAYLOAD/.system/bin/
Expand Down
Binary file added skeleton/.system/res/SpaceMono-Bold.ttf
Binary file not shown.
Loading

0 comments on commit 21366c4

Please sign in to comment.