mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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:
committed by
GitHub
parent
e4eb1c61d1
commit
040dbfe1bd
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user