Commit Graph

57 Commits

Author SHA1 Message Date
Arnaud Ferraris
f276d9cf9e suspend: make timeouts configurable
Instead of fixed values, the modem boot timeout and recovery timeout are now
(optional) config values.
2021-02-20 17:10:01 +01:00
Arnaud Ferraris
433982e4f7 manager: parse config file
The need to use libusb to check for the modem state on startup now 
depends on a config option, instead of the device type. The USB PID and 
VID are moved to config as well.
2021-02-20 17:04:49 +01:00
Arnaud Ferraris
d9256251fd src: implement config file lookup and initial parsing
This commit prepares the use of device-specific configuration files. 
These files should be named after the device-tree `compatible` string 
with the `toml` extension.

`eg25-manager` will search for config files in 
`<prefix>/etc/eg25-manager` first (or `/etc/eg25-manager` if prefix is 
`/usr`), then in `<prefix>/share/eg25-manager`.
2021-02-20 17:04:49 +01:00
Arnaud Ferraris
c92746e875 src: add TOML parser 2021-02-20 17:04:49 +01:00
Arnaud Ferraris
19d00bee3b manager: make sure we don't block suspend when rebooting the modem 2021-02-20 17:04:38 +01:00
Arnaud Ferraris
b929c6a380 src: minor cleanups and cosmetic fixes 2021-02-20 17:01:17 +01:00
Arnaud Ferraris
4962fcd13e Merge branch 'sleep-inhibit' into 'master'
suspend: add boot timer

See merge request mobian1/devices/eg25-manager!7
2021-02-20 15:49:40 +00:00
Dylan Van Assche
b8d269cf2f suspend: add boot timer
The EG25 modem needs at least 2 minutes after indicating 'RDY'
to be fully operational. If the modem is suspended before that,
calls or texts may not be seen by the userspace.
This mostly occurs when a full reboot or poweroff/poweron
sequence of the phone is performed.

:
2021-02-17 21:05:58 +01:00
Arnaud Ferraris
4ff727a7d4 udev: install using meson 2021-02-16 23:48:35 +01:00
Arnaud Ferraris
7765e6c541 udev: rename configure script 2021-02-16 23:47:29 +01:00
Arnaud Ferraris
94cbd03921 udev: rules: fix wrong ENV match and pass devpath to script 2021-02-16 23:45:25 +01:00
Arnaud Ferraris
4c832a00dc configure-usb-modem: make more generic 2021-02-16 23:44:42 +01:00
Arnaud Ferraris
ded092ef04 Merge branch 'avoid-modem-resets' into 'master'
udev: add udev rule to configure modem USB

See merge request mobian1/devices/eg25-manager!5
2021-02-16 19:09:59 +00:00
Dylan Van Assche
235eff02ac udev: add udev rule to configure modem USB
Quectel advises to configure the USB autosuspend feature as:
- power/control: auto
- power/autosuspend_delay_ms: 3000

Futhermore, the following settings are also needed:
- power/wakeup: enabled
- power/persist: 0
- avoid_reset_quirk: 1
2021-02-16 07:12:01 +01:00
Arnaud Ferraris
3bb6e15de0 mm-iface: keep watching bus if MM vanishes 2021-01-25 23:55:57 +01:00
Arnaud Ferraris
692f9134f8 suspend: handle case when MM doesn't manage suspend/resume 2021-01-23 11:14:41 +01:00
Arnaud Ferraris
31133affa0 meson.build: release version 0.1.2 0.1.2 2021-01-14 00:07:15 +01:00
Arnaud Ferraris
79974bc9ee manager: don't manage the GNSS by default 2021-01-14 00:06:55 +01:00
Arnaud Ferraris
150ff67e7b udev: only check if modem USB ID is set 2021-01-13 23:46:38 +01:00
Arnaud Ferraris
c2e83f15a6 manager: improve error checking in modem_reset() 2020-12-30 17:31:44 +01:00
Arnaud Ferraris
cb5220a1b8 at: reduce delay between retries
There's no reason we should wait 3s before retrying a failed AT command. 
This can even cause issues with suspend inhibition: 3 retries of a 
failed command would take 9s, while logind ignores the inhibitor after 
only 5s.

Reducing the delay to 500ms should be enough and wouldn't interfere with 
suspend inhibition.

