@ -36,26 +36,30 @@ local KEY_PREV2 = 0x1c
local KEY_NEXT2 = 0x1d
local KEY_NEXT2 = 0x1d
local KEY_COVEROPEN = 0x02
local KEY_COVEROPEN = 0x02
local KEY_COVERCLOSE = 0x03
local KEY_COVERCLOSE = 0x03
local CONNECTING = 1
local CONNECTED = 2
local NET_OK = 0
-- luacheck: pop
-- luacheck: pop
ffi.cdef [ [
ffi.cdef [ [
char * GetSoftwareVersion ( void ) ;
char * GetSoftwareVersion ( void ) ;
char * GetDeviceModel ( void ) ;
char * GetDeviceModel ( void ) ;
int GetNetState ( void ) ;
int NetConnect ( const char * name ) ;
int NetDisconnect ( ) ;
] ]
] ]
local function yes ( ) return true end
local function yes ( ) return true end
local function no ( ) return false end
local function no ( ) return false end
local function pocketbookEnableWifi ( toggle )
os.execute ( " /ebrmain/bin/netagent " .. ( toggle == 1 and " connect " or " disconnect " ) )
end
local PocketBook = Generic : new {
local PocketBook = Generic : new {
model = " PocketBook " ,
model = " PocketBook " ,
isPocketBook = yes ,
isPocketBook = yes ,
isInBackGround = false ,
isInBackGround = false ,
hasOTAUpdates = yes ,
hasOTAUpdates = yes ,
hasWifiToggle = no ,
hasWifiToggle = yes ,
}
}
function PocketBook : init ( )
function PocketBook : init ( )
@ -139,12 +143,24 @@ function PocketBook:setDateTime(year, month, day, hour, min, sec)
end
end
function PocketBook : initNetworkManager ( NetworkMgr )
function PocketBook : initNetworkManager ( NetworkMgr )
NetworkMgr.turnOnWifi = function ( )
function NetworkMgr : turnOnWifi ( complete_callback )
pocketbookEnableWifi ( 1 )
if inkview.NetConnect ( nil ) ~= NET_OK then
logger.info ( ' NetConnect failed ' )
end
if complete_callback then
complete_callback ( )
end
end
function NetworkMgr : turnOffWifi ( complete_callback )
inkview.NetDisconnect ( )
if complete_callback then
complete_callback ( )
end
end
end
NetworkMgr.turnOffWifi = function ( )
function NetworkMgr : isWifiO n( )
pocketbookEnableWifi ( 0 )
return inkview.GetNetState ( ) == CONNECTED
end
end
end
end