Commit Graph
35 Commits
Author SHA1 Message Date
Aleksander Morgado 939be0fbf8 base-modem: support non-serial ports when peeking the best AT port
When we don't care about the type of AT port to use, prefer the QMI or
MBIM based ones if any available.
2024-04-23 07:25:12 +00:00
Aleksander Morgado 480e12c34e base-modem-at: switch to use the MMIfacePortAt by default
The whole codebase is updated to assume the MMBaseModem AT operations
require an object implementing the MMIfacePortAt interface, instead of
a MMPortSerialAt object.

In the places where we know the port is a MMPortSerialAt, e.g. when we
query explicitly for the primary or secondary serial AT port, we will
use an explicit MM_IFACE_PORT_AT() cast when calling the AT command
method.

In the places where we get_best_at_port() we're going to assume that
we don't know the port type. This method will be updated in a follow
up commit to support the MMIfacePortAt interface as well.
2024-04-23 07:25:12 +00:00
Aleksander Morgado 67a0af3575 base-modem-at: switch internals to use MMIfacePortAt 2024-04-23 07:25:12 +00:00
Aleksander Morgado 11c2f7c068 base-modem-at: refactor implementation
No functional changes should happen.

The purpose of this change is to align coding style with the rest of
the project and also simplify the implementation of the different AT
command handling methods, e.g. to avoid needing so many internal
helper methods.
2024-04-23 07:25:12 +00:00
Aleksander Morgado 9cb709b87e base-modem-at: remove unused at_command_raw() method 2024-04-12 11:02:20 +00:00
Aleksander Morgado aec461132c base-modem-at: switch command error handling to g_autoptr 2024-03-12 10:15:59 +00:00
Dan Williams ded76a0abb base-modem-at: add optional wait before sending command in a sequence
Can be used for easier command retries where the generic sequence code
handles the GTimeout source.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2024-02-19 11:24:27 +00:00
Lubomir Rintel 0c1ad4eb77 base-modem-at: use better names for pairs of dependent cancellables
We cancel AT commands (or sequences) on cancellation of the modem's
cancellable as well as of the optional user-provided one.

However, the GTask can be associated with only one. That's okay if the
user didn't supply one -- we just use the modem's cancellable only.
Otherwise we chain the cancellables together (also cancel the user one
with the modem one) at cost of some extra complexity.

This aims to make the above a little clearer by using hopefully
better names.

Suggested-by: Aleksander Morgado <aleksandermj@chromium.org>
2023-04-11 13:49:03 +00:00
Lubomir Rintel da55fa769e base-modem-at: make abort_task_if_port_unusable() unref the GTask
Aleksander seems to prefer it this way. Looks better.

Suggested-by: Aleksander Morgado <aleksandermj@chromium.org>
2023-04-11 13:49:03 +00:00
Lubomir Rintel 476cb2bbc2 base-modem-at: port mm_base_modem_at_{command,sequence}_full() to GTask
Use GTask API in place of the deprecated GSimpleAsyncResult.
2023-04-11 13:49:03 +00:00
Lubomir Rintel c40876de95 port-serial-at: make mm_port_serial_at_command_finish() transfer ownership
This will make it slightly easier to port mm_port_serial_at_command() to
use GTask, since we won't have to keep a pointer to the result in GTask
after _finish() has been called.

