Commit Graph
60 Commits
Author SHA1 Message Date
Aleksander Morgado fa0cfd4c4d base-sim: include GID1/GID2 loaded values in info level 2022-11-04 13:12:58 +00:00
Aleksander Morgado ceee8938e8 base-sim: decrease severity of logs that don't affect functionality
Instead of warning about various unimportant things failing that don't
affect functionality, just print the logs in debug level and go on.

E.g. this warning can be completely skipped:
 <wrn> [modem0/sim0] couldn't load GID2: Couldn't read data from UIM: QMI protocol error (16): 'NotProvisioned'
2022-11-04 13:12:58 +00:00
Aleksander Morgado 20390488dd base-sim: improve logging during initialization
We will print all the loaded SIM contents, treating as personal info
the SIM ICCID, IMSI and EID.
2022-11-04 13:12:57 +00:00
Aleksander Morgado b3f315ad2d core,log: new 'MSG' log level between 'INFO' and 'WARN'
We're bumping the current "INFO" level messages to the new "MSG"
level, also making the new level the default.

The old "INFO" level will be used to setup an intermediate level of
logging which is not as verbose as "DEBUG" but still provides some
capabilities to analyze the behavior of a modem.
2022-11-04 13:12:56 +00:00
Aleksander Morgado 823f3e7995 base-sim: fix length when reading GID1/GID2
We were attempting to read 15 bytes unconditionally, regardless of the
size of the EF_gid1 and EF_gid2 files.

This operation would succeed in some SIM cards even if the actual file
lengths are shorter:

  AT+CRSM=176,28478,0,0,15
  +CRSM: 144,0,"FFFF"
  OK

But the operation would fail in some other SIM cards due to the length
mismatch:

  AT+CRSM=176,28478,0,0,15
  +CRSM: 103,0
  OK

Using 0 as requested length instructs the modem to read the length
specified in the EF status information, which is also the same
approach we do in QMI and MBIM.

  AT+CRSM=176,28478,0,0,0
  +CRSM: 144,0,"FFFF"
  OK
2022-11-03 23:42:48 +00:00
Aleksander Morgado 1532545efa base-sim: fix loading GID2
We were not even trying to load it if GID1 was successfully loaded.
2022-10-27 11:22:16 +02:00
Aleksander Morgado fa6d64550b base-sim: implement GID1 and GID2 loading using AT commands 2022-09-30 13:51:56 +00:00
Aleksander Morgado f61061044b base-sim: add steps to load GID1 and GID2 during init 2022-08-19 15:53:43 +00:00
Aleksander Morgado 0123030136 iface-modem: skip setting up carrier config on esim without profiles 2022-05-25 11:14:40 +02:00
Aleksander Morgado a535b2fddc base-sim: skip loading SIM identifier in eSIM without profiles 2022-05-25 11:14:37 +02:00
Aleksander Morgado 638841281e base-sim: disallow SIM user operations in eSIM without profiles 2022-05-25 11:14:34 +02:00
Aleksander Morgado 38a69011bd base-sim: skip loading SIM properties based on SIM type
If the reported eSIM doesn't have profiles, there is no point in
trying to load properties like ICCID, IMSI or operator name/id.

If the reported SIM is a physical SIM, there is no point in trying
to load properties like EID or eSIM status.
2022-05-25 11:14:03 +02:00
Aleksander Morgado 1b30d10ad1 base-sim: don't reload properties that may have been already initialized
If we created the SIM objects during the SIM slots processing, we
should not attempt to reload the settings that were already set during
the re-initialization, as that may end up clearing the initial
properties.
2022-05-25 10:59:17 +02:00
Aleksander Morgado ac3f9be3d3 base-sim: remove bogus comments in initialization
All properties loaded during initialization are meant to be loaded
only once, no point in saying that for each property.
2022-05-25 10:59:17 +02:00
Aleksander Morgado b497de325a iface-modem: common SIM event reporting logic
We no longer have separate mm_base_modem_process_sim_event() and
mm_broadband_modem_sim_hot_swap_detected() methods. The only
difference between both of them was that one of them would attempt to
cleanup the ports context associated to the SIM hot swap event logic
as soon as a swap was detected, in order to avoid queueing up multiple
such events.

The previous logic wasn't working well, though, as there could be
mixed AT+QMI or AT+MBIM devices that would also require that same
cleanup and so we didn't always know which one should have been
called.

Now we have a single mm_iface_modem_process_sim_event() method, which
will trigger the reprobe and disabling, but which will also perform
the cleanup of the SIM ports swap setup as specified by the
implementation.

