Watching for available SIMs on D-Bus

Ladislav Michl ladis at linux-mips.org
Sat Jul 20 11:02:42 UTC 2019


Hi Aleksander,

and apologize for late reply...

On Mon, May 06, 2019 at 01:01:34PM +0200, Aleksander Morgado wrote:
> Hey,
> 
> > I need to collect informations about modems (for IMEI) and SIM cards
> > (for IMSI) available to system over D-Bus.
> >
> > While listening to signal InterfacesAdded on interface
> > org.freedesktop.DBus.ObjectManager does work as mentioned in
> > documentation, ie. returning properties on newly discovered modem,
> > I cannot get this work for SIm cards. Here listening to
> > PropertiesChanged for both Modem or SIM interface does not
> > return anything. Current "solution" is to look at SIM object
> > path after while, which gets SIM a chance to be discovered,
> > but I would prefer to know how to implement it "the right
> > way" (tm).
> >
> 
> The "manager" object in ModemManager implements
> org.freedesktop.DBus.ObjectManager but ONLY for modem objects. This
> means that the ObjectManager interface only notifies about
> added/removed interfaces in modem objects.
> 
> Once you have the path for an existing modem object with a
> "org.freedesktop.ModemManager1.Modem" interface, you should then
> monitor the "Sim" property in that interface, which will give you the
> DBus path to the SIM object available in the modem.

Well, perhaps I didn't make above clear. I'm waiting for Modem object
to appear on the bus, which works reliably. Once it appears I'm hooking
"PropertiesChanged" on it which also works as you indicated above.
Here "Sim" property is also available and object it points to does not
emit changes [*]. So once new modem appears on the bus, its Sim
property contains valid path to Sim object, but Imsi property of that
object is empty at that time. However, asking again after some time gives
expected result.

> It is "guaranteed" by the implementation that the SIM path does NOT
> change in the same modem object, though. If for any reason the SIM is
> ejected and changed, the actual modem object will be completely
> re-created and the modem object path will also change.

A side question: Once ModemManager is restarted all the hooks to
"PropertiesChanged" has to be destroyed using "NameOwnerChanged" 
onInterface "org.freedesktop.DBus" and then created again using
"InterfacesAdded" of "org.freedesktop.DBus.ObjectManager" to get
internal application state into sync with ModemManger. Is that
correct or does some more elegant shortcut exist?

[*] debug on "PropertiesChanged" of "Modem" gives:
Property UnlockRequired at org.freedesktop.ModemManager1.Modem changed
Property State at org.freedesktop.ModemManager1.Modem changed
Property State at org.freedesktop.ModemManager1.Modem changed
Property State at org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd changed
Property Enabled at org.freedesktop.ModemManager1.Modem.Location changed
Property State at org.freedesktop.ModemManager1.Modem changed
Property State at org.freedesktop.ModemManager1.Modem changed
Property RegistrationState at org.freedesktop.ModemManager1.Modem.Modem3gpp changed
Property OperatorCode at org.freedesktop.ModemManager1.Modem.Modem3gpp changed
Property OperatorName at org.freedesktop.ModemManager1.Modem.Modem3gpp changed
Property State at org.freedesktop.ModemManager1.Modem changed
Property RegistrationState at org.freedesktop.ModemManager1.Modem.Modem3gpp changed
Property Bearers at org.freedesktop.ModemManager1.Modem changed
Property State at org.freedesktop.ModemManager1.Modem changed
Property SignalQuality at org.freedesktop.ModemManager1.Modem changed
Property State at org.freedesktop.ModemManager1.Modem changed

As you can see there is no change on org.freedesktop.ModemManager1.Sim
which is probably okay, per what you wrote before, but that leaves me
with no nice solution. Suggestions?

Thank you,
	ladis


More information about the ModemManager-devel mailing list