mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Wifi toggle for reMarkable 2 (#7122)
reMarkable 1 is no-op for the moment
This commit is contained in:
@@ -130,6 +130,32 @@ end
|
||||
|
||||
function Remarkable:supportsScreensaver() return true end
|
||||
|
||||
function Remarkable:initNetworkManager(NetworkMgr)
|
||||
function NetworkMgr:turnOnWifi(complete_callback)
|
||||
os.execute("./enable-wifi.sh")
|
||||
self:reconnectOrShowNetworkMenu(function()
|
||||
self:connectivityCheck(1, complete_callback)
|
||||
end)
|
||||
end
|
||||
|
||||
function NetworkMgr:turnOffWifi(complete_callback)
|
||||
os.execute("./disable-wifi.sh")
|
||||
if complete_callback then
|
||||
complete_callback()
|
||||
end
|
||||
end
|
||||
|
||||
function NetworkMgr:getNetworkInterfaceName()
|
||||
return "wlan0"
|
||||
end
|
||||
|
||||
NetworkMgr:setWirelessBackend("wpa_supplicant", {ctrl_interface = "/var/run/wpa_supplicant/wlan0"})
|
||||
|
||||
NetworkMgr.isWifiOn = function()
|
||||
return NetworkMgr:isConnected()
|
||||
end
|
||||
end
|
||||
|
||||
function Remarkable:setDateTime(year, month, day, hour, min, sec)
|
||||
if hour == nil or min == nil then return true end
|
||||
local command
|
||||
@@ -146,6 +172,9 @@ function Remarkable1:suspend()
|
||||
end
|
||||
|
||||
function Remarkable2:suspend()
|
||||
-- Need to remove brcmfmac kernel module before suspend. Otherwise the module crashes on wakeup
|
||||
os.execute("./disable-wifi.sh")
|
||||
|
||||
os.execute("systemctl suspend")
|
||||
-- While device is suspended, when the user presses the power button and wakes up the device,
|
||||
-- a "Power" event is NOT sent.
|
||||
|
||||
18
platform/remarkable/disable-wifi.sh
Executable file
18
platform/remarkable/disable-wifi.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# disable wifi and remove modules
|
||||
|
||||
read -r MACHINE_TYPE <"/sys/devices/soc0/machine"
|
||||
|
||||
if [ "reMarkable 2.0" = "${MACHINE_TYPE}" ]; then
|
||||
# clean stop (if it's running) of main wpa_supplicant service, used by xochitl
|
||||
systemctl stop wpa_supplicant
|
||||
# clean stop of non-service wpa_supplicant, if running
|
||||
wpa_cli terminate 2>/dev/null
|
||||
|
||||
# power down wifi interface
|
||||
ifconfig wlan0 down 2>/dev/null
|
||||
|
||||
# remove module: IMPORTANT to do this before device suspends
|
||||
modprobe -r brcmfmac 2>/dev/null
|
||||
fi
|
||||
20
platform/remarkable/enable-wifi.sh
Executable file
20
platform/remarkable/enable-wifi.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
read -r MACHINE_TYPE <"/sys/devices/soc0/machine"
|
||||
|
||||
if [ "reMarkable 2.0" = "${MACHINE_TYPE}" ]; then
|
||||
if lsmod | grep -q brcmfmac; then
|
||||
ifconfig wlan0 up
|
||||
else
|
||||
modprobe brcmfmac
|
||||
fi
|
||||
|
||||
# clean stop (if it's running) of main wpa_supplicant service, used by xochitl
|
||||
systemctl stop wpa_supplicant
|
||||
# clean stop of non-service wpa_supplicant, if running
|
||||
wpa_cli terminate 2>/dev/null
|
||||
|
||||
sleep 1
|
||||
|
||||
wpa_supplicant -i wlan0 -C /var/run/wpa_supplicant -B 2>/dev/null
|
||||
fi
|
||||
Reference in New Issue
Block a user