# le\_sim\_GetIMSI doesn't seem to work

**URL:** https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084
**Category:** Legato Application Framework
**Created:** [February 10, 2018, 12:31am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084 "2018-02-10T00:31:23Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [February 10, 2018, 12:31am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/1 "2018-02-10T00:31:23Z")

</div>

le\_sim\_GetIMSI doesn’t return the IMSI from the SIM, and logs says it can’t retrieve it. Command line “cm info” doesn’t show it either. This is on a WP7601, R7 Verizon software, Legato 17.11.

---

<div class="post-metadata">

### Author: ![Manikanta](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Manikanta](https://forum.legato.io/u/Manikanta)
#### Post date: [February 19, 2018, 8:37am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/2 "2018-02-19T08:37:31Z")

</div>

With the latest legato version, can able to retrieve ‘IMSI’ Value.  
root@swi-mdm9x28:~# cm sim info  
Type: EXTERNAL\_SLOT\_1  
ICCID: 8991440459006589640  
Home Network Operator: IDEA  
EID:  
IMSI: 404445900658964  
Phone Number:  
root@swi-mdm9x28:~# legato version  
18.02.0.rc1\_83ceda15f0be33aa3f626dc9ebb8be5e\_modified

Need to upgrade legato version. If still faces the issue please provide logs.

---

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [February 19, 2018, 1:54pm UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/3 "2018-02-19T13:54:50Z")

</div>

Hi @Manikanta,  
I’m assuming that the c/c++ the call le\_GetIMSI will then work, since cm is an application?

Thanks,  
Steve

---

<div class="post-metadata">

### Author: ![Manikanta](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Manikanta](https://forum.legato.io/u/Manikanta)
#### Post date: [February 20, 2018, 6:01am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/4 "2018-02-20T06:01:53Z")

</div>

Hi @EvetsMostel,  
Yes, le\_sim\_GetIMSI() will work when called from c file. But to access any API through c file, it should be created as an application. To access le\_sim\_GetIMSI() API, le\_sim.api file should be binded using the .adef file. As below

bindings:  
{  
\<executable\>.\<component\>.le\_sim → modemService.le\_sim  
}

Taken @ref: [Application Definition .adef - Legato Docs](http://legato.io/legato-docs/latest/defFilesAdef.html)  
To develop Apps, @ref: [http://legato.io/legato-docs/latest/basicApps.html](http://legato.io/legato-docs/latest/basicApps.html)

Thanks

---

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [February 20, 2018, 3:55pm UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/5 "2018-02-20T15:55:13Z")

</div>

Hi @Manikanta  
Of course, not sure how you’d do it any other way. lol

Evets

---

<div class="post-metadata">

### Author: ![CoRfr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/corfr/32/69_2.png) [@CoRfr](https://forum.legato.io/u/CoRfr)
#### Post date: [February 23, 2018, 8:24am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/6 "2018-02-23T08:24:17Z")

</div>

Hi @EvetsMostel, do you have any logs?

Also is the SIM ‘ready’?

---

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [February 23, 2018, 4:12pm UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/7 "2018-02-23T16:12:21Z")

</div>

Hi @CoRfr,  
It seems to be inconsistent, but I think it’s related to when you have a static IPV4 SIM. I will try to post logs later. I make the connection to the network, so the SIM must be “ready”. cm says:  
SIM card is inserted and locked (LE\_SIM\_INSERTED).

---

<div class="post-metadata">

### Author: ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.legato.io/u/lotam)
#### Post date: [February 26, 2018, 1:56am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/8 "2018-02-26T01:56:55Z")

</div>

Hi @EvetsMostel

> SIM card is inserted and **_locked_** (LE\_SIM\_INSERTED)

This means the SIM is locked and need pin code to unlock before WP can read/access the SIM.

You may try below to apply pin code and see does it able to read the IMSI.

> cm sim enterpin \<pin\>  
> cm sim info

Alternatively, you may use below to unlock it permanently

> cm sim unlock \<pin\>

Thx

---

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [February 26, 2018, 3:53am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/9 "2018-02-26T03:53:56Z")

</div>

Hi @lotam,  
I don’t believe that this SIM is locked, as it was pulled out of a MC7455 which CAN read the IMSI. Also, I’ve never locked it, unless the Carrier did. It’s my personal SIM.

---

<div class="post-metadata">

### Author: ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.legato.io/u/lotam)
#### Post date: [February 26, 2018, 4:06am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/10 "2018-02-26T04:06:49Z")

</div>

Can you share response for

> cm sim info

---

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [February 26, 2018, 4:14am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/11 "2018-02-26T04:14:03Z")

</div>

@lotam,  
I won’t give the particulars since this is a public forum, but it gives the ICCID, Home Network Operator and the phone number. The IMSI and EID are both Blank.

Manikanta from above, says that it needs to be the latest version of Legato. I’m running 17.11 because that’s what R7 is for the wp76xx.

---

<div class="post-metadata">

### Author: ![CoRfr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/corfr/32/69_2.png) [@CoRfr](https://forum.legato.io/u/CoRfr)
#### Post date: [March 3, 2018, 2:45am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/12 "2018-03-03T02:45:09Z")

</div>

This is odd, my understanding is that the IMSI is only available when the SIM card is in a `READY` state.  
That’s what the code does, cf `le_sim.c`, `GetSimCardInformation`.  
If it’s only in a `INSERTED` state, the Legato code doesn’t provide an IMSI.

Could you use the AT port to see if you can read the IMSI through that?

```auto
# microcom /dev/ttyAT
AT+CIMI

```

If it does return the IMSI while Legato doesn’t, then that would be an issue.

---

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [March 3, 2018, 3:08am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/13 "2018-03-03T03:08:58Z")

</div>

Hi @CoRfr,  
Yes, it most certainly does. As I’ve said, I’ve used this sim on a MC7455 (my personal) and the software I use to control it works, and uses the IMSI to determine what the sim carrier is. It won’t work without it.  
This is a WP7601 though, again running version 7.11 of Legato.

Evets

---

<div class="post-metadata">

### Author: ![CoRfr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/corfr/32/69_2.png) [@CoRfr](https://forum.legato.io/u/CoRfr)
#### Post date: [March 3, 2018, 3:21am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/14 "2018-03-03T03:21:11Z")

</div>

I do not have a device available at the moment, but could you rebuild Legato with the following patch to see if the IMSI is shown:  
[https://github.com/CoRfr/legato-af/commit/cb04428a1c1c52cefe57a0b0316bf9d6b244c898](https://github.com/CoRfr/legato-af/commit/cb04428a1c1c52cefe57a0b0316bf9d6b244c898)

Something like:

```auto
cd legato
git fetch https://github.com/CoRfr/legato-af/ testimsi
git checkout FETCH_HEAD
make wp76xx

```

---

<div class="post-metadata">

### Author: ![CoRfr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/corfr/32/69_2.png) [@CoRfr](https://forum.legato.io/u/CoRfr)
#### Post date: [March 5, 2018, 8:01pm UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/15 "2018-03-05T20:01:21Z")

</div>

Could you also post some logs from `logread` with debug level on (`log level DEBUG`)?  
The issue is hard to understand given that it seems that the SIM state is in `ready` state despite appearing as in `inserted` state.

---

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [March 17, 2018, 5:50pm UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/16 "2018-03-17T17:50:32Z")

</div>

Hi @CoRfr,  
Sorry, I’ve been trying to get a release out. Still don’t have your info yet, but I did want you to know that for the WP7601, R8, Legato 18.1.0, it still does not output the IMSI. Even the built in cm won’t output it. I will try to get something later today if I can finish up this issue I’m working on.

---

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [July 11, 2018, 5:56pm UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/17 "2018-07-11T17:56:05Z")

</div>

@CoRfr,  
Sorry, was doing a release and didn’t get back to this.  
So, do I need a particular version of Legato to test this on? Or is this fetch going to give me the entire build?

Evets

---

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [July 11, 2018, 5:59pm UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/18 "2018-07-11T17:59:21Z")

</div>

When I try the git command, it says:  
fatal: Not a git repository (or any of the parent directories): .git

---

<div class="post-metadata">

### Author: ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)
#### Post date: [October 8, 2018, 8:46pm UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/19 "2018-10-08T20:46:20Z")

</div>

@CoRfr,  
I am now using R9 for the WP7601 and the IDE on Windows. If I use the cm command “cm sim info”, the SIM ID is there, but the IMSI is missing. I was never able to get your patch.

cm sim info  
Type: EXTERNAL\_SLOT\_1  
ICCID: 891480000016xxxxxxxx (value removed for security)  
Home Network Operator: Verizon  
EID:  
IMSI:  
Phone Number: +1xxxxxxxxxx (Value removed for security)  
root@swi-mdm9x28:~# cm sim  
SIM card is inserted and locked (LE\_SIM\_INSERTED).

As you can see that the IMSI is not showing up. The AT+CIMI still returns the IMSI.

Can you guys fix this by R10? When is that due out?

Thanks.

---

<div class="post-metadata">

### Author: ![CoRfr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/corfr/32/69_2.png) [@CoRfr](https://forum.legato.io/u/CoRfr)
#### Post date: [October 20, 2018, 1:59am UTC](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084/20 "2018-10-20T01:59:08Z")

</div>

For the patch, you’ll need to do the `git fetch` operation from a git repository.  
So typically you’ll need to checkout the repository as mentioned in [GitHub - legatoproject/legato-af: Legato Application Framework](https://github.com/legatoproject/legato-af#clone-from-github)

R9 on wp76 uses Legato 18.03.0, so that would look something like

```auto
mkdir -p legato-18.03.0
cd legato-18.03.0
repo init -u https://github.com/legatoproject/manifest -m legato/releases/18.03.0/legato.xml
repo sync

```

Then to checkout the patch:

```auto
cd legato/
git fetch https://github.com/CoRfr/legato-af/ testimsi
git cherry-pick FETCH_HEAD
make wp76xx

```

[Next page](https://forum.legato.io/t/le-sim-getimsi-doesnt-seem-to-work/3084.md?page=2)
