Commit Graph

148 Commits

Author SHA1 Message Date
Arnaud Ferraris
25dd46bb30 manager: make modem_reset more reliable
`modem_reset()` could previously either fail silently, or fall back to
using AT commands without indicating what happened. This commit adds
informative messages and makes sure we fall back to resetting using AT
commands whenever we encounter an error.
2021-10-06 22:25:39 +02:00
Arnaud Ferraris
86978e18a6 at: fix more typos 2021-10-06 02:17:21 +02:00
Arnaud Ferraris
bcdc839abb gnss: don't overload the modem during upload
By instructing sendfile() to send the whole content of the assistance
data at once results in a big data transfer (> 4kb) first followed by a
huge amount of small transfers (64 or 128b). This "overloads" the modem
which needs to process smaller chunks of data and have more time to do
so (experimentation shows that 1kb need 100ms for processing, or the
upload will subsequently fail).

This commit sets the transfer size to 256b and increase the timeout
between each transfer to 25ms.
2021-10-06 01:54:30 +02:00
Arnaud Ferraris
73868260a2 gnss: wait for the modem to confirm upload success
If we clear QFUPL right after we finished the file transfer, we will
execute the following commands right away, leading to interleaved
replies from the modem (i.e. the reply to QGPSXTRATIME being received
with the notification of upload completion).

Keeping the command in the queue allows us to use the callback a second
time once the upload is complete and resume assistance data processing
accordingly.
2021-10-06 01:54:30 +02:00
Arnaud Ferraris
66073cdd21 at: get rid of compiler warning 2021-10-06 01:54:30 +02:00
Arnaud Ferraris
cfd7ebf156 at: ensure we don't skip steps
After the modem send "RDY", other messages are received. With the
current implementation, this causes eg25-manager to mark the modem as
configured before it is even picked up by ModemManager. Adding an
additional status check helps preventing this issue.
2021-10-06 01:54:30 +02:00
Arnaud Ferraris
f03f086fcb src: fix typo 2021-10-05 23:45:33 +02:00
Arnaud Ferraris
f68af6405d manager: honor --version option
Fixes #22
2021-10-05 23:45:27 +02:00
Arnaud Ferraris
68349c9f58 Merge branch 'fix-config-crash' into 'master'
Don't crash on incomplete config files

Closes #23

See merge request mobian1/devices/eg25-manager!31
2021-10-05 20:34:28 +00:00
Arnaud Ferraris
3d9456c0e7 Merge branch 'wip/a-wai/clear-command-queue' into 'master'
at: clear command queue before configuring modem

Closes #24

See merge request mobian1/devices/eg25-manager!34
2021-10-05 20:34:12 +00:00
Arnaud Ferraris
87a7a6c9e9 Merge branch 'at_logging' into 'master'
Fix logging of at commands (was preventing sending them)

See merge request mobian1/devices/eg25-manager!36
2021-10-05 20:33:55 +00:00
ArenM
aec8135ad4 at: escape non text characters in modem response logs 2021-10-05 12:09:12 -04:00
Arnaud Ferraris
fcf3832f52 gpio: don't execute soft wake sequence if already woken up
This add an unnecessary 200ms delay and pollute logs.
2021-10-05 11:23:06 +02:00
Arnaud Ferraris
4c6625a38d src: don't crash on incomplete user-edited config file
If a user created a custom config file and we added new fields in a
newer version, `eg25-manager` will crash by assuming all config files
are complete and up-to-date.

Moreover, creating a custom config, even to change only one option,
required copying a complete default config file and then editing the
relevant field(s). This could lead to issues when upgrading, as default
values of fields unrelated to the user change could be modified and not
applied to the user config.

This patch addresses both these issues by:
* making sure at least one config file exists
* requiring only the "default" config file (the one under `/usr/share`)
  to include all the required fields
* trying to use user config for each field, falling back to the default
  config file if the field isn't present in the user config
* exiting with a meaningful error message in case the default config
  file is missing a required field or section

