New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Add NetworkManager:isConnected() #3593

Merged
merged 1 commit into from Jan 17, 2018

Conversation

Projects
None yet
3 participants
@Frenzie
Member

Frenzie commented Jan 11, 2018

This enables connecting to calibre and FTP without Internet connectivity.

Pinging @robert00s @mk-f

@Frenzie Frenzie added the enhancement label Jan 11, 2018

return self:isWifiOn()
else
-- `-c1` try only once; `-w2` wait 2 seconds
return os.execute("ping -c1 -w2 $(ip route | grep '^default' | awk '/eth0/ {print $3}')") == 0

This comment has been minimized.

@robert00s

robert00s Jan 13, 2018

Contributor

I'm not sure if eth0 is a good idea. On my laptop, the network card is wls3. Maybe something like that?
return os.execute("ping -c1 -w2 $(ip route | grep '^default' | awk '/default/ {print $3}')") == 0

This comment has been minimized.

@Frenzie

Frenzie Jan 13, 2018

Member

The question is more what it is on your Kindle than what it is on your laptop. :-P

But yes, my original proposal was ping -c1 -w2 $(ip route | awk '/default/ { print $3 }') which should be fine.

This comment has been minimized.

@robert00s

robert00s Jan 13, 2018

Contributor

On my Kindle is wlan0 :)

@Frenzie Frenzie force-pushed the Frenzie:is-online branch from 21380dc to 927010d Jan 13, 2018

@mk-f

This comment has been minimized.

Contributor

mk-f commented Jan 14, 2018

Uh, this is a problem on PB, because:

~ # ip
-sh: ip: not found
~ # find / -name ip
~ # 

An alternative could be:

 /sbin/route -n | awk '$4 == "UG" {print $2}'
@Frenzie

This comment has been minimized.

Member

Frenzie commented Jan 14, 2018

That would work on Kobo. Same for Kindle @robert00s ?

[feat] Add NetworkManager:isConnected()
This enables connecting to calibre and FTP without Internet connectivity.

@Frenzie Frenzie force-pushed the Frenzie:is-online branch from 927010d to c17e077 Jan 14, 2018

@robert00s

This comment has been minimized.

Contributor

robert00s commented Jan 14, 2018

Looks good.
Should work :) I don't have local FTP server so I don't test.

@Frenzie Frenzie merged commit 21274f5 into koreader:master Jan 17, 2018

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@Frenzie Frenzie deleted the Frenzie:is-online branch Jan 17, 2018

@Frenzie

This comment has been minimized.

Member

Frenzie commented Jan 17, 2018

Alright, going ahead and merging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment