Remarkable1 wifi (#7216)

* add wifi support to Rm1
* remarkable: common suspend for all models
reviewable/pr7235/r1
Martín Fernández 3 years ago committed by GitHub
parent 68a5fcdbc1
commit 4a89c93290
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,6 +5,17 @@ local logger = require("logger")
local function yes() return true end local function yes() return true end
local function no() return false end local function no() return false end
-- returns isRm2, device_model
local function getModel()
local f = io.open("/sys/devices/soc0/machine")
if not f then
error("missing sysfs entry for a remarkable")
end
local model = f:read("*line")
f:close()
return model == "reMarkable 2.0", model
end
local EV_ABS = 3 local EV_ABS = 3
local ABS_X = 00 local ABS_X = 00
local ABS_Y = 01 local ABS_Y = 01
@ -17,9 +28,11 @@ local wacom_width = 15725 -- unscaled_size_check: ignore
local wacom_height = 20967 -- unscaled_size_check: ignore local wacom_height = 20967 -- unscaled_size_check: ignore
local wacom_scale_x = screen_width / wacom_width local wacom_scale_x = screen_width / wacom_width
local wacom_scale_y = screen_height / wacom_height local wacom_scale_y = screen_height / wacom_height
local isRm2, rm_model = getModel()
local Remarkable = Generic:new{ local Remarkable = Generic:new{
isRemarkable = yes, isRemarkable = yes,
model = rm_model,
hasKeys = yes, hasKeys = yes,
needsScreenRefreshAfterResume = no, needsScreenRefreshAfterResume = no,
hasOTAUpdates = yes, hasOTAUpdates = yes,
@ -34,7 +47,6 @@ local Remarkable = Generic:new{
} }
local Remarkable1 = Remarkable:new{ local Remarkable1 = Remarkable:new{
model = "reMarkable",
mt_width = 767, -- unscaled_size_check: ignore mt_width = 767, -- unscaled_size_check: ignore
mt_height = 1023, -- unscaled_size_check: ignore mt_height = 1023, -- unscaled_size_check: ignore
input_wacom = "/dev/input/event0", input_wacom = "/dev/input/event0",
@ -59,7 +71,6 @@ function Remarkable1:adjustTouchEvent(ev, by)
end end
local Remarkable2 = Remarkable:new{ local Remarkable2 = Remarkable:new{
model = "reMarkable 2",
mt_width = 1403, -- unscaled_size_check: ignore mt_width = 1403, -- unscaled_size_check: ignore
mt_height = 1871, -- unscaled_size_check: ignore mt_height = 1871, -- unscaled_size_check: ignore
input_wacom = "/dev/input/event1", input_wacom = "/dev/input/event1",
@ -167,26 +178,22 @@ function Remarkable:setDateTime(year, month, day, hour, min, sec)
return os.execute(command) == 0 return os.execute(command) == 0
end end
function Remarkable1:suspend() function Remarkable:resume()
os.execute("systemctl suspend")
end end
function Remarkable2:suspend() function Remarkable:suspend()
-- Need to remove brcmfmac kernel module before suspend. Otherwise the module crashes on wakeup
os.execute("./disable-wifi.sh") os.execute("./disable-wifi.sh")
os.execute("systemctl suspend") os.execute("systemctl suspend")
-- While device is suspended, when the user presses the power button and wakes up the device, if isRm2 then
-- a "Power" event is NOT sent. -- While device is suspended, when the user presses the power button and wakes up the device,
-- So we schedule a manual `UIManager:resume` call just far enough in the future that it won't -- a "Power" event is NOT sent.
-- trigger before the `systemctl suspend` command finishes suspending the device -- So we schedule a manual `UIManager:resume` call just far enough in the future that it won't
local UIManager = require("ui/uimanager") -- trigger before the `systemctl suspend` command finishes suspending the device
UIManager:scheduleIn(0.5, function() local UIManager = require("ui/uimanager")
UIManager:resume() UIManager:scheduleIn(0.5, function()
end) UIManager:resume()
end end)
end
function Remarkable:resume()
end end
function Remarkable:powerOff() function Remarkable:powerOff()
@ -199,19 +206,12 @@ function Remarkable:reboot()
os.execute("systemctl reboot") os.execute("systemctl reboot")
end end
local f = io.open("/sys/devices/soc0/machine") logger.info(string.format("Starting %s", rm_model))
if not f then error("missing sysfs entry for a remarkable") end
local deviceType = f:read("*line") if isRm2 then
f:close()
logger.info("deviceType: ", deviceType)
if deviceType == "reMarkable 2.0" then
if not os.getenv("RM2FB_SHIM") then if not os.getenv("RM2FB_SHIM") then
error("reMarkable2 requires RM2FB to work (https://github.com/ddvk/remarkable2-framebuffer)") error("reMarkable2 requires RM2FB to work (https://github.com/ddvk/remarkable2-framebuffer)")
end end
return Remarkable2 return Remarkable2
else else
return Remarkable1 return Remarkable1

@ -2,17 +2,13 @@
# disable wifi and remove modules # disable wifi and remove modules
read -r MACHINE_TYPE <"/sys/devices/soc0/machine" # 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
if [ "reMarkable 2.0" = "${MACHINE_TYPE}" ]; then # power down wifi interface
# clean stop (if it's running) of main wpa_supplicant service, used by xochitl ifconfig wlan0 down 2>/dev/null
systemctl stop wpa_supplicant
# clean stop of non-service wpa_supplicant, if running
wpa_cli terminate 2>/dev/null
# power down wifi interface # remove module
ifconfig wlan0 down 2>/dev/null modprobe -r brcmfmac 2>/dev/null
# remove module: IMPORTANT to do this before device suspends
modprobe -r brcmfmac 2>/dev/null
fi

@ -1,20 +1,19 @@
#!/bin/sh #!/bin/sh
read -r MACHINE_TYPE <"/sys/devices/soc0/machine" read -r MACHINE_TYPE <"/sys/devices/soc0/machine"
if [ "reMarkable 2.0" = "${MACHINE_TYPE}" ]; then if [ "reMarkable 2.0" = "${MACHINE_TYPE}" ]; then
if lsmod | grep -q brcmfmac; then if ! lsmod | grep -q brcmfmac; then
ifconfig wlan0 up
else
modprobe brcmfmac modprobe brcmfmac
fi fi
fi
# clean stop (if it's running) of main wpa_supplicant service, used by xochitl # clean stop (if it's running) of main wpa_supplicant service, used by xochitl
systemctl stop wpa_supplicant systemctl stop wpa_supplicant
# clean stop of non-service wpa_supplicant, if running
wpa_cli terminate 2>/dev/null
sleep 1 # clean stop of non-service wpa_supplicant, if running
wpa_cli terminate 2>/dev/null
wpa_supplicant -i wlan0 -C /var/run/wpa_supplicant -B 2>/dev/null sleep 1
fi
ifconfig wlan0 up
wpa_supplicant -i wlan0 -C /var/run/wpa_supplicant -B 2>/dev/null

Loading…
Cancel
Save