That way, it will be possible to have a minimal user config file
containing only the field(s) needing a different value than the default
one, falling back to the values in the default config file.

Fixes #23
2021-10-05 11:19:35 +02:00
Arnaud Ferraris
55ed2dc39c src: add helper functions for reading config files 2021-10-05 11:19:35 +02:00
ArenM
89b7dfda2f at: remove call to g_strstrip before sending commando
This log statement called g_strstrip before sending the command, which
caused it to fail because it doesn't send the newline required to run
it.
2021-10-04 23:26:16 -04:00
Arnaud Ferraris
0f3e51cd06 at: clear command queue before configuring modem
In some cases, there might be an issue with `eg25-manager` trying to
reset the modem while it's being configured. This leads to infinite boot
loops where the modem is constantly reset soon after it booted.

Fixes #24
2021-10-04 18:20:46 +02:00
Arnaud Ferraris
8ae79fa34c Merge branch 'at-write-repeat' into 'master'
at_send_command: call write(2) in a loop

See merge request mobian1/devices/eg25-manager!30
2021-10-02 12:14:44 +00:00
Xavier Del Campo
6b2f0e8fbd at.c: fix misleading g_message 2021-10-02 13:59:22 +02:00
Arnaud Ferraris
082cf996d1 Use a more meaningful message on AT send failure 2021-10-02 13:58:32 +02:00
Xavier Del Campo
5102902692 at_send_command: call write(2) in a loop
write(2) might return less than expected due to various reasons.
Therefore, unless we are dealing with a critical error, it must be
called in a loop until all bytes are written.
2021-10-02 13:58:29 +02:00
Arnaud Ferraris
5c61d41090 Merge branch 'gnss_upload_doublefree' into 'master'
gnss: fix double free introduced by !29

See merge request mobian1/devices/eg25-manager!33
2021-09-30 23:19:57 +00:00
ArenM
1a65947176 gnss: fix double free introduced by !29
!29 changed the url varible in fetch_assistance_data to use g_autofree,
but didn't remove all calls to free it.
2021-09-30 14:23:21 -04:00
Arnaud Ferraris
3d29617977 Merge branch 'gnss_cleanup' into 'master'
Fix various small issues in the gnss assistance data upload code

Closes #20

See merge request mobian1/devices/eg25-manager!29
2021-09-29 21:05:08 +00:00
ArenM
36ac57b627 gnss: Gracefully handle failure to access xtra data file 2021-09-29 15:24:33 -04:00
ArenM
ee10cafa00 gnss: flush tmp_file after downloading gpsOneXtra data 2021-09-29 14:37:23 -04:00
ArenM
2fcb5852ae gnss: better error handling and messages when fetching data
This will print the error message from curl instead of just the http
status code if downloading gpsOneXtra data fails. It also adds checks
for other errors that are likely to occur.
2021-09-29 14:37:23 -04:00
Arnaud Ferraris
86372093d7 Merge branch 'gnss-disable-after-fetch' into 'master'
gnss: disable GPS only after fetching assistance data

Closes #21

See merge request mobian1/devices/eg25-manager!32
2021-09-29 07:33:34 +00:00
Arnaud Ferraris
34ec02cd34 gnss: disable GPS only after fetching assistance data
Fixes #21
2021-09-29 01:31:54 +02:00
Arnaud Ferraris
3f4dd9ac79 Merge branch 'snprintf' into 'master'
at.c: use snprintf(3)

See merge request mobian1/devices/eg25-manager!28
2021-09-28 21:31:53 +00:00
Xavier Del Campo
6f91389496 at_send_command: improve logging when snprintf(3) fails 2021-09-28 23:25:19 +02:00
Xavier Del Campo
771e9f8316 at_send_command: call at_next_command on failure 2021-09-28 23:17:25 +02:00
Xavier Del Campo
9e0d97d2e2 at.c: use snprintf(3)
snprintf(3) is preferred over insecure sprintf(3) in order to avoid
buffer overrun vulnerabilities.
2021-09-28 22:53:54 +02:00
ArenM
593db8aa67 gnss: include error messages directly from curl
This will print the error message from curl instead of just the http
status code if downloading gpsOneXtra data fails. This also removes the
need to check to check the size of the file curl downloaded.
2021-09-28 16:48:11 -04:00
ArenM
ad1d6e5d3e gnss: increase upload timeout to 10 seconds
The timeout for QFUPL defaults to 5 seconds which is about how long it
takes to upload data under ideal circumstances.