In most cases the caller needs the value anyway, so this doesn't add too
much hasle.
2023-04-11 13:49:03 +00:00
Aleksander Morgado 4b37b7d3cf base-modem,at: response processors return a more specific enum
Instead of using the FALSE return of the method to indicate either a
fatal error (if result_error was set) or the continuation request (if
result_error wasn't set), provide a enum that has explicit states for
all three possible values (failure, success or continue).
2020-06-28 15:07:34 +02:00
Aleksander Morgado c4d82aaf1e base-modem,at: improve documentation on response processor methods 2020-06-28 15:07:34 +02:00
Aleksander Morgado accd1a5841 base-modem: define new helper MMBaseModemAtCommandAlloc
It has the same exact format as MMBaseModemAtCommand, but its contents
are assumed heap allocated.

The only real purpose of this type is to allow defining static
constant MMBaseModemAtCommand variables without warnings when using
-Wdiscarded-qualifiers.
2020-01-31 15:18:35 +01:00
Aleksander Morgado c0e1bde03e base-modem-at: avoid using MM_CORE_ERROR_CANCELLED 2019-10-11 07:27:59 +00:00
Aleksander Morgado 6dc6a825b3 base-modem-at: don't ignore allow_cached flag in first command in sequence 2019-05-18 16:00:28 +02:00
Ville Skyttä 90b89bb9f4 *: Spelling fixes 2018-01-25 09:52:12 +01:00
Aleksander Morgado d4dfd661b9 port-serial-at: use GIO Async API like methods 2014-02-13 13:40:21 +01:00
Aleksander Morgado 6f235b9948 ports: rename 'MMAtSerialPort' to 'MMPortSerialAt' 2014-02-13 13:40:01 +01:00
Aleksander Morgado 9cde02111b ports: rename 'MMSerialPort' to 'MMPortSerial' 2014-02-13 13:39:51 +01:00
Aleksander Morgado d593116d68 base-modem: don't run port init sequence if we're just sending a command
This may happen when sending commands to the modem while in non-enabled state,
like when sending the PIN. In this case, just send the command, don't fully
initialize the port with the initialization sequence.
2013-02-18 16:06:18 +01:00
Aleksander Morgado 5978258d85 base-modem-at: handle NULL responses from the serial parsing in sequences 2012-10-22 12:33:19 +02:00
Aleksander Morgado 4fe7c7d637 base-modem-at: new `mm_base_modem_at_command_raw()'
Equivalent to `mm_base_modem_at_command()', but with a raw setup.
2012-08-24 12:32:29 +02:00
Aleksander Morgado d18dbb869a base-modem-at: add 'raw' handling to `mm_base_modem_at_command_full()' 2012-08-24 12:32:29 +02:00
Aleksander Morgado d9ea4a304c at-serial-port: allow sending 'raw' commands
Commands treated as 'raw' won't get the 'AT' prefix and will also not get the
trailing carriage return.
2012-08-24 12:32:28 +02:00
Aleksander Morgado b8e5dbcaf4 novatel: flip secondary ports to AT mode during port setup 2012-08-20 16:26:55 +02:00
Aleksander Morgado cdd339f802 base-modem: implement new modem-wide cancellable, and rework AT commands
Instead of the `_in_port()' variants, we'll provide more generic
`_full()' methods. These should be used either if we want to send commands
to a specific port, or if we want to use a specific user-provided GCancellable.

In addition to this user-provided GCancellable, we keep the internal modem-wide
one.
2012-03-16 14:53:23 +01:00
Aleksander Morgado 7bfc56c2a8 base-modem-at: set error if NULL port detected
Users of mm_base_modem_at_command_in_port() can now directly pass the result
of mm_base_modem_peek_port_primary() or mm_base_modem_peek_port_secondary(),
which may be NULL if no such port exists in the modem. So we'll gracefully
detect the NULL port and complete the async operation with an error.
2012-03-16 14:53:23 +01:00
Aleksander Morgado cc6d4a97fb base-modem: new port getters and peekers
* mm_base_modem_peek_port_* () will return either a port object (no new
reference), or NULL if none available.

You would usually peek() a port if you're going to use it just in the current
method, as there is no way to that reference to get invalid (we're single
threaded).

 * mm_base_modem_get_port_* () will return either NEW references to valid
port objects, or NULL if none available.

And, you would usually get() a port, whenever you want the port object to be
valid even out of the current method, for example when keeping it in the
context of an async operation.

Also, we need to consider that the primary AT port MAY BE NULL when you
peek() or get() it. This is due to the fact that we may be releasing ports
(due to device disconnection) in the middle of async operations.
2012-03-16 14:53:23 +01:00
Aleksander Morgado ef2b1cf030 at-serial-port: allow cancelling the response timeout 2012-03-16 14:53:22 +01:00
Dan Williams cb2d6d6105 base-modem-at: indicate sequence status to response parsers
Let parsers know if this command is the last in a sequence since
they may want to handle errors differently if that's the case.
2012-03-15 14:14:48 +01:00
Aleksander Morgado 7b884c4635 base-modem-at: always unref the modem object in AT command/sequence contexts 2012-03-15 14:14:44 +01:00
Aleksander Morgado 94846a2f51 base-modem: make public the method to get best AT port
Sometimes, we want to check whether a given port is available to send commands,
and fallback to some other method if so (e.g. using a QCDM port).
2012-03-15 14:14:43 +01:00
Aleksander Morgado e4486fd5f0 base-modem: store the AT sequence context GDestroyNotify callback 2012-03-15 14:14:41 +01:00
Aleksander Morgado 52db9b9035 base-modem-at: refactor AT sequence/command handling
Make a tight connection between the action of sending AT commands, either single
or in a sequence, with the MMBaseModem object owning the port. This direct
relation allows sending commands without specifying which port to use, so that
the modem object can get the best port at each time, and handling all that in a
single common place.

The original mm-at API has also been modified so that when a single command is
sent, a constant string is returned. We are allowed to return constant strings
in mm_base_modem_at_command_finish() because the string itself is owned by the
GSimpleAsyncResult, and hence, alive enough time. The GSimpleAsyncResult is
completely disposed only after the async call is fully completed.

Same reasoning behind the GVariant returned in the AT sequences; it should not
be owned by the caller, it's a transfer-none in introspection terms.
2012-03-15 14:14:31 +01:00