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.
This commit is contained in:
Robert-Jan de Dreu
2022-06-25 19:58:30 +02:00
committed by GitHub
parent e4eb1c61d1
commit 040dbfe1bd

View File

@@ -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()