Executing a reset each time the modem is unbound is a bit too extreme:
the modem sometimes recovers by itself and only needs a "soft" reset
sequence (unbind/bind).
This commit introduces a short timer (2s) so we the modem can settle in.
If reset fails after this time, the modem is probably completely broken,
or already rebooting, so we can safely issue a reset AT command.
`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.
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.
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.
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.
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
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
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.
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.
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.
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.
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.
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.