Commit Graph

2375 Commits

Author SHA1 Message Date
Aleksander Morgado
1746949277 ports: add port initialization sequences instead of iface-modem's modem_init()
Instead of a custom modem_init() step in the 'Modem' interface, just add a
sequence of port initialization commands in each port.

While enabling for the first time a non-hotplugged modem, we will issue the
port initialization commands only after having run the enabling_modem_init()
step (i.e. after ATZ usually).
2013-02-18 13:47:35 +01:00
Aleksander Morgado
be37f41f06 at-serial-port: new properties to define and manage a set of init commands
We are now able to specify a list of AT commands to be run whenever the port is
opened for the first time (i.e. open_count from 0 to 1). These commands are
to be treated as a 'port initialization' sequence, where port-configuration
specific AT commands are defined (e.g. ATE0).
2013-02-18 13:47:35 +01:00
Aleksander Morgado
30639606d3 broadband-modem: new step during 'enabling_started' to initialize the modem
We previously had the modem initialization command merged with some other port
setup commands in the 'modem_init' step of the 'Modem' interface. Instead of
doing this, we now split the logic into two separate steps:

A first 'enabling_modem_init' modem initialization step is to be run just after
the ports have been opened, but only during the first enabling operation, and
only if the modem was not hotplugged. A hotplugged modem is assumed to be
properly initialized already, so no need to ATZ-it. Also, we will now wait 500ms
by default after the modem initialization command has been sent, to let it
settle down.

The second 'modem_init' step will be run during the 'Modem' interface
initialization, and it currently only holds specific setup of the primary and
secondary serial ports. We'll be modifying this logic a bit in the next commits,
so no big deal to have that step name unchanged.
2013-02-18 13:47:34 +01:00
Dan Williams
263be58465 serial-port: don't steal data from PPP when connected
There was a race where if PPP was slow to start, MM could read the
first bits of PPP from the port, which MM shouldn't really do.  So
if the port is connected, remove our GIOChannel watch and let pppd
handle all the data.  When the port is disconnected, re-attach our
watch and start reading from the port again.

This may make it harder to detect spurious disconnects if for example
pppd drops the connection and the thing controlling PPP (eg,
NetworkManager or something else) doesn't tell us about that event
by disconnecting the bearer.  This is arguably programmer error though.

See the logs in https://bugzilla.gnome.org/show_bug.cgi?id=624956#c10
for an example of this:

DEBUG: <1280300196.929489> (ttyACM0): <-- '<CR><LF>CONNECT<CR><LF>'
DEBUG: <1280300196.929761> (ttyACM0): port now connected
DEBUG: <1280300196.929853> Modem /org/freedesktop/ModemManager/Modems/0: state changed (connecting -> connected)
DEBUG: <1280300196.929954> (ttyACM0): simple connect state 6
DEBUG: <1280300196.933432> (ttyACM0): <-- '~\-1}#\-64!}!} } }2}#}$\-64#}!}$}%\-36}"}&} }*} } g}%~'
2013-02-15 13:43:50 -06:00
Dan Williams
5280364c4b Revert "serial-port: don't steal data from PPP when connected"
This reverts commit 625e1c4884.

