![]() |
#16 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 242
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
|
Maybe something like this?
https://unix.stackexchange.com/quest...ation-on-linux Edit: a couple of Kobo example projects: https://www.mobileread.com/forums/sh...d.php?t=332127 https://www.mobileread.com/forums/sh...d.php?t=355368 But it would be much less work to get the startup script working. You will have to run some tests or find an alternate way of running startup scripts. Only YOU can do this, so if that's more work than you expected, well, that's not uncommon for these quirky devices... Last edited by elinkser; 12-05-2024 at 10:13 AM. Reason: examples |
![]() |
![]() |
![]() |
#17 |
Member
![]() Posts: 10
Karma: 10
Join Date: Nov 2024
Device: Kobo Touch
|
To whom it may concern: I tried a lot and it seems, that the Kobo has problems with its "sleep" function (does not wake up until manually hitting the home button), so I created a delay_function simply by counting. Just to be sure, I encapsulate the other functions by a timeout.
Wifi is lost 10-30 times a day, but the current script detects a missing Wifi connection and tries to reconnect. So far, it has been running for the last 3 days without major issues (so still not perfectly tested, but looks quite promising so far) Code:
# network details LOG_FILE="/wifijob.log" log_message() { local MESSAGE="$@" echo "$(date +"%Y-%m-%d %H:%M:%S") : $MESSAGE" >> "$LOG_FILE" } INTERFACE="wlan0" WIFI_SSID="MYWIFI" WIFI_PASSWORD="MYWIFIPASSWORD" # The IP address to ping HOST="192.168.0.1" delay_function() { local count=0 local delay=$1 # Number of seconds to wait local start_time=$(date +%s) while [ $(( $(date +%s) - start_time )) -lt $delay ]; do count=$((count + 1)) done echo "Waited for $delay seconds by counting to $count." } # Function to reconnect to Wi-Fi reconnect_wifi() { log_message " ################# Host is not reachable. Reconnecting to WiFi" timeout 2 echo " ################# Host $HOST is not reachable. Reconnecting to Wi-Fi..." timeout 60 ifconfig $INTERFACE down log_message "Ifconfig down. Now sleep for 10s" timeout 2 echo "Ifconfig down. Now sleep for 10s" delay_function 10; timeout 60 ifconfig $INTERFACE up log_message "Ifconfig up. Now sleep for 10s" timeout 2 echo "Ifconfig up. Now sleep for 10s" delay_function 10; timeout 60 wpa_cli reassociate log_message "Wifi hopefully reassociated. Sleep for 30s, check ping and re-enter loop." timeout 2 echo "Wifi hopefully reassociated. Sleep for 30s, check ping and re-enter loop" status=$(wpa_cli status) timeout 2 echo "Current Wi-Fi status: $status" log_message "Current Wi-Fi status: $status" delay_function 30; timeout 60 wpa_cli reconfigure log_message "Wifi hopefully reconfigured. Sleep for 30s, check ping and re-enter loop." timeout 2 echo "Wifi hopefully reconfigured. Sleep for 30s, check ping and re-enter loop" status=$(wpa_cli status) timeout 2 echo "Current Wi-Fi status: $status" log_message "Current Wi-Fi status: $status" delay_function 30; timeout 10 ping -c 1 $HOST > /dev/null 2>&1 # Check and log the ping result if [ $? -ne 0 ]; then log_message "Ping is still negative :( Now trying to reconnect." timeout 2 echo "Ping is still negative :( Now trying to reconnect." timeout 60 wpa_cli disconnect # Remove all known networks delay_function 5; ##timeout 60 wpa_cli remove_network all ##timeout 60 wpa_cli save_config networks=$(wpa_cli list_networks | grep -v "network id" | wc -l) if [ "$networks" -eq 0 ]; then timeout 2 echo "No known networks found. Adding new network..." log_message "No known networks found. Adding new network..." NETWORK_ID=$(wpa_cli add_network) timeout 60 wpa_cli set_network $NETWORK_ID ssid "\"$WIFI_SSID\"" timeout 60 wpa_cli set_network $NETWORK_ID psk "\"$WIFI_PASSWORD\"" timeout 60 wpa_cli enable_network $NETWORK_ID timeout 60 wpa_cli save_config timeout 2 echo "Network added with SSID: $WIFI_SSID" log_message "Network added with SSID: $WIFI_SSID" else timeout 2 echo "Known networks already configured. No action needed." log_message "Known networks already configured. No action needed." fi # Reconnect to the new network timeout 60 wpa_cli reconnect log_message "Wifi hopefully reconnected. Sleep for 30s, check ping and re-enter loop." timeout 2 echo "Wifi hopefully reconnected. Sleep for 30s, check ping and re-enter loop" delay_function 30; status=$(wpa_cli status) timeout 2 echo "Current Wi-Fi status: $status" log_message "Current Wi-Fi status: $status" fi } while true; do # Ping the host timeout 10 ping -c 1 $HOST > /dev/null 2>&1 # Check the ping result if [ $? -ne 0 ]; then reconnect_wifi else timeout 2 echo "Host $HOST is reachable." #log_message "Host $HOST is reachable." fi delay_function 10 done |
![]() |
![]() |
Advert | |
|
![]() |
#18 | ||||||
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 242
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
|
In case the subject comes up again, just a few possibly helpful quotes...
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
||||||
![]() |
![]() |
![]() |
Tags |
browser, kobo-touch, wifi |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Troubleshooting battery, Wifi, and display issues | PaulB223 | Amazon Kindle | 0 | 08-17-2022 10:41 AM |
Diagnosing Kobo touch issues [non-responsive to touch] | emacsomancer | Kobo Reader | 4 | 02-21-2021 10:12 AM |
Kobo wifi PNG display | AMB-ereader | Kobo Developer's Corner | 10 | 03-21-2016 07:56 PM |
Kobo touch WIFI permanent aktivieren | koboman | Andere Lesegeräte | 0 | 09-08-2012 05:51 AM |
Touch - Cover display issues resolved at last | Hoods7070 | Kobo Reader | 0 | 05-20-2012 06:26 AM |