Hello, currently I'm working on an SMS server project. I've managed to get access to the SMSs stored on the device with AT commands, but I receive them in the following format, in a string:

07916303898800F0180B916303470054F60000808012415064402FD4321B14D6BFDDEF799AFED68168B45C4C1683C9400A2A34E9D4816E31594D4185269DB21D0887CBD100

This is actually an SMS, but I can't get it to human readable format. There is the CMGF=1 AT command, which would return text messages as text, but my device doesn't support it.

Can anybody help me convert this into a plain Unicode string, in C#?

I'd appreciate any help.

Hello, currently I'm working on an SMS server project. I've managed to get access to the SMSs stored on the device with AT commands, but I receive them in the following format, in a string:

07916303898800F0180B916303470054F60000808012415064402FD4321B14D6BFDDEF799AFED68168B45C4C1683C9400A2A34E9D4816E31594D4185269DB21D0887CBD100

This is actually an SMS, but I can't get it to human readable format. There is the CMGF=1 AT command, which would return text messages as text, but my device doesn't support it.

Can anybody help me convert this into a plain Unicode string, in C#?

I'd appreciate any help.

You mean like:

private string HexString2Ascii(string hexString)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= hexString.Length - 2; i += 2)
{
sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(hexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber))));
}
return sb.ToString();
}

Im not entirely sure you have retrieved it correctly, or if you have the encoding is odd.
I played around with several different conversions and got nothing but gibberish from the string you gave above.

Im not entirely sure you have retrieved it correctly, or if you have the encoding is odd.
I played around with several different conversions and got nothing but gibberish from the string you gave above.

Well, the function works for what it's supposed to do. But it expects the hex to convert to ASCII.

You need to figure out what encoding they are sending that to you in. Looking at the first two bytes you have 7 and 136 which would translate to "Bell" then "^".

There is always the issue of endianness.
I remember from the old days(more than 20 years ago), we had to read some data from a magnetic tape. We could finaly read them if we swapped the bytes or nibbles(I don't remember that anymore;) )

Do you, per chance, know what the text message shown above says? If we can see the end result we may be able to reverse engineer it.

This article has been dead for over six months. Start a new discussion instead.