Cm sim storepin

I have a sim with a pin code and have saved the pin to secure storage with “cm sim storepin pin”
On boot the sim status is “inserted and locked (LE_SIM_INSERTED)”.

The documentation suggests that the pin is automatically read from secure storage on boot.
That is not happening here, the sim remains locked until unlocked manually.

I have read that the secure storage starts a timer which counts up to 300 before completing a backup, but I have tried leaving this for over 10 minutes after issuing “cm sim storepin pin” but it never manages to unlock automatically.

Using the cellnet api I can confirm that the pin is being stored in the secure storage, but it is not being applied.

This can be done manually in the app, the issue is that it is supposed to be automatic.

For anyone else who stumbles across this same issue:

Include the le_cellnet api and the le_sim api in the cdef file.

    api:
    {
        le_cellnet = le_cellnet.api
        le_sim = le_sim.api		
    }

Bind the api’s in the adef file.

    bindings:
    {
        your_project.your_component.le_cellnet -> cellNetService.le_cellnet
        your_project.your_component.le_sim -> modemService.le_sim
    }

And then in the COMPONENT_INIT do the following:

    char pin[8]={0,0,0,0,0,0,0,0};
    le_cellnet_GetSimPinCode(LE_SIM_EXTERNAL_SLOT_1,pin,sizeof(pin));
    le_sim_EnterPIN(LE_SIM_EXTERNAL_SLOT_1,pin);

I welcome any cleaner solutions.

Hello Shane,

Can you please tell if before:
cm sim storepin pin
you also run:
cm sim select EXTERNAL_SLOT_1

KR,
flu

I do not explicitly tell it to use EXTERNAL_SLOT_1 because it uses that by default - as reported by cm sim info.

I just performed a test as per your recommendation.

cm sim select EXTERNAL_SLOT_1
cm sim storepin xxxx
reboot

And sim is unlocked automatically as it is supposed to be.

Edit:
My app was still running performing the unlock manually.
I Just checked with my app removed and the sim status is still locked on reboot.

hi @shib,
an internal investigation is on going for this issue,
keep you inform on any progress,
BR

Hello @shib

If useful, please note that there is an additional workaround:

Call “Ref = le_cellnet_Request()” from your Legato Application.
This will trigger the load of the SIM PIN from the secure storage.

KR.

Hello Shane,

Here is the solution to this defect:

--- a/[components/cellNetService/cellNetServiceServer.c]
+++ b/[components/cellNetService/cellNetServiceServer.c]

@@ -917,6 +917,13 @@ COMPONENT_INIT

le_wdogChain_Init(1);

le_wdogChain_MonitorEventLoop(0, watchdogInterval);

+ // Try to load SIM PIN from secstore

+ le_sim_Id_t sim = le_sim_GetSelectedCard();

+ if (le_sim_IsPresent(sim))

+ {

+ LoadSimFromSecStore(sim);

+ }

+

LE_INFO("Cellular Network Server is ready");

}

KR.