From e8fa5bdeddbdada8083f8aa11a50fa5d18642efb Mon Sep 17 00:00:00 2001 From: Robert-Jan de Dreu Date: Sat, 29 Jan 2022 19:58:28 +0000 Subject: [PATCH] PocketBook: Check NET_CONNECTED to see if wifi is really connected (#8730) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I've emailed with PocketBook about the problem with Wifi on the newer models. They explained the wrong constant was being used: > Dear Robert, > > Thank you for choosing Pocketbook. ​ > Wi-Fi Connection" enabled when no connection: > https://github.com/koreader/koreader/issues/8617 > The problem is in incorrect usage of constant. You should use flag NET_CONNECTED with bit AND operation as shown in example below. > > function NetworkMgr:isWifiOn() > local state = inkview.QueryNetwork() > return band(state, C.NET_CONNECTED) ~= 0 > end > > Inkpad3 Wifi Standby > https://github.com/koreader/koreader/issues/4747 > the same solution for this issue Related issues: https://github.com/koreader/koreader/issues/8617 https://github.com/koreader/koreader/issues/4747 Since I made the previous hack and their suggestion seems to work on the PB741 color. I've made this PR to remove my hack. It might be wise to also test this fix on older models. --- frontend/device/pocketbook/device.lua | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/frontend/device/pocketbook/device.lua b/frontend/device/pocketbook/device.lua index 1494e5ed9..f7e142fba 100644 --- a/frontend/device/pocketbook/device.lua +++ b/frontend/device/pocketbook/device.lua @@ -359,15 +359,7 @@ function PocketBook:initNetworkManager(NetworkMgr) end function NetworkMgr:isWifiOn() - local state = inkview.QueryNetwork() - -- Some devices (PB741) return state = 515 for connected and state = 3 - -- when not connected. We guess the reason is deprecation of the old API - -- for this reason when state is higher than C.CONNECTED we try the new API - if state <= C.CONNECTED then - return band(state, C.CONNECTED) ~= 0 - else - return band(inkview.GetNetState(), C.CONNECTED) ~= 0 - end + return band(inkview.QueryNetwork(), C.NET_CONNECTED) ~= 0 end end