2014-10-30 18:42:18 +00:00
|
|
|
local Generic = require("device/generic/device")
|
|
|
|
local Geom = require("ui/geometry")
|
2019-09-12 12:15:08 +00:00
|
|
|
local WakeupMgr = require("device/wakeupmgr")
|
|
|
|
local logger = require("logger")
|
2016-12-29 08:10:38 +00:00
|
|
|
local util = require("ffi/util")
|
2016-06-26 00:53:08 +00:00
|
|
|
local _ = require("gettext")
|
2014-10-30 18:42:18 +00:00
|
|
|
|
|
|
|
local function yes() return true end
|
2018-02-04 11:32:51 +00:00
|
|
|
local function no() return false end
|
2014-10-30 18:42:18 +00:00
|
|
|
|
2016-06-12 18:50:30 +00:00
|
|
|
local function koboEnableWifi(toggle)
|
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
|
|
|
if toggle == true then
|
|
|
|
logger.info("Kobo Wi-Fi: enabling Wi-Fi")
|
2016-09-01 07:05:40 +00:00
|
|
|
os.execute("./enable-wifi.sh")
|
2016-06-12 18:50:30 +00:00
|
|
|
else
|
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
|
|
|
logger.info("Kobo Wi-Fi: disabling Wi-Fi")
|
2016-09-01 07:05:40 +00:00
|
|
|
os.execute("./disable-wifi.sh")
|
2016-06-12 18:50:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-10-30 18:42:18 +00:00
|
|
|
local Kobo = Generic:new{
|
|
|
|
model = "Kobo",
|
|
|
|
isKobo = yes,
|
|
|
|
isTouchDevice = yes, -- all of them are
|
2018-10-06 05:55:35 +00:00
|
|
|
hasOTAUpdates = yes,
|
2020-09-28 23:06:41 +00:00
|
|
|
hasFastWifiStatusQuery = yes,
|
2019-02-06 14:51:50 +00:00
|
|
|
hasWifiManager = yes,
|
2019-08-15 12:49:15 +00:00
|
|
|
canReboot = yes,
|
|
|
|
canPowerOff = yes,
|
2014-10-30 18:42:18 +00:00
|
|
|
|
|
|
|
-- most Kobos have X/Y switched for the touch screen
|
|
|
|
touch_switch_xy = true,
|
|
|
|
-- most Kobos have also mirrored X coordinates
|
|
|
|
touch_mirrored_x = true,
|
2019-01-13 23:49:29 +00:00
|
|
|
-- enforce portrait mode on Kobos
|
2019-09-22 00:22:22 +00:00
|
|
|
--- @note: In practice, the check that is used for in ffi/framebuffer is no longer relevant,
|
|
|
|
--- since, in almost every case, we enforce a hardware Portrait rotation via fbdepth on startup by default ;).
|
|
|
|
--- We still want to keep it in case an unfortunate soul on an older device disables the bitdepth switch...
|
2014-11-27 15:33:48 +00:00
|
|
|
isAlwaysPortrait = yes,
|
Enable HW dithering in a few key places (#4541)
* Enable HW dithering on supported devices (Clara HD, Forma; Oasis 2, PW4)
* FileManager and co. (where appropriate, i.e., when covers are shown)
* Book Status
* Reader, where appropriate:
* CRe: on pages whith image content (for over 7.5% of the screen area, should hopefully leave stuff like bullet points or small scene breaks alone).
* Other engines: on user-request (in the gear tab of the bottom menu), via the new "Dithering" knob (will only appear on supported devices).
* ScreenSaver
* ImageViewer
* Minimize repaints when flash_ui is enabled (by, almost everywhere, only repainting the flashing element, and not the toplevel window which hosts it).
(The first pass of this involved fixing a few Button instances whose show_parent was wrong, in particular, chevrons in the FM & TopMenu).
* Hunted down a few redundant repaints (unneeded setDirty("all") calls),
either by switching the widget to nil when only a refresh was needed, and not a repaint,
or by passing the appropritate widget to setDirty.
(Note to self: Enable *verbose* debugging to catch broken setDirty calls via its post guard).
There were also a few instances of 'em right behind a widget close.
* Don't repaint the underlying widget when initially showing TopMenu & ConfigDialog.
We unfortunately do need to do it when switching tabs, because of their variable heights.
* On Kobo, disabled the extra and completely useless full refresh before suspend/reboot/poweroff, as well as on resume. No more double refreshes!
* Fix another debug guard in Kobo sysfs_light
* Switch ImageWidget & ImageViewer mostly to "ui" updates, which will be better suited to image content pretty much everywhere, REAGL or not.
PS: (Almost :100: commits! :D)
2019-02-07 00:14:37 +00:00
|
|
|
-- we don't need an extra refreshFull on resume, thank you very much.
|
|
|
|
needsScreenRefreshAfterResume = no,
|
2019-01-13 23:49:29 +00:00
|
|
|
-- currently only the Aura One and Forma have coloured frontlights
|
2018-02-04 11:32:51 +00:00
|
|
|
hasNaturalLight = no,
|
2019-04-12 20:46:10 +00:00
|
|
|
hasNaturalLightMixer = no,
|
2020-03-16 00:05:17 +00:00
|
|
|
-- HW inversion is generally safe on Kobo, except on a few boards/kernels
|
2019-04-08 21:05:08 +00:00
|
|
|
canHWInvert = yes,
|
2020-06-19 07:41:50 +00:00
|
|
|
home_dir = "/mnt/onboard",
|
2020-08-25 00:00:59 +00:00
|
|
|
canToggleMassStorage = yes,
|
2021-03-26 16:13:27 +00:00
|
|
|
-- New devices *may* be REAGL-aware, but generally don't expect explicit REAGL requests, default to not.
|
|
|
|
isREAGL = no,
|
|
|
|
-- Mark 7 devices sport an updated driver.
|
|
|
|
isMk7 = no,
|
2021-03-21 09:56:21 +00:00
|
|
|
-- MXCFB_WAIT_FOR_UPDATE_COMPLETE ioctls are generally reliable
|
|
|
|
hasReliableMxcWaitFor = yes,
|
2014-10-30 18:42:18 +00:00
|
|
|
}
|
|
|
|
|
2019-08-23 17:53:53 +00:00
|
|
|
--- @todo hasKeys for some devices?
|
2014-10-30 18:42:18 +00:00
|
|
|
|
2014-11-27 10:14:24 +00:00
|
|
|
-- Kobo Touch:
|
2014-10-30 18:42:18 +00:00
|
|
|
local KoboTrilogy = Kobo:new{
|
|
|
|
model = "Kobo_trilogy",
|
2016-04-03 04:52:30 +00:00
|
|
|
needsTouchScreenProbe = yes,
|
2014-10-30 18:42:18 +00:00
|
|
|
touch_switch_xy = false,
|
2014-12-26 11:45:09 +00:00
|
|
|
hasKeys = yes,
|
2019-03-19 19:18:38 +00:00
|
|
|
hasMultitouch = no,
|
2014-10-30 18:42:18 +00:00
|
|
|
}
|
|
|
|
|
2014-11-27 10:14:24 +00:00
|
|
|
-- Kobo Mini:
|
2014-10-30 18:42:18 +00:00
|
|
|
local KoboPixie = Kobo:new{
|
|
|
|
model = "Kobo_pixie",
|
|
|
|
display_dpi = 200,
|
2019-03-19 19:18:38 +00:00
|
|
|
hasMultitouch = no,
|
2014-11-27 15:33:48 +00:00
|
|
|
-- bezel:
|
|
|
|
viewport = Geom:new{x=0, y=2, w=596, h=794},
|
2014-10-30 18:42:18 +00:00
|
|
|
}
|
|
|
|
|
2016-09-13 05:50:07 +00:00
|
|
|
-- Kobo Aura One:
|
|
|
|
local KoboDaylight = Kobo:new{
|
|
|
|
model = "Kobo_daylight",
|
|
|
|
hasFrontlight = yes,
|
|
|
|
touch_phoenix_protocol = true,
|
|
|
|
display_dpi = 300,
|
2018-02-04 11:32:51 +00:00
|
|
|
hasNaturalLight = yes,
|
2018-10-27 20:49:18 +00:00
|
|
|
frontlight_settings = {
|
|
|
|
frontlight_white = "/sys/class/backlight/lm3630a_led1b",
|
|
|
|
frontlight_red = "/sys/class/backlight/lm3630a_led1a",
|
|
|
|
frontlight_green = "/sys/class/backlight/lm3630a_ledb",
|
|
|
|
},
|
2016-09-13 05:50:07 +00:00
|
|
|
}
|
|
|
|
|
2014-11-27 10:14:24 +00:00
|
|
|
-- Kobo Aura H2O:
|
2014-10-30 18:42:18 +00:00
|
|
|
local KoboDahlia = Kobo:new{
|
|
|
|
model = "Kobo_dahlia",
|
|
|
|
hasFrontlight = yes,
|
|
|
|
touch_phoenix_protocol = true,
|
2021-04-02 23:48:35 +00:00
|
|
|
-- There's no slot 0, the first finger gets assigned slot 1, and the second slot 2.
|
2021-04-13 15:53:15 +00:00
|
|
|
-- NOTE: Could be queried at runtime via EVIOCGABS on C.ABS_MT_TRACKING_ID (minimum field).
|
|
|
|
-- Used to be handled via an adjustTouchAlyssum hook that just mangled ABS_MT_TRACKING_ID values.
|
2020-10-27 15:42:22 +00:00
|
|
|
main_finger_slot = 1,
|
2014-10-30 18:42:18 +00:00
|
|
|
display_dpi = 265,
|
2015-04-26 17:11:47 +00:00
|
|
|
-- the bezel covers the top 11 pixels:
|
|
|
|
viewport = Geom:new{x=0, y=11, w=1080, h=1429},
|
2014-10-30 18:42:18 +00:00
|
|
|
}
|
|
|
|
|
2014-11-27 10:14:24 +00:00
|
|
|
-- Kobo Aura HD:
|
2014-10-30 18:42:18 +00:00
|
|
|
local KoboDragon = Kobo:new{
|
|
|
|
model = "Kobo_dragon",
|
|
|
|
hasFrontlight = yes,
|
2019-03-19 19:18:38 +00:00
|
|
|
hasMultitouch = no,
|
2014-10-30 18:42:18 +00:00
|
|
|
display_dpi = 265,
|
|
|
|
}
|
|
|
|
|
2014-11-27 10:14:24 +00:00
|
|
|
-- Kobo Glo:
|
2014-10-30 18:42:18 +00:00
|
|
|
local KoboKraken = Kobo:new{
|
|
|
|
model = "Kobo_kraken",
|
|
|
|
hasFrontlight = yes,
|
2019-03-19 19:18:38 +00:00
|
|
|
hasMultitouch = no,
|
2014-10-30 18:42:18 +00:00
|
|
|
display_dpi = 212,
|
|
|
|
}
|
|
|
|
|
2014-11-27 10:14:24 +00:00
|
|
|
-- Kobo Aura:
|
2014-10-30 18:42:18 +00:00
|
|
|
local KoboPhoenix = Kobo:new{
|
|
|
|
model = "Kobo_phoenix",
|
|
|
|
hasFrontlight = yes,
|
|
|
|
touch_phoenix_protocol = true,
|
2014-11-20 03:23:02 +00:00
|
|
|
display_dpi = 212,
|
2019-05-21 18:31:23 +00:00
|
|
|
-- The bezel covers 10 pixels at the bottom:
|
|
|
|
viewport = Geom:new{x=0, y=0, w=758, h=1014},
|
2021-03-26 16:13:27 +00:00
|
|
|
-- NOTE: AFAICT, the Aura was the only one explicitly requiring REAGL requests...
|
|
|
|
isREAGL = yes,
|
2019-04-08 21:05:08 +00:00
|
|
|
-- NOTE: May have a buggy kernel, according to the nightmode hack...
|
|
|
|
canHWInvert = no,
|
2014-10-30 18:42:18 +00:00
|
|
|
}
|
|
|
|
|
2017-10-19 05:42:59 +00:00
|
|
|
-- Kobo Aura H2O2:
|
|
|
|
local KoboSnow = Kobo:new{
|
|
|
|
model = "Kobo_snow",
|
|
|
|
hasFrontlight = yes,
|
2018-03-04 17:31:46 +00:00
|
|
|
touch_snow_protocol = true,
|
|
|
|
touch_mirrored_x = false,
|
2017-10-19 05:42:59 +00:00
|
|
|
display_dpi = 265,
|
2018-03-02 22:03:00 +00:00
|
|
|
hasNaturalLight = yes,
|
|
|
|
frontlight_settings = {
|
|
|
|
frontlight_white = "/sys/class/backlight/lm3630a_ledb",
|
|
|
|
frontlight_red = "/sys/class/backlight/lm3630a_led",
|
|
|
|
frontlight_green = "/sys/class/backlight/lm3630a_leda",
|
|
|
|
},
|
2017-10-19 05:42:59 +00:00
|
|
|
}
|
|
|
|
|
2018-05-10 10:26:07 +00:00
|
|
|
-- Kobo Aura H2O2, Rev2:
|
2019-08-23 17:53:53 +00:00
|
|
|
--- @fixme Check if the Clara fix actually helps here... (#4015)
|
2018-05-10 10:26:07 +00:00
|
|
|
local KoboSnowRev2 = Kobo:new{
|
2018-12-28 03:32:42 +00:00
|
|
|
model = "Kobo_snow_r2",
|
2021-03-26 16:13:27 +00:00
|
|
|
isMk7 = yes,
|
2018-05-10 10:26:07 +00:00
|
|
|
hasFrontlight = yes,
|
2018-06-10 12:46:29 +00:00
|
|
|
touch_snow_protocol = true,
|
2018-05-10 10:26:07 +00:00
|
|
|
display_dpi = 265,
|
|
|
|
hasNaturalLight = yes,
|
|
|
|
frontlight_settings = {
|
|
|
|
frontlight_white = "/sys/class/backlight/lm3630a_ledb",
|
Another set of fixes (#4083)
* Make findcalibre actually useful
By setting SEARCH_LIBRARY_PATH when a Calibre tree is found, so that
book paths can properly be constructed.
Users should still very much set it themselves, but at least everything
works as intended when not, instead of mysteriously half-breaking later.
Drop the SetDefaults bits, it appeared to have been added to fix no-ops
detected by Luacheck, and it's actually non-functional, because
SetDefaults doesn't handle saving variables it did not itself assign.
So this was just causing the "Do you want to save new defaults" popup to
show up on exit, but it couldn't actually do anything useful (like, say,
save the new SEARCH_LIBRARY_PATH value).
fix #4082
* Better comments about the state of NaturalLight on the Clara, and how this might translate to the H2O²r2.
re #4015
* Make ScrolltextWidget refresh as "partial" only on actual Scroll events
Moving the cursor should stay "ui", or things gets annoying really fast
;).
re #4084
* Bump base to pickup ZMQ fixes (fix #4086)
2018-07-21 19:51:25 +00:00
|
|
|
frontlight_red = "/sys/class/backlight/lm3630a_leda",
|
2018-05-10 10:26:07 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2016-12-13 13:42:06 +00:00
|
|
|
-- Kobo Aura second edition:
|
|
|
|
local KoboStar = Kobo:new{
|
|
|
|
model = "Kobo_star",
|
|
|
|
hasFrontlight = yes,
|
2016-12-16 09:53:41 +00:00
|
|
|
touch_phoenix_protocol = true,
|
2016-12-13 13:42:06 +00:00
|
|
|
display_dpi = 212,
|
|
|
|
}
|
|
|
|
|
2018-05-10 10:26:07 +00:00
|
|
|
-- Kobo Aura second edition, Rev 2:
|
|
|
|
local KoboStarRev2 = Kobo:new{
|
2018-12-28 03:32:42 +00:00
|
|
|
model = "Kobo_star_r2",
|
2021-03-26 16:13:27 +00:00
|
|
|
isMk7 = yes,
|
2018-05-10 10:26:07 +00:00
|
|
|
hasFrontlight = yes,
|
|
|
|
touch_phoenix_protocol = true,
|
|
|
|
display_dpi = 212,
|
|
|
|
}
|
|
|
|
|
2015-05-15 21:46:16 +00:00
|
|
|
-- Kobo Glo HD:
|
|
|
|
local KoboAlyssum = Kobo:new{
|
|
|
|
model = "Kobo_alyssum",
|
|
|
|
hasFrontlight = yes,
|
2015-05-16 01:57:00 +00:00
|
|
|
touch_phoenix_protocol = true,
|
2021-04-13 15:53:15 +00:00
|
|
|
main_finger_slot = 1,
|
2015-05-15 21:46:16 +00:00
|
|
|
display_dpi = 300,
|
|
|
|
}
|
|
|
|
|
2016-05-04 15:59:52 +00:00
|
|
|
-- Kobo Touch 2.0:
|
|
|
|
local KoboPika = Kobo:new{
|
|
|
|
model = "Kobo_pika",
|
|
|
|
touch_phoenix_protocol = true,
|
2021-04-13 15:53:15 +00:00
|
|
|
main_finger_slot = 1,
|
2016-05-04 15:59:52 +00:00
|
|
|
}
|
|
|
|
|
2018-06-10 12:46:29 +00:00
|
|
|
-- Kobo Clara HD:
|
|
|
|
local KoboNova = Kobo:new{
|
|
|
|
model = "Kobo_nova",
|
2021-03-26 16:13:27 +00:00
|
|
|
isMk7 = yes,
|
2020-10-21 23:17:34 +00:00
|
|
|
canToggleChargingLED = yes,
|
2018-06-10 12:46:29 +00:00
|
|
|
hasFrontlight = yes,
|
|
|
|
touch_snow_protocol = true,
|
|
|
|
display_dpi = 300,
|
|
|
|
hasNaturalLight = yes,
|
2018-07-01 15:35:12 +00:00
|
|
|
frontlight_settings = {
|
2019-01-31 13:55:14 +00:00
|
|
|
frontlight_white = "/sys/class/backlight/mxc_msp430.0/brightness",
|
|
|
|
frontlight_mixer = "/sys/class/backlight/lm3630a_led/color",
|
|
|
|
nl_min = 0,
|
|
|
|
nl_max = 10,
|
|
|
|
nl_inverted = true,
|
2018-07-01 15:35:12 +00:00
|
|
|
},
|
2018-06-10 12:46:29 +00:00
|
|
|
}
|
|
|
|
|
2018-11-11 00:01:08 +00:00
|
|
|
-- Kobo Forma:
|
2018-12-28 03:32:42 +00:00
|
|
|
-- NOTE: Right now, we enforce Portrait orientation on startup to avoid getting touch coordinates wrong,
|
|
|
|
-- no matter the rotation we were started from (c.f., platform/kobo/koreader.sh).
|
|
|
|
-- NOTE: For the FL, assume brightness is WO, and actual_brightness is RO!
|
|
|
|
-- i.e., we could have a real KoboPowerD:frontlightIntensityHW() by reading actual_brightness ;).
|
2019-02-08 17:31:40 +00:00
|
|
|
-- NOTE: Rotation events *may* not be enabled if Nickel has never been brought up in that power cycle.
|
|
|
|
-- i.e., this will affect KSM users.
|
|
|
|
-- c.f., https://github.com/koreader/koreader/pull/4414#issuecomment-449652335
|
|
|
|
-- There's also a CM_ROTARY_ENABLE command, but which seems to do as much nothing as the STATUS one...
|
2018-11-11 00:01:08 +00:00
|
|
|
local KoboFrost = Kobo:new{
|
|
|
|
model = "Kobo_frost",
|
2021-03-26 16:13:27 +00:00
|
|
|
isMk7 = yes,
|
2020-10-21 23:17:34 +00:00
|
|
|
canToggleChargingLED = yes,
|
2018-11-11 00:01:08 +00:00
|
|
|
hasFrontlight = yes,
|
|
|
|
hasKeys = yes,
|
2020-07-09 17:11:44 +00:00
|
|
|
hasGSensor = yes,
|
2019-01-08 01:59:47 +00:00
|
|
|
canToggleGSensor = yes,
|
2018-11-11 00:01:08 +00:00
|
|
|
touch_snow_protocol = true,
|
2018-12-28 03:32:42 +00:00
|
|
|
misc_ntx_gsensor_protocol = true,
|
2018-11-11 00:01:08 +00:00
|
|
|
display_dpi = 300,
|
|
|
|
hasNaturalLight = yes,
|
|
|
|
frontlight_settings = {
|
2018-12-28 03:32:42 +00:00
|
|
|
frontlight_white = "/sys/class/backlight/mxc_msp430.0/brightness",
|
|
|
|
frontlight_mixer = "/sys/class/backlight/tlc5947_bl/color",
|
|
|
|
-- Warmth goes from 0 to 10 on the device's side (our own internal scale is still normalized to [0...100])
|
|
|
|
-- NOTE: Those three extra keys are *MANDATORY* if frontlight_mixer is set!
|
|
|
|
nl_min = 0,
|
|
|
|
nl_max = 10,
|
|
|
|
nl_inverted = true,
|
|
|
|
},
|
2018-11-11 00:01:08 +00:00
|
|
|
}
|
|
|
|
|
2019-09-11 17:40:36 +00:00
|
|
|
-- Kobo Libra:
|
|
|
|
-- NOTE: Assume the same quirks as the Forma apply.
|
|
|
|
local KoboStorm = Kobo:new{
|
|
|
|
model = "Kobo_storm",
|
2021-03-26 16:13:27 +00:00
|
|
|
isMk7 = yes,
|
2020-10-21 23:17:34 +00:00
|
|
|
canToggleChargingLED = yes,
|
2019-09-11 17:40:36 +00:00
|
|
|
hasFrontlight = yes,
|
|
|
|
hasKeys = yes,
|
2020-07-09 17:11:44 +00:00
|
|
|
hasGSensor = yes,
|
2019-09-11 17:40:36 +00:00
|
|
|
canToggleGSensor = yes,
|
|
|
|
touch_snow_protocol = true,
|
|
|
|
misc_ntx_gsensor_protocol = true,
|
|
|
|
display_dpi = 300,
|
|
|
|
hasNaturalLight = yes,
|
|
|
|
frontlight_settings = {
|
|
|
|
frontlight_white = "/sys/class/backlight/mxc_msp430.0/brightness",
|
2019-09-23 16:06:57 +00:00
|
|
|
frontlight_mixer = "/sys/class/backlight/lm3630a_led/color",
|
2019-09-11 17:40:36 +00:00
|
|
|
-- Warmth goes from 0 to 10 on the device's side (our own internal scale is still normalized to [0...100])
|
|
|
|
-- NOTE: Those three extra keys are *MANDATORY* if frontlight_mixer is set!
|
|
|
|
nl_min = 0,
|
|
|
|
nl_max = 10,
|
|
|
|
nl_inverted = true,
|
|
|
|
},
|
2021-03-21 09:56:21 +00:00
|
|
|
-- NOTE: The Libra apparently suffers from a mysterious issue where completely innocuous WAIT_FOR_UPDATE_COMPLETE ioctls
|
|
|
|
-- will mysteriously fail with a timeout (5s)...
|
|
|
|
-- This obviously leads to *terrible* user experience, so, until more is understood avout the issue,
|
|
|
|
-- bypass this ioctl on this device.
|
|
|
|
-- c.f., https://github.com/koreader/koreader/issues/7340
|
|
|
|
hasReliableMxcWaitFor = no,
|
2019-09-11 17:40:36 +00:00
|
|
|
}
|
|
|
|
|
2020-07-16 11:18:10 +00:00
|
|
|
-- Kobo Nia:
|
|
|
|
--- @fixme: Untested, assume it's Clara-ish for now.
|
|
|
|
local KoboLuna = Kobo:new{
|
|
|
|
model = "Kobo_luna",
|
2021-03-26 16:13:27 +00:00
|
|
|
isMk7 = yes,
|
2020-10-21 23:17:34 +00:00
|
|
|
canToggleChargingLED = yes,
|
2020-07-16 11:18:10 +00:00
|
|
|
hasFrontlight = yes,
|
|
|
|
touch_snow_protocol = true,
|
|
|
|
display_dpi = 212,
|
|
|
|
}
|
|
|
|
|
2014-10-30 18:42:18 +00:00
|
|
|
function Kobo:init()
|
2021-03-21 09:56:21 +00:00
|
|
|
-- Check if we need to disable MXCFB_WAIT_FOR_UPDATE_COMPLETE ioctls...
|
|
|
|
local mxcfb_bypass_wait_for
|
|
|
|
if G_reader_settings:has("mxcfb_bypass_wait_for") then
|
|
|
|
mxcfb_bypass_wait_for = G_reader_settings:isTrue("mxcfb_bypass_wait_for")
|
|
|
|
else
|
|
|
|
mxcfb_bypass_wait_for = not self:hasReliableMxcWaitFor()
|
|
|
|
end
|
|
|
|
|
|
|
|
self.screen = require("ffi/framebuffer_mxcfb"):new{
|
|
|
|
device = self,
|
|
|
|
debug = logger.dbg,
|
|
|
|
is_always_portrait = self.isAlwaysPortrait(),
|
|
|
|
mxcfb_bypass_wait_for = mxcfb_bypass_wait_for,
|
|
|
|
}
|
2019-03-14 03:48:03 +00:00
|
|
|
if self.screen.fb_bpp == 32 then
|
[feat, Kobo] On Kobo, drop fb to 8bpp on startup (#4637)
* The Great 8bpp Experiment
Swap to 8bpp on Kobo, because we're 'effing grayscale, for pete's sake!
* Always swap to 8bpp, no matter the launch method.
Because it turned out that, even when restarting Nickel, we had to
restore the expected bitdepth ourselves, because pickel/Nickel didn't do
the job completely.
(I'm going to guess the grayscale flag wasn't getting flipped properly).
* Dither every non-transparent icon to the eInk palette
* Make sure hasBGRFrameBuffer is only enabled when the Kobo fb actually is
@ 32bpp...
* Re-process badly grayscaled icons
* And re-grayscale that one w/ gamma correction so the squares show up
better.
* Allow the fbdepth switch to be disabled (in Developer settings).
Also, allow setting debug mode that way.
Also, forcibly disable verbose logging when disabling debug.
* Update setting name to piggyback on the existing check in reader.lua
* Update icons postprocessing info
2019-03-03 11:31:55 +00:00
|
|
|
-- Ensure we decode images properly, as our framebuffer is BGRA...
|
2019-03-14 03:48:03 +00:00
|
|
|
logger.info("Enabling Kobo @ 32bpp BGR tweaks")
|
[feat, Kobo] On Kobo, drop fb to 8bpp on startup (#4637)
* The Great 8bpp Experiment
Swap to 8bpp on Kobo, because we're 'effing grayscale, for pete's sake!
* Always swap to 8bpp, no matter the launch method.
Because it turned out that, even when restarting Nickel, we had to
restore the expected bitdepth ourselves, because pickel/Nickel didn't do
the job completely.
(I'm going to guess the grayscale flag wasn't getting flipped properly).
* Dither every non-transparent icon to the eInk palette
* Make sure hasBGRFrameBuffer is only enabled when the Kobo fb actually is
@ 32bpp...
* Re-process badly grayscaled icons
* And re-grayscale that one w/ gamma correction so the squares show up
better.
* Allow the fbdepth switch to be disabled (in Developer settings).
Also, allow setting debug mode that way.
Also, forcibly disable verbose logging when disabling debug.
* Update setting name to piggyback on the existing check in reader.lua
* Update icons postprocessing info
2019-03-03 11:31:55 +00:00
|
|
|
self.hasBGRFrameBuffer = yes
|
2018-08-12 18:01:04 +00:00
|
|
|
end
|
2019-04-12 20:46:10 +00:00
|
|
|
|
|
|
|
-- Automagically set this so we never have to remember to do it manually ;p
|
|
|
|
if self:hasNaturalLight() and self.frontlight_settings and self.frontlight_settings.frontlight_mixer then
|
|
|
|
self.hasNaturalLightMixer = yes
|
|
|
|
end
|
2021-03-26 16:13:27 +00:00
|
|
|
-- Ditto
|
|
|
|
if self:isMk7() then
|
|
|
|
self.canHWDither = yes
|
|
|
|
end
|
2019-04-12 20:46:10 +00:00
|
|
|
|
2014-10-30 18:42:18 +00:00
|
|
|
self.powerd = require("device/kobo/powerd"):new{device = self}
|
2018-12-28 03:32:42 +00:00
|
|
|
-- NOTE: For the Forma, with the buttons on the right, 193 is Top, 194 Bottom.
|
2014-10-30 18:42:18 +00:00
|
|
|
self.input = require("device/input"):new{
|
|
|
|
device = self,
|
|
|
|
event_map = {
|
2017-03-06 02:50:10 +00:00
|
|
|
[59] = "SleepCover",
|
|
|
|
[90] = "LightButton",
|
|
|
|
[102] = "Home",
|
|
|
|
[116] = "Power",
|
2018-12-28 03:32:42 +00:00
|
|
|
[193] = "RPgBack",
|
|
|
|
[194] = "RPgFwd",
|
2017-03-06 02:50:10 +00:00
|
|
|
},
|
|
|
|
event_map_adapter = {
|
|
|
|
SleepCover = function(ev)
|
2016-09-20 07:14:14 +00:00
|
|
|
if self.input:isEvKeyPress(ev) then
|
|
|
|
return "SleepCoverClosed"
|
2019-01-08 01:59:47 +00:00
|
|
|
elseif self.input:isEvKeyRelease(ev) then
|
2016-09-20 07:14:14 +00:00
|
|
|
return "SleepCoverOpened"
|
|
|
|
end
|
|
|
|
end,
|
2017-03-06 02:50:10 +00:00
|
|
|
LightButton = function(ev)
|
2016-09-20 07:14:14 +00:00
|
|
|
if self.input:isEvKeyRelease(ev) then
|
|
|
|
return "Light"
|
|
|
|
end
|
|
|
|
end,
|
2014-10-30 18:42:18 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-12 12:15:08 +00:00
|
|
|
self.wakeup_mgr = WakeupMgr:new()
|
2014-10-30 18:42:18 +00:00
|
|
|
|
2016-04-03 04:52:30 +00:00
|
|
|
Generic.init(self)
|
|
|
|
|
2018-12-28 03:32:42 +00:00
|
|
|
-- When present, event2 is the raw accelerometer data (3-Axis Orientation/Motion Detection)
|
|
|
|
self.input.open("/dev/input/event0") -- Various HW Buttons, Switches & Synthetic NTX events
|
2016-04-03 04:52:30 +00:00
|
|
|
self.input.open("/dev/input/event1")
|
2016-10-22 07:04:37 +00:00
|
|
|
-- fake_events is only used for usb plug event so far
|
2020-07-29 01:27:04 +00:00
|
|
|
-- NOTE: usb hotplug event is also available in /tmp/nickel-hardware-status (... but only when Nickel is running ;p)
|
2016-10-22 07:04:37 +00:00
|
|
|
self.input.open("fake_events")
|
2016-04-03 04:52:30 +00:00
|
|
|
|
|
|
|
if not self.needsTouchScreenProbe() then
|
|
|
|
self:initEventAdjustHooks()
|
|
|
|
else
|
|
|
|
-- if touch probe is required, we postpone EventAdjustHook
|
|
|
|
-- initialization to when self:touchScreenProbe is called
|
|
|
|
self.touchScreenProbe = function()
|
|
|
|
-- if user has not set KOBO_TOUCH_MIRRORED yet
|
|
|
|
if KOBO_TOUCH_MIRRORED == nil then
|
|
|
|
-- and has no probe before
|
2021-03-06 21:44:18 +00:00
|
|
|
if G_reader_settings:hasNot("kobo_touch_switch_xy") then
|
2016-08-11 11:29:09 +00:00
|
|
|
local TouchProbe = require("tools/kobo_touch_probe")
|
2016-04-03 04:52:30 +00:00
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
UIManager:show(TouchProbe:new{})
|
|
|
|
UIManager:run()
|
|
|
|
-- assuming TouchProbe sets kobo_touch_switch_xy config
|
|
|
|
end
|
2021-03-06 21:44:18 +00:00
|
|
|
self.touch_switch_xy = G_reader_settings:readSetting("kobo_touch_switch_xy")
|
2016-04-03 04:52:30 +00:00
|
|
|
end
|
|
|
|
self:initEventAdjustHooks()
|
|
|
|
end
|
|
|
|
end
|
2020-10-21 23:17:34 +00:00
|
|
|
|
|
|
|
-- We have no way of querying the current state of the charging LED, so, our only sane choices are:
|
|
|
|
-- * Do nothing
|
|
|
|
-- * Turn it off on startup
|
|
|
|
-- I've chosen the latter, as I find it vaguely saner, more useful, and it matches Nickel's behavior (I think).
|
|
|
|
self:toggleChargingLED(false)
|
2016-04-03 04:52:30 +00:00
|
|
|
end
|
|
|
|
|
2017-09-18 17:04:36 +00:00
|
|
|
function Kobo:setDateTime(year, month, day, hour, min, sec)
|
2017-08-15 17:54:02 +00:00
|
|
|
if hour == nil or min == nil then return true end
|
2017-09-18 17:04:36 +00:00
|
|
|
local command
|
|
|
|
if year and month and day then
|
|
|
|
command = string.format("date -s '%d-%d-%d %d:%d:%d'", year, month, day, hour, min, sec)
|
|
|
|
else
|
|
|
|
command = string.format("date -s '%d:%d'",hour, min)
|
|
|
|
end
|
|
|
|
if os.execute(command) == 0 then
|
2017-08-15 17:54:02 +00:00
|
|
|
os.execute('hwclock -u -w')
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-12 18:50:30 +00:00
|
|
|
function Kobo:initNetworkManager(NetworkMgr)
|
2016-06-26 00:53:08 +00:00
|
|
|
function NetworkMgr:turnOffWifi(complete_callback)
|
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
|
|
|
self:releaseIP()
|
|
|
|
koboEnableWifi(false)
|
2016-06-26 00:53:08 +00:00
|
|
|
if complete_callback then
|
|
|
|
complete_callback()
|
|
|
|
end
|
2016-06-12 18:50:30 +00:00
|
|
|
end
|
|
|
|
|
2016-06-26 00:53:08 +00:00
|
|
|
function NetworkMgr:turnOnWifi(complete_callback)
|
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
|
|
|
koboEnableWifi(true)
|
2021-03-10 01:16:17 +00:00
|
|
|
self:reconnectOrShowNetworkMenu(complete_callback)
|
2016-06-26 00:53:08 +00:00
|
|
|
end
|
|
|
|
|
2018-05-10 10:26:07 +00:00
|
|
|
local net_if = os.getenv("INTERFACE")
|
|
|
|
if not net_if then
|
|
|
|
net_if = "eth0"
|
|
|
|
end
|
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
|
|
|
function NetworkMgr:getNetworkInterfaceName()
|
|
|
|
return net_if
|
|
|
|
end
|
2016-06-26 00:53:08 +00:00
|
|
|
NetworkMgr:setWirelessBackend(
|
2018-05-10 10:26:07 +00:00
|
|
|
"wpa_supplicant", {ctrl_interface = "/var/run/wpa_supplicant/" .. net_if})
|
2016-06-26 00:53:08 +00:00
|
|
|
|
|
|
|
function NetworkMgr:obtainIP()
|
2016-09-01 07:05:40 +00:00
|
|
|
os.execute("./obtain-ip.sh")
|
2016-06-26 00:53:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function NetworkMgr:releaseIP()
|
2016-09-01 07:05:40 +00:00
|
|
|
os.execute("./release-ip.sh")
|
|
|
|
end
|
|
|
|
|
|
|
|
function NetworkMgr:restoreWifiAsync()
|
|
|
|
os.execute("./restore-wifi-async.sh")
|
2016-06-12 18:50:30 +00:00
|
|
|
end
|
2018-05-10 10:26:07 +00:00
|
|
|
|
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
|
|
|
-- NOTE: Cheap-ass way of checking if Wi-Fi seems to be enabled...
|
2018-05-10 10:26:07 +00:00
|
|
|
-- Since the crux of the issues lies in race-y module unloading, this is perfectly fine for our usage.
|
|
|
|
function NetworkMgr:isWifiOn()
|
2019-08-14 18:50:03 +00:00
|
|
|
local fd = io.open("/proc/modules", "r")
|
|
|
|
if fd then
|
|
|
|
local lsmod = fd:read("*all")
|
|
|
|
fd:close()
|
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
|
|
|
-- lsmod is usually empty, unless Wi-Fi or USB is enabled
|
2019-08-14 18:50:03 +00:00
|
|
|
-- We could alternatively check if lfs.attributes("/proc/sys/net/ipv4/conf/" .. os.getenv("INTERFACE"), "mode") == "directory"
|
|
|
|
-- c.f., also what Cervantes does via /sys/class/net/eth0/carrier to check if the interface is up.
|
|
|
|
-- That said, since we only care about whether *modules* are loaded, this does the job nicely.
|
|
|
|
if lsmod:len() > 0 then
|
|
|
|
local module = os.getenv("WIFI_MODULE") or "sdio_wifi_pwr"
|
|
|
|
if lsmod:find(module) then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
2018-05-10 10:26:07 +00:00
|
|
|
end
|
2016-06-12 18:50:30 +00:00
|
|
|
end
|
|
|
|
|
2017-04-13 17:55:31 +00:00
|
|
|
function Kobo:supportsScreensaver() return true end
|
|
|
|
|
2016-04-03 04:52:30 +00:00
|
|
|
function Kobo:initEventAdjustHooks()
|
2014-10-30 18:42:18 +00:00
|
|
|
-- it's called KOBO_TOUCH_MIRRORED in defaults.lua, but what it
|
|
|
|
-- actually did in its original implementation was to switch X/Y.
|
2016-04-03 04:52:30 +00:00
|
|
|
-- NOTE: for kobo touch, adjustTouchSwitchXY needs to be called before
|
|
|
|
-- adjustTouchMirrorX
|
|
|
|
if (self.touch_switch_xy and not KOBO_TOUCH_MIRRORED)
|
|
|
|
or (not self.touch_switch_xy and KOBO_TOUCH_MIRRORED)
|
2014-10-30 18:42:18 +00:00
|
|
|
then
|
|
|
|
self.input:registerEventAdjustHook(self.input.adjustTouchSwitchXY)
|
|
|
|
end
|
|
|
|
|
|
|
|
if self.touch_mirrored_x then
|
|
|
|
self.input:registerEventAdjustHook(
|
|
|
|
self.input.adjustTouchMirrorX,
|
2019-08-23 17:53:53 +00:00
|
|
|
--- @fixme what if we change the screen portrait mode?
|
2016-04-03 04:52:30 +00:00
|
|
|
self.screen:getWidth()
|
2014-10-30 18:42:18 +00:00
|
|
|
)
|
|
|
|
end
|
2015-05-16 01:57:00 +00:00
|
|
|
|
2018-03-04 17:31:46 +00:00
|
|
|
if self.touch_snow_protocol then
|
|
|
|
self.input.snow_protocol = true
|
|
|
|
end
|
|
|
|
|
2014-10-30 18:42:18 +00:00
|
|
|
if self.touch_phoenix_protocol then
|
|
|
|
self.input.handleTouchEv = self.input.handleTouchEvPhoenix
|
|
|
|
end
|
2018-12-28 03:32:42 +00:00
|
|
|
|
|
|
|
-- Accelerometer on the Forma
|
|
|
|
if self.misc_ntx_gsensor_protocol then
|
2019-01-08 01:59:47 +00:00
|
|
|
if G_reader_settings:isTrue("input_ignore_gsensor") then
|
|
|
|
self.input.isNTXAccelHooked = false
|
|
|
|
else
|
|
|
|
self.input.handleMiscEv = self.input.handleMiscEvNTX
|
|
|
|
self.input.isNTXAccelHooked = true
|
|
|
|
end
|
2018-12-28 03:32:42 +00:00
|
|
|
end
|
2014-10-30 18:42:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function Kobo:getCodeName()
|
2015-04-27 11:15:02 +00:00
|
|
|
-- Try to get it from the env first
|
|
|
|
local codename = os.getenv("PRODUCT")
|
|
|
|
-- If that fails, run the script ourselves
|
|
|
|
if not codename then
|
|
|
|
local std_out = io.popen("/bin/kobo_config.sh 2>/dev/null", "r")
|
2021-01-16 03:41:46 +00:00
|
|
|
codename = std_out:read("*line")
|
2015-04-27 11:15:02 +00:00
|
|
|
std_out:close()
|
|
|
|
end
|
2014-10-30 18:42:18 +00:00
|
|
|
return codename
|
|
|
|
end
|
|
|
|
|
|
|
|
function Kobo:getFirmwareVersion()
|
|
|
|
local version_file = io.open("/mnt/onboard/.kobo/version", "r")
|
2018-05-10 10:26:07 +00:00
|
|
|
if not version_file then
|
|
|
|
self.firmware_rev = "none"
|
|
|
|
end
|
2021-01-16 03:41:46 +00:00
|
|
|
local version_str = version_file:read("*line")
|
2014-10-30 18:42:18 +00:00
|
|
|
version_file:close()
|
2018-05-10 10:26:07 +00:00
|
|
|
|
|
|
|
local i = 0
|
|
|
|
for field in util.gsplit(version_str, ",", false, false) do
|
|
|
|
i = i + 1
|
|
|
|
if (i == 3) then
|
|
|
|
self.firmware_rev = field
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function getProductId()
|
|
|
|
-- Try to get it from the env first (KSM only)
|
2018-06-16 21:05:20 +00:00
|
|
|
local product_id = os.getenv("MODEL_NUMBER")
|
2018-05-10 10:26:07 +00:00
|
|
|
-- If that fails, devise it ourselves
|
|
|
|
if not product_id then
|
|
|
|
local version_file = io.open("/mnt/onboard/.kobo/version", "r")
|
|
|
|
if not version_file then
|
|
|
|
return "000"
|
|
|
|
end
|
2021-01-16 03:41:46 +00:00
|
|
|
local version_str = version_file:read("*line")
|
2018-05-10 10:26:07 +00:00
|
|
|
version_file:close()
|
|
|
|
|
|
|
|
product_id = string.sub(version_str, -3, -1)
|
|
|
|
end
|
|
|
|
|
|
|
|
return product_id
|
2014-10-30 18:42:18 +00:00
|
|
|
end
|
|
|
|
|
2017-02-02 15:26:34 +00:00
|
|
|
local unexpected_wakeup_count = 0
|
|
|
|
local function check_unexpected_wakeup()
|
2019-09-12 12:15:08 +00:00
|
|
|
local UIManager = require("ui/uimanager")
|
2017-02-02 15:26:34 +00:00
|
|
|
-- just in case other events like SleepCoverClosed also scheduled a suspend
|
2019-09-12 12:15:08 +00:00
|
|
|
UIManager:unschedule(Kobo.suspend)
|
|
|
|
|
2021-03-10 01:21:02 +00:00
|
|
|
-- Do an initial validation to discriminate unscheduled wakeups happening *outside* of the alarm proximity window.
|
2019-09-12 12:15:08 +00:00
|
|
|
if WakeupMgr:isWakeupAlarmScheduled() and WakeupMgr:validateWakeupAlarmByProximity() then
|
2019-09-14 13:45:46 +00:00
|
|
|
logger.info("Kobo suspend: scheduled wakeup.")
|
2019-09-12 12:15:08 +00:00
|
|
|
local res = WakeupMgr:wakeupAction()
|
|
|
|
if not res then
|
|
|
|
logger.err("Kobo suspend: wakeup action failed.")
|
|
|
|
end
|
2019-09-14 13:45:46 +00:00
|
|
|
logger.info("Kobo suspend: putting device back to sleep.")
|
2019-09-12 12:15:08 +00:00
|
|
|
-- Most wakeup actions are linear, but we need some leeway for the
|
|
|
|
-- poweroff action to send out close events to all requisite widgets.
|
|
|
|
UIManager:scheduleIn(30, Kobo.suspend)
|
|
|
|
else
|
|
|
|
logger.dbg("Kobo suspend: checking unexpected wakeup:",
|
|
|
|
unexpected_wakeup_count)
|
|
|
|
if unexpected_wakeup_count == 0 or unexpected_wakeup_count > 20 then
|
|
|
|
-- Don't put device back to sleep under the following two cases:
|
|
|
|
-- 1. a resume event triggered Kobo:resume() function
|
|
|
|
-- 2. trying to put device back to sleep more than 20 times after unexpected wakeup
|
2021-03-10 01:21:02 +00:00
|
|
|
-- Broadcast a specific event, so that AutoSuspend can pick up the baton...
|
|
|
|
local Event = require("ui/event")
|
|
|
|
UIManager:broadcastEvent(Event:new("UnexpectedWakeupLimit"))
|
2019-09-12 12:15:08 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
logger.err("Kobo suspend: putting device back to sleep. Unexpected wakeups:",
|
|
|
|
unexpected_wakeup_count)
|
|
|
|
Kobo.suspend()
|
|
|
|
end
|
2017-02-02 15:26:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function Kobo:getUnexpectedWakeup() return unexpected_wakeup_count end
|
|
|
|
|
2015-02-01 04:49:46 +00:00
|
|
|
function Kobo:suspend()
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo suspend: going to sleep . . .")
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
UIManager:unschedule(check_unexpected_wakeup)
|
2016-12-29 08:10:38 +00:00
|
|
|
local f, re, err_msg, err_code
|
|
|
|
-- NOTE: Sleep as little as possible here, sleeping has a tendency to make
|
|
|
|
-- everything mysteriously hang...
|
|
|
|
|
|
|
|
-- Depending on device/FW version, some kernels do not support
|
|
|
|
-- wakeup_count, account for that
|
|
|
|
--
|
|
|
|
-- NOTE: ... and of course, it appears to be broken, which probably
|
|
|
|
-- explains why nickel doesn't use this facility...
|
|
|
|
-- (By broken, I mean that the system wakes up right away).
|
|
|
|
-- So, unless that changes, unconditionally disable it.
|
|
|
|
|
|
|
|
--[[
|
|
|
|
|
|
|
|
local has_wakeup_count = false
|
|
|
|
f = io.open("/sys/power/wakeup_count", "r")
|
|
|
|
if f ~= nil then
|
|
|
|
io.close(f)
|
|
|
|
has_wakeup_count = true
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Clear the kernel ring buffer... (we're missing a proper -C flag...)
|
|
|
|
--dmesg -c >/dev/null
|
|
|
|
|
|
|
|
-- Go to sleep
|
|
|
|
local curr_wakeup_count
|
|
|
|
if has_wakeup_count then
|
|
|
|
curr_wakeup_count = "$(cat /sys/power/wakeup_count)"
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo suspend: Current WakeUp count:", curr_wakeup_count)
|
2016-12-29 08:10:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-]]
|
|
|
|
|
2017-01-23 15:14:13 +00:00
|
|
|
-- NOTE: Sets gSleep_Mode_Suspend to 1. Used as a flag throughout the
|
|
|
|
-- kernel to suspend/resume various subsystems
|
|
|
|
-- cf. kernel/power/main.c @ L#207
|
2016-12-29 08:10:38 +00:00
|
|
|
f = io.open("/sys/power/state-extended", "w")
|
|
|
|
if not f then
|
|
|
|
logger.err("Cannot open /sys/power/state-extended for writing!")
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
re, err_msg, err_code = f:write("1\n")
|
2017-01-23 15:14:13 +00:00
|
|
|
io.close(f)
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo suspend: asked the kernel to put subsystems to sleep, ret:", re)
|
2016-12-29 08:10:38 +00:00
|
|
|
if not re then
|
|
|
|
logger.err('write error: ', err_msg, err_code)
|
|
|
|
end
|
|
|
|
|
|
|
|
util.sleep(2)
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo suspend: waited for 2s because of reasons...")
|
2016-12-29 08:10:38 +00:00
|
|
|
|
|
|
|
os.execute("sync")
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo suspend: synced FS")
|
2016-12-29 08:10:38 +00:00
|
|
|
|
|
|
|
--[[
|
|
|
|
|
|
|
|
if has_wakeup_count then
|
|
|
|
f = io.open("/sys/power/wakeup_count", "w")
|
|
|
|
if not f then
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.err("cannot open /sys/power/wakeup_count")
|
2016-12-29 08:10:38 +00:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
re, err_msg, err_code = f:write(tostring(curr_wakeup_count), "\n")
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo suspend: wrote WakeUp count:", curr_wakeup_count)
|
2016-12-29 08:10:38 +00:00
|
|
|
if not re then
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.err("Kobo suspend: failed to write WakeUp count:",
|
2016-12-29 08:10:38 +00:00
|
|
|
err_msg,
|
|
|
|
err_code)
|
|
|
|
end
|
|
|
|
io.close(f)
|
|
|
|
end
|
|
|
|
|
|
|
|
--]]
|
|
|
|
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo suspend: asking for a suspend to RAM . . .")
|
2016-12-29 08:10:38 +00:00
|
|
|
f = io.open("/sys/power/state", "w")
|
|
|
|
if not f then
|
2017-01-23 15:14:13 +00:00
|
|
|
-- reset state-extend back to 0 since we are giving up
|
|
|
|
local ext_fd = io.open("/sys/power/state-extended", "w")
|
|
|
|
if not ext_fd then
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.err("cannot open /sys/power/state-extended for writing!")
|
2017-01-23 15:14:13 +00:00
|
|
|
else
|
|
|
|
ext_fd:write("0\n")
|
|
|
|
io.close(ext_fd)
|
|
|
|
end
|
2016-12-29 08:10:38 +00:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
re, err_msg, err_code = f:write("mem\n")
|
|
|
|
-- NOTE: At this point, we *should* be in suspend to RAM, as such,
|
|
|
|
-- execution should only resume on wakeup...
|
|
|
|
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo suspend: ZzZ ZzZ ZzZ? Write syscall returned: ", re)
|
2016-12-29 08:10:38 +00:00
|
|
|
if not re then
|
|
|
|
logger.err('write error: ', err_msg, err_code)
|
|
|
|
end
|
|
|
|
io.close(f)
|
|
|
|
-- NOTE: Ideally, we'd need a way to warn the user that suspending
|
|
|
|
-- gloriously failed at this point...
|
|
|
|
-- We can safely assume that just from a non-zero return code, without
|
|
|
|
-- looking at the detailed stderr message
|
|
|
|
-- (most of the failures we'll see are -EBUSY anyway)
|
|
|
|
-- For reference, when that happens to nickel, it appears to keep retrying
|
|
|
|
-- to wakeup & sleep ad nauseam,
|
|
|
|
-- which is where the non-sensical 1 -> mem -> 0 loop idea comes from...
|
|
|
|
-- cf. nickel_suspend_strace.txt for more details.
|
|
|
|
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo suspend: woke up!")
|
2016-12-29 08:10:38 +00:00
|
|
|
|
|
|
|
--[[
|
|
|
|
|
|
|
|
if has_wakeup_count then
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("wakeup count: $(cat /sys/power/wakeup_count)")
|
2016-12-29 08:10:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Print tke kernel log since our attempt to sleep...
|
|
|
|
--dmesg -c
|
|
|
|
|
|
|
|
--]]
|
|
|
|
|
|
|
|
-- NOTE: We unflag /sys/power/state-extended in Kobo:resume() to keep
|
|
|
|
-- things tidy and easier to follow
|
2017-02-02 15:26:34 +00:00
|
|
|
|
|
|
|
-- Kobo:resume() will reset unexpected_wakeup_count = 0 to signal an
|
|
|
|
-- expected wakeup, which gets checked in check_unexpected_wakeup().
|
|
|
|
unexpected_wakeup_count = unexpected_wakeup_count + 1
|
|
|
|
-- assuming Kobo:resume() will be called in 15 seconds
|
2019-09-12 12:15:08 +00:00
|
|
|
logger.dbg("Kobo suspend: scheduling unexpected wakeup guard")
|
2017-02-02 15:26:34 +00:00
|
|
|
UIManager:scheduleIn(15, check_unexpected_wakeup)
|
2014-10-30 18:42:18 +00:00
|
|
|
end
|
|
|
|
|
2015-02-01 04:49:46 +00:00
|
|
|
function Kobo:resume()
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo resume: clean up after wakeup")
|
|
|
|
-- reset unexpected_wakeup_count ASAP
|
|
|
|
unexpected_wakeup_count = 0
|
|
|
|
require("ui/uimanager"):unschedule(check_unexpected_wakeup)
|
|
|
|
|
2016-12-29 08:10:38 +00:00
|
|
|
-- Now that we're up, unflag subsystems for suspend...
|
2017-01-23 15:14:13 +00:00
|
|
|
-- NOTE: Sets gSleep_Mode_Suspend to 0. Used as a flag throughout the
|
|
|
|
-- kernel to suspend/resume various subsystems
|
|
|
|
-- cf. kernel/power/main.c @ L#207
|
|
|
|
local f = io.open("/sys/power/state-extended", "w")
|
|
|
|
if not f then
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.err("cannot open /sys/power/state-extended for writing!")
|
2017-01-23 15:14:13 +00:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
local re, err_msg, err_code = f:write("0\n")
|
|
|
|
io.close(f)
|
2017-02-02 15:26:34 +00:00
|
|
|
logger.info("Kobo resume: unflagged kernel subsystems for resume, ret:", re)
|
2017-01-23 15:14:13 +00:00
|
|
|
if not re then
|
|
|
|
logger.err('write error: ', err_msg, err_code)
|
|
|
|
end
|
2016-12-29 08:10:38 +00:00
|
|
|
|
|
|
|
-- HACK: wait a bit (0.1 sec) for the kernel to catch up
|
|
|
|
util.usleep(100000)
|
2016-03-01 18:56:42 +00:00
|
|
|
-- cf. #1862, I can reliably break IR touch input on resume...
|
2016-04-09 15:50:49 +00:00
|
|
|
-- cf. also #1943 for the rationale behind applying this workaorund in every case...
|
2018-04-19 19:08:55 +00:00
|
|
|
f = io.open("/sys/devices/virtual/input/input1/neocmd", "w")
|
2016-04-09 15:50:49 +00:00
|
|
|
if f ~= nil then
|
2017-01-23 15:14:13 +00:00
|
|
|
f:write("a\n")
|
2016-04-09 15:50:49 +00:00
|
|
|
io.close(f)
|
2016-03-01 18:56:42 +00:00
|
|
|
end
|
2014-10-30 18:42:18 +00:00
|
|
|
end
|
|
|
|
|
2017-09-04 19:05:05 +00:00
|
|
|
function Kobo:saveSettings()
|
|
|
|
-- save frontlight state to G_reader_settings (and NickelConf if needed)
|
|
|
|
self.powerd:saveSettings()
|
|
|
|
end
|
|
|
|
|
2016-04-26 22:30:52 +00:00
|
|
|
function Kobo:powerOff()
|
2020-05-31 21:51:21 +00:00
|
|
|
-- Much like Nickel itself, disable the RTC alarm before powering down.
|
|
|
|
WakeupMgr:unsetWakeupAlarm()
|
|
|
|
|
|
|
|
-- Then shut down without init's help
|
2019-06-03 16:54:45 +00:00
|
|
|
os.execute("poweroff -f")
|
2016-04-26 22:30:52 +00:00
|
|
|
end
|
|
|
|
|
2017-05-14 16:43:08 +00:00
|
|
|
function Kobo:reboot()
|
|
|
|
os.execute("reboot")
|
|
|
|
end
|
|
|
|
|
2019-07-01 15:12:24 +00:00
|
|
|
function Kobo:toggleGSensor(toggle)
|
2019-01-08 01:59:47 +00:00
|
|
|
if self:canToggleGSensor() and self.input then
|
|
|
|
-- Currently only supported on the Forma
|
|
|
|
if self.misc_ntx_gsensor_protocol then
|
2019-07-01 15:12:24 +00:00
|
|
|
self.input:toggleMiscEvNTX(toggle)
|
2019-01-08 01:59:47 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-21 23:17:34 +00:00
|
|
|
function Kobo:toggleChargingLED(toggle)
|
|
|
|
if not self:canToggleChargingLED() then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- We have no way of querying the current state from the HW!
|
|
|
|
if toggle == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- NOTE: While most/all Kobos actually have a charging LED, and it can usually be fiddled with in a similar fashion,
|
|
|
|
-- we've seen *extremely* weird behavior in the past when playing with it on older devices (c.f., #5479).
|
|
|
|
-- In fact, Nickel itself doesn't provide this feature on said older devices
|
|
|
|
-- (when it does, it's an option in the Energy saving settings),
|
|
|
|
-- which is why we also limit ourselves to "true" Mk. 7 devices.
|
|
|
|
local f = io.open("/sys/devices/platform/ntx_led/lit", "w")
|
|
|
|
if not f then
|
|
|
|
logger.err("cannot open /sys/devices/platform/ntx_led/lit for writing!")
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
-- c.f., strace -fittvyy -e trace=ioctl,file,signal,ipc,desc -s 256 -o /tmp/nickel.log -p $(pidof -s nickel) &
|
|
|
|
-- This was observed on a Forma, so I'm mildly hopeful that it's safe on other Mk. 7 devices ;).
|
|
|
|
if toggle == true then
|
|
|
|
-- NOTE: Technically, Nickel forces a toggle off before that, too.
|
|
|
|
-- But since we do that on startup, it shouldn't be necessary here...
|
|
|
|
f:write("ch 4")
|
|
|
|
f:flush()
|
|
|
|
f:write("cur 1")
|
|
|
|
f:flush()
|
|
|
|
f:write("dc 63")
|
|
|
|
f:flush()
|
|
|
|
else
|
|
|
|
f:write("ch 3")
|
|
|
|
f:flush()
|
|
|
|
f:write("cur 1")
|
|
|
|
f:flush()
|
|
|
|
f:write("dc 0")
|
|
|
|
f:flush()
|
|
|
|
f:write("ch 4")
|
|
|
|
f:flush()
|
|
|
|
f:write("cur 1")
|
|
|
|
f:flush()
|
|
|
|
f:write("dc 0")
|
|
|
|
f:flush()
|
|
|
|
f:write("ch 5")
|
|
|
|
f:flush()
|
|
|
|
f:write("cur 1")
|
|
|
|
f:flush()
|
|
|
|
f:write("dc 0")
|
|
|
|
f:flush()
|
|
|
|
end
|
|
|
|
|
|
|
|
io.close(f)
|
|
|
|
end
|
|
|
|
|
2020-11-28 21:48:09 +00:00
|
|
|
function Kobo:isStartupScriptUpToDate()
|
|
|
|
-- Compare the hash of the *active* script (i.e., the one in /tmp) to the *potential* one (i.e., the one in KOREADER_DIR)
|
|
|
|
local current_script = "/tmp/koreader.sh"
|
|
|
|
local new_script = os.getenv("KOREADER_DIR") .. "/" .. "koreader.sh"
|
|
|
|
|
|
|
|
local md5 = require("ffi/MD5")
|
|
|
|
return md5.sumFile(current_script) == md5.sumFile(new_script)
|
|
|
|
end
|
|
|
|
|
2014-10-30 18:42:18 +00:00
|
|
|
-------------- device probe ------------
|
|
|
|
|
|
|
|
local codename = Kobo:getCodeName()
|
2018-05-10 10:26:07 +00:00
|
|
|
local product_id = getProductId()
|
2014-10-30 18:42:18 +00:00
|
|
|
|
|
|
|
if codename == "dahlia" then
|
|
|
|
return KoboDahlia
|
|
|
|
elseif codename == "dragon" then
|
|
|
|
return KoboDragon
|
|
|
|
elseif codename == "kraken" then
|
|
|
|
return KoboKraken
|
|
|
|
elseif codename == "phoenix" then
|
|
|
|
return KoboPhoenix
|
|
|
|
elseif codename == "trilogy" then
|
|
|
|
return KoboTrilogy
|
|
|
|
elseif codename == "pixie" then
|
|
|
|
return KoboPixie
|
2015-05-15 21:46:16 +00:00
|
|
|
elseif codename == "alyssum" then
|
2015-05-16 01:57:00 +00:00
|
|
|
return KoboAlyssum
|
2016-05-04 15:59:52 +00:00
|
|
|
elseif codename == "pika" then
|
|
|
|
return KoboPika
|
2018-05-10 10:26:07 +00:00
|
|
|
elseif codename == "star" and product_id == "379" then
|
|
|
|
return KoboStarRev2
|
2016-12-13 13:42:06 +00:00
|
|
|
elseif codename == "star" then
|
|
|
|
return KoboStar
|
2016-09-13 05:50:07 +00:00
|
|
|
elseif codename == "daylight" then
|
2016-09-20 07:14:14 +00:00
|
|
|
return KoboDaylight
|
2018-05-10 10:26:07 +00:00
|
|
|
elseif codename == "snow" and product_id == "378" then
|
|
|
|
return KoboSnowRev2
|
2017-10-19 05:42:59 +00:00
|
|
|
elseif codename == "snow" then
|
|
|
|
return KoboSnow
|
2018-06-10 12:46:29 +00:00
|
|
|
elseif codename == "nova" then
|
|
|
|
return KoboNova
|
2018-11-11 00:01:08 +00:00
|
|
|
elseif codename == "frost" then
|
|
|
|
return KoboFrost
|
2019-09-11 17:40:36 +00:00
|
|
|
elseif codename == "storm" then
|
|
|
|
return KoboStorm
|
2020-07-16 11:18:10 +00:00
|
|
|
elseif codename == "luna" then
|
|
|
|
return KoboLuna
|
2014-10-30 18:42:18 +00:00
|
|
|
else
|
|
|
|
error("unrecognized Kobo model "..codename)
|
|
|
|
end
|