By simply returning when data is available, no data gets cleared
from the file descriptor and data_available() keeps getting
rescheduled, leading to a busy-loop.  This is the wrong approach,
we should be removing the GIOChannel watch instead.
2013-02-15 13:43:49 -06:00
Ben Chan
85b67ed8d9 modem: use +CEREG to determine EPS network registration status
This patch adds the support for solicited/unsolicited EPS network
registration status via AT+CEREG, which is configurable via the
'iface-modem-3gpp-eps-network-supported' property of the
MMIfaceModem3gpp interface and is disabled by default.
2013-02-15 08:53:45 +01:00
Dan Williams
594adc38ff broadband-modem: don't try QCDM access technology checks for non-QCDM 3GPP devices
Result handling code mistakenly ran for these devices, when it shouldn't.
2013-02-14 14:52:23 -06:00
Aleksander Morgado
29c0560a9a broadband-modem-qmi: don't try to load access technologies using QCDM 2013-02-14 17:43:54 +01:00
Aleksander Morgado
914cda5de3 bearer-qmi: wait longer for the 'Stop Network' reply
The 'Stop Network' reply may really take more than 10s to arrive; so let's wait
some more time, 30s, before falling back.
2013-02-14 10:47:14 +01:00
Dan Williams
2d700043ab core: use g_unix_signal_add() for more reliable Unix signal handling
There were a few problems with MM's existing signal handling, first
of which was that calling g_main_loop_quit() from a signal handler
only works 50% of the time due to severe restrictions on what you
can do from the handler.  This caused INT or TERM to sometimes be
ignored by MM.

Instead, use the glib signal functions which ensure that the handler
is run in the right context, where we can do anything we want.
2013-02-12 15:48:39 -06:00
Dan Williams
625e1c4884 serial-port: don't steal data from PPP when connected
There was a race where if PPP was slow to start, MM could read the
first bits of PPP from the port, which MM shouldn't really do.  So
if the port is connected, don't read any data and let pppd do its
thing.

See the logs in https://bugzilla.gnome.org/show_bug.cgi?id=624956#c10
for an example of this:

DEBUG: <1280300196.929489> (ttyACM0): <-- '<CR><LF>CONNECT<CR><LF>'
DEBUG: <1280300196.929761> (ttyACM0): port now connected
DEBUG: <1280300196.929853> Modem /org/freedesktop/ModemManager/Modems/0: state changed (connecting -> connected)
DEBUG: <1280300196.929954> (ttyACM0): simple connect state 6
DEBUG: <1280300196.933432> (ttyACM0): <-- '~\-1}#\-64!}!} } }2}#}$\-64#}!}$}%\-36}"}&} }*} } g}%~'
2013-02-12 15:26:21 -06:00
Dan Williams
18436a8f77 iface-modem-messaging: fix INSTANCE_CAST() vs. GET_INTERFACE() confusion
Yeah, GObject is pretty obscure here.  But to get the implementation's
override function, we want GET_INTERFACE, otherwise we're looking at
some random memory location that's sometimes NULL.  And then we crash.
2013-02-06 15:50:22 -06:00
Dan Williams
dcbb6dc811 iface-modem-cdma: fix handling of HDR registration state
hybrid mode is the first parameter, not the third.  Caused EVDO
to look like it wasn't registered.
2013-02-06 11:57:00 -06:00
Dan Williams
8070627011 trivial: add debugging to generic QCDM registration parsing 2013-02-06 11:57:00 -06:00
Dan Williams
b9d0a3275f trivial: debug print CDMA1x State results 2013-02-06 11:57:00 -06:00
Ben Chan
24b28d1a72 iface-modem: add a missing step increment in interface_initialization_step 2013-01-30 23:11:51 +01:00
Ben Chan
c204a8ce4e iface-modem: rearrange initialization steps
This patch rearranges the initialization steps in MMIfaceModem such that
the following SIM related operations happen at the end of the
initialization:
    - INITIALIZATION_STEP_UNLOCK_REQUIRED
    - INITIALIZATION_STEP_SIM
    - INITIALIZATION_STEP_OWN_NUMBERS

The rationale of this change is that the SIM interface of some modems
may require some time to initialize before it responds to SIM related
AT commands. By rearranging the initialization steps to execute non-SIM
related AT commands first, some of the latency for the SIM
initialization can be absorbed.
2013-01-24 13:37:52 +01:00
Ben Chan
69aff6183a iface-modem: fix invalid modem state consolidation
ModemManager has a bogus modem state transition from 'enabling' to 'disabled':

ModemManager[26214]: <info>  Modem fully enabled...
ModemManager[26214]: <info>  Modem /org/freedesktop/ModemManager1/Modem/2: state changed (enabling -> disabled)

