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 12-04-2024, 10:10 AM   #16
elinkser
Addict
elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.
 
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
elinkser is offline   Reply With Quote
Old 12-16-2024, 02:09 PM   #17
kobotouch2711
Member
kobotouch2711 began at the beginning.
 
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
kobotouch2711 is offline   Reply With Quote
Advert
Old 12-17-2024, 07:15 AM   #18
elinkser
Addict
elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.
 
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:
The debug services also enables a telnet service. This tends to block the WiFi from turning off and the device from automatically sleeping. And that runs the battery down a lot faster.
https://www.mobileread.com/forums/sh...1&postcount=27


Quote:
(You can't suspend (any?) NTX boards with Wi-Fi on (or even just *powered* on): it hangs the kernel, either right away, or on resume/next wifi bringup).
https://www.mobileread.com/forums/sh...2&postcount=88


Quote:
For the Qt resources, I don't bother getting them myself. In the kobo-patches repository, geek1011 extracts them on every firmware issue. Just find the issue for the latest firmware and look for the comment that includes them.
https://www.mobileread.com/forums/sh...4&postcount=34


Quote:
It doesn't help that the branches aren't ABI-compatible, that some are qt6, and that I don't have any devices capable of testing anything other than 4.38.x (which means I either have to do everything statically, or I have to put in the time and effort to backport or emulate the newer branches -- which is possible, but yet another hurdle to overcome before I can get to the fun stuff).
https://www.mobileread.com/forums/sh...85&postcount=8


Quote:
Actually, the /mnt/onboard mount
happens only after udev is started, so it's entirely possible it won't be mounted yet...
So if you execute a script on /mnt/onboard/ there might be a possibility it won't run.
https://www.mobileread.com/forums/sh...88&postcount=8


Quote:
The difference between restarting only Nickel and restarting the whole device does seem to be up to about 8 seconds btw, so clearly I was wrong about it not making that
much difference (and/or it differs per device).
https://www.mobileread.com/forums/sh...postcount=1196
elinkser is offline   Reply With Quote
Reply

Tags
browser, kobo-touch, wifi


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 08:15 PM.


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