pascalw / kindle-dash

Power efficient dashboard for Kindle 4 NT devices
MIT License
1.21k stars 34 forks source link

wait-for-wifi.sh not working reliably when called from dash.sh #6

Closed chrisvanpatten closed 3 years ago

chrisvanpatten commented 3 years ago

First of all, thanks for this cool utility! I've had a lot of fun setting it up and playing around with the possibilities.

I'm using a Kindle Keyboard 3G (k3g, US model) and I noticed some strange behavior around the wait-for-wifi.sh script. For some reason, only when called in the context of dash.sh, it hangs and never makes it to the point of downloading the dashboard.

It seems like something is funky in the while statement in wait-for-wifi.sh. I tossed in some debug statements:

  ping -c 1 $WIFI_TEST_IP >/dev/null 2>&1
  while [ $? -ne 0 ]; do
    echo $?

...

    echo "Trying again"
    sleep 1
    /bin/ping -c 1 $WIFI_TEST_IP >/dev/null 2>&1
  done

But when I tail the logs, I see this:

[root@kindle dashboard]# tail -f logs/dash.log
Starting dashboard with 0 2,32 9-19 * * * refresh...
system: I framework:def:stopping booklet framework
Sun Jan 31 15:44:57 2021  INFO:battery charge: 91%
Sun Jan 31 15:44:57 EST 2021 Battery level: 91%.
Refreshing dashboard
0
Trying again
0
Trying again

What's really strange here is that calling the script directly yields no issues:

[root@kindle dashboard]# ./wait-for-wifi.sh
./wait-for-wifi.sh
Wi-Fi connected

For now I'm working around this by just stopping wait-for-wifi.sh from being called inside dash.sh which is totally fine, but I'd be curious if you have any ideas of what might be going on.

Thanks!

julianlam commented 3 years ago

Oh interesting... I also ran into something similar. In fact, I was just here to open a similar issue.

In my case, I have a Ubiquiti router which uses a self-signed cert. I think perhaps that's why? I changed the IP address wait-for-wifi.sh checks to 1.1.1.1 and it worked okay.

Caveat: I don't know if this was the cause, it just happened to be the one variable I changed and when I ran dash.sh, it correctly loaded the test image.

chrisvanpatten commented 3 years ago

@julianlam I also had an issue with the default IP; I just changed that to a different local IP on my network and it worked fine when called directly.

Still not sure why this while loop is failing, but definitely a good first debugging step for others to try swapping in a different IP before digging further!

chrisvanpatten commented 3 years ago

And I'm an idiot — of course it works when called directly; I only updated the default value in wait-for-wifi.sh, not the main environment script! Thanks for letting me rubber duck this here.

julianlam commented 3 years ago

Well, while we're here -- perhaps the default IP should be changed to something external (say, 1.1.1.1 again)?

pascalw commented 3 years ago

Hey sorry about that, the current default indeed is not very reliable across different network setups. I'll change the default to 1.1.1.1.

pascalw commented 3 years ago

This is now fixed on the main branch.