View Single Post
Old 08-05-2019, 05:25 PM   #3
Mavireck
Connoisseur
Mavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a Texan
 
Posts: 63
Karma: 18290
Join Date: Jul 2016
Location: France
Device: Kobo H2O (broken), Kobo H2O Edition 2 v1 (stolen), Kobo Clara 2E
I am just having the same issue, so I will use this thread instead of creating a new one ;-)

I would like to toggle Wifi on and off by executing a script for my app (a homemade dashboard launched through KFmon) for battery-saving purposes

I can easily disable Wifi with a script.
It looks like I can enable it. But it does not seem to connect to the available know wifi network. (Actually, what my log says is that the script is correctly executed, but the IP Adress remains 127.0.0.1)

I am using these scripts borrowed from koreader's sources:
wifidown.sh
Spoiler:
Code:
#! /bin/sh

lsmod | grep -q sdio_wifi_pwr || exit 1

killall udhcpc default.script wpa_supplicant 2> /dev/null

[ "$WIFI_MODULE" != 8189fs ] && [ "$WIFI_MODULE" != 8192es ] && wlarm_le -i "$INTERFACE" down
ifconfig "$INTERFACE" down

sleep 0.2
rmmod -r "$WIFI_MODULE"
rmmod -r sdio_wifi_pwr


wifiup.sh
Spoiler:
Code:
#! /bin/sh
# Load wifi modules and enable wifi.

lsmod | grep -q sdio_wifi_pwr || insmod "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko"
# Moar sleep!
usleep 250000
# WIFI_MODULE_PATH = /drivers/$PLATFORM/wifi/$WIFI_MODULE.ko
lsmod | grep -q "${WIFI_MODULE}" || insmod "${WIFI_MODULE_PATH}"
# Race-y as hell, don't try to optimize this!
sleep 1

ifconfig "${INTERFACE}" up
[ "$WIFI_MODULE" != "8189fs" ] && [ "${WIFI_MODULE}" != "8192es" ] && wlarm_le -i "${INTERFACE}" up

pidof wpa_supplicant >/dev/null \
    || env -u LD_LIBRARY_PATH \
        wpa_supplicant -D wext -s -i "${INTERFACE}" -O /var/run/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -B


I would like the wifiup.sh script to automatically connect to a wifi network, so that after its execution I can make my API calls with my app ;-)

Can anyone help me out ?

(Oh and I may have the same question with a script that would turn up and down brightness, if anyone has that, I can't find much documentation - I am new to progamming things which almost directly communicates with the hardware)
Mavireck is offline   Reply With Quote