The root cause seems to be the following:

get_current_consolidated_state() in MMIfaceModem returns
MM_MODEM_STATE_DISABLED as the default fallback value. When
mm_iface_modem_update_state() is invoked to transition the modem state from
MM_MODEM_STATE_ENABLING to MM_MODEM_STATE_ENABLED, the following code can
potentially cause the final state to be MM_MODEM_STATE_DISABLED instead.

     /* Enabled may really be searching or registered */
     if (new_state == MM_MODEM_STATE_ENABLED)
         new_state = get_current_consolidated_state (self);

https://code.google.com/p/chromium-os/issues/detail?id=38173
2013-01-24 09:08:44 +01:00
Aleksander Morgado
9d5794e9e4 iface-modem: print power state as string
Thanks to Marius B. Kotsbak <marius@kotsbak.com> for reporting.
2013-01-21 10:33:49 +01:00
Ben Chan
1cf8ccbdd5 iface-modem: schedule signal quality check more often initially
This patch modifies MMIfaceModem to schedule the periodic signal quality
check with a period of 3s instead of 30s (up to 5 periods) initially
until a non-zero signal quality value is obtained and then switch back
to the 30s period.
2013-01-18 11:28:08 +01:00
Ben Chan
e75dba639f core: add 'hotplugged' flag to indicate if modem is newly plugged in
This patch adds a 'hotplugged' flag to MMBaseModem to indicate if a
modem is newly plugged in. A plugin can use this information to
determine if, for example, the modem needs to be soft reset using the
ATZ command.

Dan Williams <dcbw@redhat.com> contributed the idea of implementation.
2013-01-18 11:27:51 +01:00
Dan Williams
fdad4d636d broadband-modem: guess CDMA access technologies from registration state
Setting access technologies from registration state as part of the
registration checking in the CDMA Interface code fights with
custom implementations in each modem subclass, which causes the
access technologies to ping-pong between more specific (custom
implementation) and less specific (generated from registration state
during registration checking).  If the modem class has more
specific access technology knowledge, we should use that and not
override it on the next registration state poll.