So, if a plugin explicitly initializes the serial ports context for
SIM hot swap handling, it should also explicitly clean it up.

Also, the initialization of the serial ports context for SIM hot swap
handling is no longer done automatically for all modems, it will be
done only for those modems using it; i.e. the modems that explicitly
report support SIM hot swap handling using AT URCs.
2022-05-20 09:03:54 +00:00
Aleksander Morgado 83ebc2b4a8 base-sim: new 'SimType', 'Removability' and 'EsimStatus' properties
We implement the methods to load the properties during SIM object
initialization.
2021-12-11 12:53:37 +01:00
Aleksander Morgado 8cfddef2be base-sim: reorder init ready() methods
The ready() methods for each step in the initialization sequence must
be ordered from bottom to top, so that we can read the logic in that
same order.
2021-12-11 12:53:37 +01:00
Michal Mazur c6b5045105 base-sim: ignore personalization locks after SIM unlock 2021-05-22 23:56:22 +00:00
Aleksander Morgado e0a6d5d76b base-sim: allow disabling CPOL based preferred networks features 2021-03-12 12:41:35 +01:00
Teijo Kinnunen 82a9f16fa4 base-sim: select the desired format for loading preferred networks
Before invoking AT+CPOL? for loading preferred networks list from
SIM, AT+CPOL=,2 is executed to make sure that the returned
operator codes are in expected (numeric) format.
2021-03-12 09:32:35 +02:00
Teijo Kinnunen 8b1ae5afab modem-helpers,mm-base-sim: Sim.SetPreferredNetworks AT implementation
Implement Sim.SetPreferredNetworks method by using the AT+CPOL command.
2021-03-09 16:33:45 +01:00
Teijo Kinnunen 66e93751b8 api,sim: add new Sim.SetPreferredNetworks method
This commit includes D-Bus processing and documentation, but not any
modem access implementation.
2021-03-09 08:52:55 +02:00
Teijo Kinnunen 72d753ba83 base-sim: select PLMN list before reading preferred networks
Before reading preferred network list with AT+CPOL?, AT+CPLS=0 is
now invoked first to make sure that the correct PLMN list (i.e.
user-defined) is selected.
2021-03-09 08:52:55 +02:00
Teijo Kinnunen 816beeffcb libmm-glib,modem-helpers,mm-base-sim: implement Sim.PreferredNetworks
The ModemManager1.Sim.PreferredNetworks property contains the preferred
networks (and access technologies, if available) configured to the
SIM card.

This commit implements preferred networks reading with AT+CPOL.
2021-02-26 12:28:01 +01:00
Aleksander Morgado 033e174e44 charsets: make charset_gsm_unpacked_to_utf8() private
Use the generic mm_modem_charset_bytearray_to_utf8() instead.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 5ce97abd73 charsets: make translit optional in gsm_unpacked_to_utf8()
Until now, this method would automatically apply transliteration;
i.e. replacing characters with '?' when no direct translation was
available.

We can attempt to do that transliteration on strings that are not
critical, e.g. the operator name reported by the network. But we
should not do that on other types of strings, e.g. on SMS contents
that may really have additional purposes than just being
human-readable.

This commit makes the transliteration option to be explicitly
requested by the caller.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 34de613dea libmm-glib,common-helpers: make hexstr2bin() return a guint8 array
It makes much more sense than returning a gchar array, as gchar is
signed.
2021-02-23 11:35:11 +00:00
Aleksander Morgado a211981d4a libmm-glib,common-helpers: make hexstr2bin() accept input string length
Optionally given explicitly, and -1 can be used to assume it's
NUL-terminated.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 657cabcfce libmm-glib,common-helpers: make hexstr2bin() return a GError
This util method checks whether the input string is a valid hex
string, so make sure we return a GError on failure.
2021-02-23 11:35:11 +00:00
Pavan Holla 1f0c04644d base-sim: Reprobe modem if puk lock is discovered after sending pin1
Enabling/Disabling/Changing/Sending the PIN1 lock is usually limited to
3 retries. If these attempts are exhausted, the modem is puk_locked.
We reprobe the modem to get rid of any unwanted interfaces and move
to a locked state.
2020-11-26 08:53:14 +00:00
Pavan Holla 38f6704fa1 base-sim: Reprobe modem if lock status cannot be read after sending puk
If the lock status cannot be read during a puk unblock attempt, reprobe
the modem. It is likely that the SIM was permanently blocked if the lock
status cannot be read.
2020-11-26 08:53:14 +00:00
Eric Caruso e24a8240cb mm-shared-qmi: load EID during SIM slot loading
SIMs can be created with an EID fetched during load_sim_slots
while initializing the modem, if present.