I'm not sure if this will actually have an effect, the docs say
"<timeout> The time waiting for data to be inputted to USB/UART. The
default value is 5. Unit: s." which could be the time before the first
byte is received.
2021-09-28 16:48:11 -04:00
Arnaud Ferraris
2bf63376d7 Merge branch 'conditional-modemmanager' into 'master'
gnss: Support using ofono when compiled with HAVE_MMGLIB

Closes #16

See merge request mobian1/devices/eg25-manager!26
2021-09-27 18:01:26 +00:00
ArenM
6177c7167c gnss: use sendfile to upload xtra data
This should make the data upload much faster because it handles
incomplete writes better, and because it the kernel copies the data
between the files directly, and it doesn't get sent to userspace and
back.
2021-09-27 13:57:57 -04:00
ArenM
750c41cbb5 gnss: rearrange enable_mm_gnss so it doesn't noop 2021-09-27 13:57:57 -04:00
Arnaud Ferraris
0d2b0e326a Merge branch 'gnss-upload-failure' into 'master'
gnss: properly clean temporary file before downloading assistance data

Closes #17

See merge request mobian1/devices/eg25-manager!27
2021-09-27 17:51:22 +00:00
ArenM
f7c655c297 gnss: Support using ofono when compiled with HAVE_MMGLIB 2021-09-12 17:56:45 -04:00
Dylan Van Assche
41511cbc5f gnss: truncate temporary file before download
A temporary file is used to download the GNSS assistance data.
It's created and truncated at initialization, but not truncated
when a re-upload is necessary (when data expires).
This causes to corrupt the GNSS assistance data if the new downloaded
data is smaller than the previous download.
2021-09-07 09:02:48 +02:00
Dylan Van Assche
8913300997 gnss: open temporary file as read/write
Opening as write-only may cause undefined behavior when reading the file
2021-09-07 07:28:34 +02:00
Dylan Van Assche
7b96296938 at: fix indentation 2021-09-03 21:33:05 +02:00
Arnaud Ferraris
c11f68f402 meson.build: release v0.4.0 0.4.0 2021-09-01 00:40:38 +02:00
Arnaud Ferraris
e6df81778e Merge branch 'handle-sim-unlock' into 'master'
gnss: handle locked SIM

See merge request mobian1/devices/eg25-manager!25
2021-08-12 10:17:02 +00:00
Dylan Van Assche
ef94492b30 gnss: handle locked SIM
ModemManager Location service is only available after SIM unlock
and network registration.
Track service separately to avoid an assert error and crashes.
GNSS assistance data is uploaded when the service becomes available.
2021-08-12 11:19:45 +02:00
Dylan Van Assche
75570e45da gpio: extend softsleep wake time
50ms is way to short for the Quectel firmware to react, increase to 200ms
2021-08-12 11:19:21 +02:00
Arnaud Ferraris
34c3b19f70 Merge branch 'modem-power-cfgs' into 'master'
config: synchronize with modem-power

See merge request mobian1/devices/eg25-manager!18
2021-08-11 13:43:06 +00:00
Dylan Van Assche
10ec1119fb at: fast/poweroff is only available in newer firmware versions
Do not retry the AT command of the fast/poweroff setting as it may not be supported by the firmware
2021-08-11 12:58:06 +02:00
Dylan Van Assche
898c0dc79c config: synchronize with modem-power
We cannot assume default factory values if other drivers change them
2021-08-11 12:56:42 +02:00