So instead, implement the generic access technology update from
registration state in the broadband modem base class'
load_access_technologies() hook.  Thus, modem classes with more
specific checking (which override MMBroadbandModem's implementation)
will never fight with generic checking, while modems that don't
(and thus actually need the generic checking) still get some basic
access technology handling.
2013-01-14 13:50:27 -06:00
Dan Williams
edeb75b028 broadband-modem: implement generic QCDM access technology checks
For modems that don't implement vendor-specific access technology
checks, try to get the access technology via QCDM if the modem has
a QCDM port.
2013-01-14 13:50:27 -06:00
Dan Williams
f71852c5b9 iface-modem-cdma: get CDMA1x Serving System during QCDM registration
We want the SID/NID even when AT Serving System checks are disabled,
otherwise the SID/NID don't get filled at all.  QCDM doesn't need the
SID/NID to determine registration, so the values are informational
only and don't affect registration state.  But we still want to
export them via the API.
2013-01-14 13:50:27 -06:00
Dan Williams
fe7438973a trivial: fix comment 2013-01-14 13:50:27 -06:00
Dan Williams
01e8e0574f broadband-modem: more compatible CSQ parsing
Some devices (usually CDMA modems like the Sierra MC5725 and others)
don't prefix their +CSQ replies with +CSQ.  So don't require that.
The scanf() should ensure the reply is valid even without the +CSQ.
2013-01-14 13:50:26 -06:00
Dan Williams
f95274e735 broadband-modem: load own numbers with QCDM too
Not many CDMA/EVDO-only modems support CNUM since it's not a
standard IS707/856 AT command, so for those that don't
support it and have a QCDM port, try grabbing the number from
NV memory.
2013-01-14 13:50:26 -06:00
Aleksander Morgado
8403a48b31 plugin-manager: new debug logs to help track probing issues 2013-01-11 12:20:57 +01:00
Aleksander Morgado
eec5d00a97 core,plugins: remove initial power down sequence
We no longer power down the modem during initialization, so remove that
implementation.
2013-01-11 10:05:46 +01:00
Aleksander Morgado
952d96234b broadband-modem: implement custom power state loading 2013-01-11 10:05:45 +01:00
Aleksander Morgado
696b879b6d broadband-modem-qmi: implement custom power state loading 2013-01-11 10:05:45 +01:00
Aleksander Morgado
e55b543d38 iface-modem: implement power mode loading and setting 2013-01-11 10:05:45 +01:00
Dan Williams
f50aa47fb2 sim-qmi: fix trivial GError literal issues/format string warnings 2013-01-10 10:09:35 -06:00
Aleksander Morgado
763e207e9c blacklist: ignore all devices from VID 0x0617
No modems from the Swiss Federal Institute of Technology.

https://bugzilla.gnome.org/show_bug.cgi?id=691384
2013-01-09 10:05:15 +01:00
Aleksander Morgado
dc7aa25f0a sim-qmi: translate common SIM-related QMI errors into ME errors
Upper layers expect Mobile Equipment errors, so try to translate known QMI
protocol errors.
2013-01-08 18:40:48 +01:00
Aleksander Morgado
1372933345 iface-modem,sim: improve lock info update logic
The logic to handle the lock information (current lock and unlock retry count)
wasn't handling all possible cases properly, e.g.:

 * When PIN is incorrectly entered too many times, a SIM-PUK error may happen.
   In this case we need to directly assume SIM-PUK is the current lock (some
   modems, like Option HSO ones, would incorrectly reply SIM-PIN if CPIN? asked
   just after the SIM-PUK error).

 * After every operation acting in SIM locks, we need to update the current
   unlock retry count.

This change tries to cover those cases, by:

 * The logic to check current lock is extended to also load the unlock retry
   count when needed.

 * Whenever a SIM-PUK error happens in the SIM operations, we directly assume
   that SIM-PUK is required, without re-asking CPIN?.

 * The overall logic of lock checking is now handled by a state machine, which
   is much easier to understand.
2013-01-08 18:40:47 +01:00
Aleksander Morgado
959bb9d2ff broadband-modem: launch the Firmware interface even on fatal errors
Even when there is a fatal error during initialization (e.g. missing PIN in a
3GPP modem), we should allow operations on the Firmware interface.
2013-01-07 22:25:46 +01:00
Ben Chan
e939221975 iface-modem, novatel-lte: disable network scan in LTE mode 2013-01-04 12:10:51 +01:00
Ben Chan
bc399d9cf8 iface-modem-3gpp,iface-modem-cdma: check for deallocated RegistrationCheckContext
This patch fixes a crash in periodic_registration_checks_ready() due to
access of an already deallocated RegistrationCheckContext.

Thread 0 *CRASHED* ( SIGSEGV @ 0x00000000 )

0x7fc344d355cd   [ModemManager]             - mm-iface-modem-cdma.c:1112   periodic_registration_checks_ready
0x7fc3449ea266   [libgio-2.0.so.0.3200.4]   - gsimpleasyncresult.c:767     g_simple_async_result_complete
0x7fc3449ea368   [libgio-2.0.so.0.3200.4]   - gsimpleasyncresult.c:779     complete_in_idle_cb
0x7fc344851dc4   [libglib-2.0.so.0.3200.4]  - gmain.c:2539                 g_main_context_dispatch
0x7fc344852147   [libglib-2.0.so.0.3200.4]  - gmain.c:3146                 g_main_context_iterate
0x7fc3448525a1   [libglib-2.0.so.0.3200.4]  - gmain.c:3340                 g_main_loop_run
0x7fc344d0f154   [ModemManager]             - main.c:158                   main
0x7fc34426a474   [libc-2.15.so]             - libc-start.c:234             __libc_start_main
0x7fc344d0eb68   [ModemManager]             + 0x0001bb68
2013-01-03 22:28:34 +01:00
Aleksander Morgado
1b0ab2ea60 broadband-bearer: dial port may be different to the primary port 2012-12-28 08:00:04 +01:00
Aleksander Morgado
731812fe34 plugin: avoid QMI-managed net ports when compiling without QMI support 2012-12-27 13:51:28 +01:00
Aleksander Morgado
80b68ac0ae plugin-manager: initially never start with the Generic plugin suggested
The generic plugin should be a fallback, so when starting to probe the port,
never start with the Generic plugin first.
2012-12-27 12:44:50 +01:00
Aleksander Morgado
ef31ff7535 broadband-bearer: PDP context deactivation may take longer
Update the default timeout from 3s to 10s.
2012-12-27 08:58:39 +01:00
Aleksander Morgado
c8fcf7a91d plugin: re-run subsystems filter before grabbing the ports
Every port probing will have the Generic plugin as fallback, and due to some
other issues in other plugins (see ee099fcd), we need to allow overwriting the
suggested plugin from the Generic to a more specific one.

One of the drawbacks of this is that we're actually allowing the Generic plugin
to probe and accept the port, which means that the generic plugin may accept a
specific port type (e.g. QMI) while the specific plugin wouldn't. So, we will
now also run the subsystems filter before grabbing the specific port, in order
to really filter out those cases. We still keep the subsystems filter in
pre-probing, so that we build a better initial plugin list to probe.
2012-12-27 08:53:45 +01:00
Aleksander Morgado
f923e95861 base-modem: don't set the modem valid if we didn't export the Modem interface
If an error occurs early during the initialization (e.g. during port setup), we
would be aborting without even having exported the modem interface. So detect
that case and skip setting the modem as valid.
2012-12-27 08:48:11 +01:00
Aleksander Morgado
4d4ea9c369 iface-modem-location: fix periodic reporting of the GPS location info
The Location property was never being updated properly.
2012-12-24 18:57:39 +01:00
Aleksander Morgado
850a7737b8 broadband-modem: fix reloading of operator code when enabling 3GPP location
When the 3GPP location is enabled, we need to reload the operator code
information, but only if the modem is registered in a 3GPP network.

Now, instead of looking at the global modem state value, look at the specific
3GPP registration state. This will avoid issues like:
 * updating 3GPP operator info and the modem registered in a CDMA network.
 * not updating the 3GPP operator info when the modem is registered in a 3GPP
   network but not yet fully enabled (i.e. 'enabling').
2012-12-24 15:54:37 +01:00
Anton Blanchard
0380045aac ModemManager: Blacklist Dangerous Prototypes Bus Pirate v4
The Bus Pirate v4 presents itself as a CDC ACM device which
ModemManager attempts to configure. This results in a range
of confusing issues because it injects a bunch of AT commands
over whatever is going on at the time.

Firmware updates were failing at random points and avrdude
failed to work at all. Blacklisting it fixed my issues.
2012-12-23 16:55:27 +01:00
Aleksander Morgado
dc9bbefbc0 icera,hso: don't wait to get connected if the primary port is removed
If the primary port is gone (e.g. when going to sleep) and we are just in the
middle of a connection attempt, we won't be able to receive any unsolicited
message regarding the status of the attempt. So, if we detect that the port is
forced to get closed, we'll just treat it as a connection failure.

http://code.google.com/p/chromium-os/issues/detail?id=35391
2012-12-12 12:56:47 +01:00
Aleksander Morgado
f20922ba9d bearer: check if signal handler is connected before trying to disconnect it
Avoids warnings like:
GLib-GObject-WARNING **: gsignal.c:2576: instance `0x78624028' has no handler with id `148'
2012-12-12 12:55:33 +01:00