Since load_eid would be implemented with the same mechanism
we avoid using it here (if Get Slot Status fails once, it
probably doesn't make a lot of sense to try it again).
2020-10-19 20:38:43 +00:00
Eric Caruso 9fca046780 mm-base-sim: add EID D-Bus property
This provides a new D-Bus property on the Sim object that
exposes the EID of the SIM, if available.
2020-10-19 20:38:43 +00:00
Aleksander Morgado b2979c63eb base-sim: allow explicit wait for SIM readiness during initialization
Before attempting to load any SIM property value, allow checking
whether the SIM is ready for operation or not.

This action is implicitly done by the "unlock required check" step
that is triggered before initializing the primary SIM card, but it
would not be done when initializing other available SIM cards.
2020-08-28 14:59:06 +00:00
Aleksander Morgado 18084f8939 base-sim: allow creating preinitialized SIM objects
The default SIM creation method will attempt to initialize the SIM
properties during the object creation.

This new method allows creating SIM objects with already known
property values, and therefore not explicitly running the
asynchronous initialization process.
2020-08-28 14:59:06 +00:00
Aleksander Morgado c999c8e9cf base-sim: new 'slot number' property
This new property helps us identify in which SIM slot the SIM card is
inserted, when multiple slots are available, in the [1,N] range.

For the single-SIM systems this value will always be '0'.

This property is not publicly exposed in DBus, it is considered an
implementation detail.
2020-08-28 14:59:06 +00:00
Aleksander Morgado 842ad4bd64 base-sim: only allow operations on active SIMs
If a SIM is inactive we cannot perform any SIM-PIN or SIM-PUK related
operation with it.
2020-08-28 14:59:06 +00:00
Aleksander Morgado 86a183778b api,sim: new 'Active' property
In preparation for the multi-SIM setup, we need a way to tell whether
a given SIM card is active or not in the system.

On systems with one single SIM slot, the available SIM card will
always be active.

On Multi-SIM Single-Standby setups we may have multiple SIM slots with
multiple SIM cards, but only one of them will be active at any given
time.

On Multi-SIM Multi-Standby setups we may have multiple SIM slots with
multiple SIM cards that may be active at the same time. E.g. the QMI
protocol allows up to 5 different active SIM cards (primary,
secondary, tertiary...).
2020-08-28 14:59:06 +00:00
Aleksander Morgado ae38106ad2 base-sim: port to use object logging 2020-04-08 16:35:09 +02:00
Aleksander Morgado 7e5af3b38d base-sim: set dbus id as soon as object is created 2020-04-08 16:35:09 +02:00
Aleksander Morgado fd052c8e58 base-sim: don't allow sending PIN/PUK if not required
This avoids issues when e.g. sending SIM-PIN while the modem is
already unlocked or when SIM-PIN is not enabled.

Under those conditions, the needlessly sent SIM-PIN unlock attempt may
fail while libmm-glib/mmcli reports a successful operation. E.g.:

  # mmcli --sim=/org/freedesktop/ModemManager1/SIM/0 --pin=3497
  successfully sent PIN code to the SIM

But in reality...

  Wed Nov 20 14:38:52 2019 daemon.debug [4254]: <debug> [1574260732.489513] Verifying PIN...
  Wed Nov 20 14:38:52 2019 daemon.debug [4254]: [/dev/cdc-wdm0] sent message...
  <<<<<< RAW:
  <<<<<<   length = 27
  <<<<<<   data   = 01:1A:00:00:0B:02:00:09:00:26:00:0E:00:02:06:00:01:04:33:34:39:37:01:02:00:06:00
  Wed Nov 20 14:38:52 2019 daemon.debug [4254]: [/dev/cdc-wdm0] sent generic request (translated)...
  <<<<<< QMUX:
  <<<<<<   length  = 26
  <<<<<<   flags   = 0x00
  <<<<<<   service = "uim"
  <<<<<<   client  = 2
  <<<<<< QMI:
  <<<<<<   flags       = "none"
  <<<<<<   transaction = 9
  <<<<<<   tlv_length  = 14
  <<<<<<   message     = "Verify PIN" (0x0026)
  <<<<<< TLV:
  <<<<<<   type       = "Info" (0x02)
  <<<<<<   length     = 6
  <<<<<<   value      = 01:04:33:34:39:37
  <<<<<<   translated = [ pin_id = 'pin1' pin_value = '3497' ]
  Wed Nov 20 14:38:52 2019 daemon.debug [4254]: [/dev/cdc-wdm0] received message...
  <<<<<< RAW:
  <<<<<<   length = 30
  <<<<<<   data   = 01:1D:00:80:0B:02:02:09:00:26:00:11:00:02:04:00:01:00:52:00:13:02:00:69:84:10:02:00:03:0A
  Wed Nov 20 14:38:52 2019 daemon.debug [4254]: [/dev/cdc-wdm0] received generic response (translated)...
  <<<<<< QMUX:
  <<<<<<   length  = 29
  <<<<<<   flags   = 0x80
  <<<<<<   service = "uim"
  <<<<<<   client  = 2
  <<<<<< QMI:
  <<<<<<   flags       = "response"
  <<<<<<   transaction = 9
  <<<<<<   tlv_length  = 17
  <<<<<<   message     = "Verify PIN" (0x0026)
  <<<<<< TLV:
  <<<<<<   type       = "Result" (0x02)
  <<<<<<   length     = 4
  <<<<<<   value      = 01:00:52:00
  <<<<<<   translated = FAILURE: AccessDenied

As we already know what the current lock status is, just abort the
user operation if the unlock operation isn't required.
2020-02-12 09:41:10 +00:00
Aleksander Morgado 634bb1caac base-sim: avoid using 'self' to refer to the modem 2020-02-12 09:41:10 +00:00
Aleksander Morgado 94025aad6c base-sim: refactor common PIN/PUK unlock operations
Keep the saved GError directly as GTask context, instead of allocating
the SendPinPukContext unconditionally.
2020-02-12 09:41:10 +00:00
Aleksander Morgado ce5689112d core,base-sim: fix warnings with -Wimplicit-fallthrough
mm-base-sim.c:1590:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
   1590 |         ctx->step++;
        |         ~~~~~~~~~^~
  mm-base-sim.c:1592:5: note: here
   1592 |     case INITIALIZATION_STEP_SIM_IDENTIFIER:
        |     ^~~~
  mm-base-sim.c:1606:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
   1606 |         ctx->step++;
        |         ~~~~~~~~~^~
  mm-base-sim.c:1608:5: note: here
   1608 |     case INITIALIZATION_STEP_IMSI:
        |     ^~~~
  mm-base-sim.c:1622:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
   1622 |         ctx->step++;
        |         ~~~~~~~~~^~
  mm-base-sim.c:1624:5: note: here
   1624 |     case INITIALIZATION_STEP_OPERATOR_ID:
        |     ^~~~
  mm-base-sim.c:1638:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
   1638 |         ctx->step++;
        |         ~~~~~~~~~^~
  mm-base-sim.c:1640:5: note: here
   1640 |     case INITIALIZATION_STEP_OPERATOR_NAME:
        |     ^~~~
  mm-base-sim.c:1654:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
   1654 |         ctx->step++;
        |         ~~~~~~~~~^~
  mm-base-sim.c:1656:5: note: here
   1656 |     case INITIALIZATION_STEP_EMERGENCY_NUMBERS:
        |     ^~~~
  mm-base-sim.c:1670:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
   1670 |         ctx->step++;
        |         ~~~~~~~~~^~
  mm-base-sim.c:1672:5: note: here
   1672 |     case INITIALIZATION_STEP_LAST:
        |     ^~~~
2020-01-30 11:59:14 +01:00
Aleksander Morgado 850c6636bf core,base-sim: fix warnings with -Wswitch-default
mm-base-sim.c: In function ‘interface_initialization_step’:
  mm-base-sim.c:1587:5: warning: switch missing default case [-Wswitch-default]
   1587 |     switch (ctx->step) {
        |     ^~~~~~
2020-01-30 11:59:14 +01:00
Aleksander Morgado 2c0281aac9 call: disallow non-emergency calls when in emergency-only state 2019-10-17 10:51:50 +02:00
Aleksander Morgado d6f9d5e9ec sim: load emergency numbers from EF_ECC 2019-10-17 10:51:50 +02:00
Aleksander Morgado 1f6c006976 api,sim: new 'Emergency Numbers' property 2019-10-17 08:31:46 +00:00
Ben Chan 07c8a2b4f6 base-sim: avoid unnecessary MM_BASE_MODEM() call on MMBaseModem object
The 'modem' field in _MMBaseSimPrivate is already a MMBaseModem object.
2019-08-29 18:40:16 +00:00
Aleksander Morgado 52aa393d40 base-sim: wrap in its own GTask the SIM id loading from the subclass
Instead of reusing the caller GTask, use a new GTask to wrap the
execution of the subclass' async method implementation.

Also, rename the _ready() methods implemented in the GObject
initialization flow so that we can use the load_sim_identifier_ready()
function name.
2017-09-04 17:59:59 +02:00