Pocketbook: Keep wifi alive as long as wifi is enabled (#9208)

Schedule wifi keep-alive on wifi start but do not reschedule when
connection is lost. This will make sure this code is not run when
wifi is disabled again saving some battery and cpu cycles.
pull/9255/head
Robert-Jan de Dreu 2 years ago committed by GitHub
parent e4eb1c61d1
commit 040dbfe1bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -334,10 +334,28 @@ function PocketBook:reboot()
end
function PocketBook:initNetworkManager(NetworkMgr)
local UIManager = require("ui/uimanager")
local function keepWifiAlive()
-- Make sure only one wifiKeepAlive is scheduled
UIManager:unschedule(keepWifiAlive)
if NetworkMgr:isWifiOn() then
logger.dbg("ping wifi keep alive and reschedule")
inkview.NetMgrPing()
UIManager:scheduleIn(30, keepWifiAlive)
else
logger.dbg("wifi is disabled do not reschedule")
end
end
function NetworkMgr:turnOnWifi(complete_callback)
inkview.WiFiPower(1)
if inkview.NetConnect(nil) ~= C.NET_OK then
logger.info('NetConnect failed')
if inkview.NetConnect(nil) == C.NET_OK then
keepWifiAlive()
else
logger.info("NetConnect failed")
end
if complete_callback then
complete_callback()

Loading…
Cancel
Save