Detection of whether a SIM card is inserted or not

Is there a way (for scripting) to detect if a SIM card is inserted or not?
Scenario: If SIM card is removed, do this and that …

I would check native Situations app for that.

Maybe Dbus can help?

busctl introspect  org.ofono /ril_0 org.nemomobile.ofono.SimInfo
NAME                         TYPE      SIGNATURE RESULT/VALUE FLAGS
.GetAll                      method    -         isss         -
.GetCardIdentifier           method    -         s            -
.GetInterfaceVersion         method    -         i            -
.GetServiceProviderName      method    -         s            -
.GetSubscriberIdentity       method    -         s            -
.CardIdentifierChanged       signal    s         -            -
.ServiceProviderNameChanged  signal    s         -            -
.SubscriberIdentityChanged   signal    s         -            -

You could listen for the CardIdentifierChanged signal for example.

1 Like

This gives me (on XA2 SFOS 4.0.15) the same output for ril_1, but I have only one SIM inserted, the other slot has an SD card.
But /usr/bin/dbus-send --system --print-reply --dest=org.ofono /ril_0 org.ofono.NetworkMonitor.GetServingCellInformation returns something when registered, otherwise not.

Thanks to all for the input. 'will try that after this busy time :slight_smile:

Just to piggyback on this… ril_0 and ril_1 are the two SIM slots? so sub ril_1 in dbus-send --system --print-reply --dest=org.ofono /ril_0 org.ofono.MessageManager.SendMessage string:“005552222” string:“Hej world” means it will send with the other SIM?

It should, however see: Starting sms with dbus-send stopped working on 4.6

1 Like

Ah, I got that working by adding defaultuser to the radio group ( usermod -a -G sailfish-radio defaultuser ) but also notice my SMS app had broken because it was doing to old command where I had sudo running the dbus-send command. I took that away and everything worked again.

2 Likes