# Convert device id hex to string

**URL:** <https://forum.sierrawireless.com/t/convert-device-id-hex-to-string/24561>\
**Category:** AirLink Routers\
**Created:** [August 13, 2021, 2:50pm UTC](https://forum.sierrawireless.com/t/convert-device-id-hex-to-string/24561 "2021-08-13T14:50:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![steven\_mcneese](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@steven\_mcneese](https://forum.sierrawireless.com/u/steven_mcneese)\
**Post date:** [August 13, 2021, 2:50pm UTC](https://forum.sierrawireless.com/t/convert-device-id-hex-to-string/24561/1 "2021-08-13T14:50:04Z")

</div>

I am evaluating the LX60. After struggling to get it to stream to server 1 IP address, I realized they are using UDP and not TCP. So that is working now. I have the Device Id configuration set to Phone Number. It is coming across in the NMEA sentences and is supposed to be HEX. This is not any HEX I can identify so I am struggling how to convert his to the phone number.

The 9 bytes before the NMEA string start are:

```auto
255,235,114,41,0,213,1,0,0

```

Anybody have any C# examples of how this is done.

---

<div class="post-metadata">

**Author:** ![steven\_mcneese](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@steven\_mcneese](https://forum.sierrawireless.com/u/steven_mcneese)\
**Post date:** [August 13, 2021, 8:28pm UTC](https://forum.sierrawireless.com/t/convert-device-id-hex-to-string/24561/2 "2021-08-13T20:28:25Z")

</div>

The AT \*DEVICEID? command returned

```auto
0x000001D5002972EB

```

But still cannot figure out what that is as it related to the phone number

---

<div class="post-metadata">

**Author:** ![steven\_mcneese](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@steven\_mcneese](https://forum.sierrawireless.com/u/steven_mcneese)\
**Post date:** [August 15, 2021, 6:06pm UTC](https://forum.sierrawireless.com/t/convert-device-id-hex-to-string/24561/3 "2021-08-15T18:06:04Z")

</div>

From OP

255 = FF  
235 = EB  
114 = 72  
41 = 29  
0 = 00  
213 = D5  
1 = 01  
0 = 00  
0 = 00

So in the NMEA sentence starts with FF but then the next 8 bytes which represent the phone number are reversed from what the \*DEVICEID? command returns. But still even doing that I cannot get it to match the phone number of the SIM card. Not sure why any of this is not documented in detail.

---

<div class="post-metadata">

**Author:** ![barney.a.goette](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@barney.a.goette](https://forum.sierrawireless.com/u/barney.a.goette)\
**Post date:** [August 7, 2023, 6:29pm UTC](https://forum.sierrawireless.com/t/convert-device-id-hex-to-string/24561/4 "2023-08-07T18:29:03Z")

</div>

Why is there still no answer? How do we parse the $DEVID field?

---

<div class="post-metadata">

**Author:** ![steven\_mcneese](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@steven\_mcneese](https://forum.sierrawireless.com/u/steven_mcneese)\
**Post date:** [August 7, 2023, 6:44pm UTC](https://forum.sierrawireless.com/t/convert-device-id-hex-to-string/24561/5 "2023-08-07T18:44:45Z")

</div>

I figured it out. When I get back to the office I will post the code.

---

<div class="post-metadata">

**Author:** ![steven\_mcneese](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@steven\_mcneese](https://forum.sierrawireless.com/u/steven_mcneese)\
**Post date:** [August 7, 2023, 7:06pm UTC](https://forum.sierrawireless.com/t/convert-device-id-hex-to-string/24561/6 "2023-08-07T19:06:01Z")

</div>

Mine is set to include the IMEI in the location report being sent to the server UDP.

> string locationReport = Encoding.ASCII.GetString(bytes);  
> string IMEI = Convert.ToInt64(locationReport.Substring(11,14), 16).ToString();

_locationReport_ is a string representing an entire record send via UDP to the server listener from the modem. Hope this helps.

---

<div class="post-metadata">

**Author:** ![barney.a.goette](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@barney.a.goette](https://forum.sierrawireless.com/u/barney.a.goette)\
**Post date:** [August 7, 2023, 7:27pm UTC](https://forum.sierrawireless.com/t/convert-device-id-hex-to-string/24561/7 "2023-08-07T19:27:14Z")

</div>

So I see you’re using `Substring(11, 14)`, my device id is coming as 16 characters (after `0x`). Are you skipping the first 2? I am testing with `Phone Number` as the ID, and when I convert to an `Int64` it isn’t correct.
