PocketBook: Check NET_CONNECTED to see if wifi is really connected (#8730)

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.
pull/8756/head
Robert-Jan de Dreu 2 years ago committed by GitHub
parent 4f707bb49d
commit e8fa5bdedd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

Loading…
Cancel
Save