Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 07-27-2019, 02:46 PM   #1
kanataa
Junior Member
kanataa began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jul 2019
Device: KOBO Glo HD
Enable Wifi by script?

Dear community

I've a Kobo Glo HD with XCsoar (https://xcsoar.org/) installed, everything works fine and it's overall a great device.

Unfortunately, since a few weeks ago, the upper part of my display (~1 inch) isn't working anymore. (Doesn't react on touch inputs).
Because of this, I'm no longer able to switch on and off the Wi-Fi.

Is there a possibility to activate / deactivate the Wi-Fi by script?
kanataa is offline   Reply With Quote
Old 07-27-2019, 08:16 PM   #2
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,477
Karma: 26012494
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
On a stock Kobo, sure (although it's not necessarily entirely trivial).

In XCSoar though, you'd have to ask the XCSoar guys.
NiLuJe is offline   Reply With Quote
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
Old 08-05-2019, 05:55 PM   #4
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,477
Karma: 26012494
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
You're missing the bits from acquire-ip.sh (i.e., dhcp).

FL control is via ioctl (except on Mk. 7 when there's also a sysfs entry), so, that'd need a C helper if you want to cover all current devices.
NiLuJe is offline   Reply With Quote
Old 08-06-2019, 06:53 AM   #5
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
Quote:
Originally Posted by NiLuJe View Post
FL control is via ioctl (except on Mk. 7 when there's also a sysfs entry), so, that'd need a C helper if you want to cover all current devices.
Yes thank you for your help, it is now working well on my H20 (mark5 - I am not going to try to make it work on a mark7 for now)

As for wifi. Disabling seems to work, but connecting to the network doesn't:
I copied the whole sources from koreader in a folder called 'files' in my app.
It is coded in Python (of course). After a click on a button, it launches a function which among other things, executes these lines of code:
Code:
os.system("sh ./files/enable-wifi.sh")
time.sleep(5)
os.system("sh ./files/obtain-ip.sh")
print("Wifi enabled")
But it still does not connect to the wifi network (IP remains local), while it does connect with Nickel.
Am I missing something ?

I also have another unexpected issue : the "Wifi enabled" message is being printed multiple times... Can it be due to the problem I am having (or cause it?). I really don't know why it would be executed multiple times in my code.

Thank you for your help !
Mavireck is offline   Reply With Quote
Old 08-07-2019, 04:48 AM   #6
sherman
Guru
sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.
 
Posts: 856
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
Quote:
Originally Posted by Mavireck View Post
Yes thank you for your help, it is now working well on my H20 (mark5 - I am not going to try to make it work on a mark7 for now)

As for wifi. Disabling seems to work, but connecting to the network doesn't:
I copied the whole sources from koreader in a folder called 'files' in my app.
It is coded in Python (of course). After a click on a button, it launches a function which among other things, executes these lines of code:
Code:
os.system("sh ./files/enable-wifi.sh")
time.sleep(5)
os.system("sh ./files/obtain-ip.sh")
print("Wifi enabled")
But it still does not connect to the wifi network (IP remains local), while it does connect with Nickel.
Am I missing something ?

I also have another unexpected issue : the "Wifi enabled" message is being printed multiple times... Can it be due to the problem I am having (or cause it?). I really don't know why it would be executed multiple times in my code.

Thank you for your help !
enable-wifi.sh doesn't include the required Nickel environment variables. You want to look at lines 93-94 from koreader.sh. They are the lines that read:
Code:
eval "$(xargs -n 1 -0 <"/proc/$(pidof nickel)/environ" | grep -e DBUS_SESSION_BUS_ADDRESS -e NICKEL_HOME -e WIFI_MODULE -e LANG -e WIFI_MODULE_PATH -e INTERFACE 2>/dev/null)"
    export DBUS_SESSION_BUS_ADDRESS NICKEL_HOME WIFI_MODULE LANG WIFI_MODULE_PATH INTERFACE
You may like to also look at the shell scripts from my Kobo UNCaGED, project, more specifically scripts/nickel-usbms.sh, lines 69-71.

Note, the Wifi stuff in that file may look a little familiar. I took a lot of "inspiration" from koreader for the Wifi stuff.
sherman is offline   Reply With Quote
Old 08-07-2019, 10:10 AM   #7
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
Quote:
Originally Posted by sherman View Post
Spoiler:

enable-wifi.sh doesn't include the required Nickel environment variables. You want to look at lines 93-94 from koreader.sh. They are the lines that read:
Code:
eval "$(xargs -n 1 -0 <"/proc/$(pidof nickel)/environ" | grep -e DBUS_SESSION_BUS_ADDRESS -e NICKEL_HOME -e WIFI_MODULE -e LANG -e WIFI_MODULE_PATH -e INTERFACE 2>/dev/null)"
    export DBUS_SESSION_BUS_ADDRESS NICKEL_HOME WIFI_MODULE LANG WIFI_MODULE_PATH INTERFACE
You may like to also look at the shell scripts from my Kobo UNCaGED, project, more specifically scripts/nickel-usbms.sh, lines 69-71.

Note, the Wifi stuff in that file may look a little familiar. I took a lot of "inspiration" from koreader for the Wifi stuff.
Thank you so much ! My problem is solved !
I did absolutely not know of the details of exported variables within bash scripts. My initialization script did not export all the variables required (it did not export WIFI_MODULE_PATH for instance).
I still had some issues, until I found that the $PLATFORM variable was not defined. For now I hardcoded the path to the wifi driver:
Code:
lsmod | grep -q sdio_wifi_pwr || insmod "/drivers/mx50-ntx/wifi/sdio_wifi_pwr.ko"
instead of :
Code:
lsmod | grep -q sdio_wifi_pwr || insmod "/drivers/${PLATFORM}/wifi/sdio_wifi_pwr.ko"
That is enough to make it work on my device ! I will further investigate about that platform variable issue, but that is already a great step forward!
Mavireck is offline   Reply With Quote
Reply

Tags
script, wi-fi


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Koreader WIFI enable after start: Possible? anki KOReader 5 09-07-2017 10:12 AM
Kindle Touch 5.1.0, How to turn on/off wifi in a script? wisecrick Kindle Developer's Corner 3 12-08-2013 05:31 AM
Kindle 3: run script when turning wifi on? theblop Kindle Developer's Corner 1 11-09-2010 10:25 AM
Request Enable access to adhoc wifi networks devseev enTourage Archive 7 11-05-2010 11:01 AM
run script on wifi connect sinisterguy Kindle Developer's Corner 1 10-18-2010 03:46 PM


All times are GMT -4. The time now is 12:48 PM.


MobileRead.com is a privately owned, operated and funded community.