Fixes #3
2020-12-30 16:28:39 +01:00
Arnaud Ferraris
abc05e86e5 manager: only toggle GPIOs for suspend after executing all AT commands 2020-12-30 16:20:32 +01:00
Arnaud Ferraris
d990ab667e at: make sure URC cache is disabled on startup 2020-12-30 16:10:41 +01:00
Arnaud Ferraris
2a18b1cb0c meson.build: release version 0.1.1 0.1.1 2020-12-18 01:38:58 +01:00
Arnaud Ferraris
067c01b685 manager: rename suspend_source to suspend_timer
This makes its role more explicit.
2020-12-18 01:38:27 +01:00
Arnaud Ferraris
62a07f9c51 src: add udev watcher to improve modem recovery
Most of the modem issues follow a (incomplete) USB device reset. Instead 
of relying solely on the existing timer, this patch adds a udev monitor 
which resets the modem as soon as its associated USB device is reset, 
which greatly improves recovery time.
2020-12-18 01:37:06 +01:00
Arnaud Ferraris
74b91c7d58 manager: make sure we don't reset the modem twice in a row
This patch adds a 3s delay when resetting the modem during which we 
avoid triggering a new reset. This makes sure we don't trigger a reset 
twice in a row.

It also disables any related running timer to avoid being re-triggered 
unnecessarily.
2020-12-18 00:45:58 +01:00
Arnaud Ferraris
c39000bf93 suspend: increase modem detection delay by 1s
Sometimes it takes just a little bit longer than usual, so this avoids 
unnecessary modem recovery.
2020-12-18 00:35:32 +01:00
Arnaud Ferraris
fdbc2cfa69 Merge branch 'fix_gerror_pointer' into 'master'
mm-iface: fix GError pointer

See merge request mobian1/devices/eg25-manager!2
0.1.0
2020-12-14 00:29:58 +00:00
fortysixandtwo
aa85cd873c mm-iface: fix GError pointer 2020-12-13 16:54:10 +01:00
Arnaud Ferraris
a8e6da534c Merge branch 'autofree_gerror' into 'master'
use g_autoptr for GError

See merge request mobian1/devices/eg25-manager!1
2020-12-13 14:33:52 +00:00
fortysixandtwo
1bb2f80fef use g_autoptr for GError 2020-12-13 15:14:11 +01:00
Arnaud Ferraris
9c9169a972 manager: get rid of compiler warnings 2020-12-13 00:55:22 +01:00
Arnaud Ferraris
b495d6c747 gpio: get rid of compiler warnings 2020-12-13 00:52:38 +01:00
Arnaud Ferraris
dd904bc8c1 at: get rid of compiler warnings 2020-12-13 00:52:35 +01:00
Arnaud Ferraris
8c9a2b21f9 gpio: exit if we can't request output GPIOs
This means the system is in a very bad shape as no other software should 
make use of those, so exit the daemon (will be restarted by systemd).
2020-12-13 00:35:17 +01:00
Arnaud Ferraris
90a016a8f6 src: be more careful before dereferencing potentially NULL pointers 2020-12-12 23:59:53 +01:00
Arnaud Ferraris
ff60016e5d release version 0.0.6 0.0.6 2020-12-11 15:10:13 +01:00
Arnaud Ferraris
5715138a96 suspend: reset sleep inhibitor if already present upon resume 2020-12-11 15:09:43 +01:00
Arnaud Ferraris
fd6a292a8f manager: don't change modem state after reset
This makes sure the resume commands (disable URC cache and enable GPS)
are executed.
2020-12-11 15:09:38 +01:00
Arnaud Ferraris
5fa345ec92 mm-iface: don't reset USB ID unless quitting
As ModemManager releases the modem while going to sleep, we clear the
USB ID too, which causes a segfault when trying to recover the modem.
2020-12-11 14:34:34 +01:00
Arnaud Ferraris
a9725243ec meson.build: bump version 0.0.5 2020-12-11 13:37:40 +01:00
Arnaud Ferraris
75b0920e9d Revert "manager: split modem_suspend() into _pre() and _post() functions"
This reverts commit ff9b26b831.
2020-12-11 13:36:28 +01:00
Arnaud Ferraris
9713af7ca8 at: fix GPS disabling on suspend 2020-12-11 13:31:11 +01:00
Arnaud Ferraris
664f82d570 at: add default handling for unrecognized responses 2020-12-11 13:31:11 +01:00
Arnaud Ferraris
f386d851fa at: make sure we read the full response before processing it 0.0.4 2020-12-11 12:49:31 +01:00
Arnaud Ferraris
5bc8443c38 at: be less strict when checking for error
The response can include the command and an error number, so we want to 
only check it contains ERROR, even if it's replying more than just the 
'ERROR' string.
2020-12-11 12:49:31 +01:00
Arnaud Ferraris
aabe4df41c at: fix suspend/resume sequences
These are set commands, no need to verify the current value.
2020-12-11 12:49:31 +01:00
Arnaud Ferraris
ff9b26b831 manager: split modem_suspend() into _pre() and _post() functions
This way we can make sure the AT commands are executed only once 
ModemManager has released the modem, preventing any race condition.
2020-12-11 12:49:31 +01:00
Arnaud Ferraris
8d31e39e89 manager: only start the modem if it isn't already on 2020-12-11 12:49:10 +01:00