How can I decode PDU with GSMComm or PduBitPacker? - c#

I want to Decode PDU Text Retrieved from GSM Modem in C#, How can I decode it with GSMComm or PduBitPacker?
Please answer me with a code
TY
(P.S. I have encoded text and I do not need to get it from Modem)

Make sure you include PDUConverter.dll in your project.
IncomingSmsPdu sms = IncomingSmsPdu.Decode("0791893905004100640C9189398978168400003160915151238110050003110202C26735B94D87DF41", true);
Console.WriteLine(sms.UserDataText);
The first argument of Decode is your RAW PDU string including header at the end, the second argument is a flag telling the decoder that a header is present.
Inside of UserDataText you will find the SMS text.
If you see estrange characters at the beginning, it is because you have a "Smart Message", that is, a multi-part SMS that should be concatenated into a single large message, this is a trick invented by Nokia.
The class GsmComm.PduConverter.SmartMessaging.SmartMessageDecoder could be of help if you want to deal with this smart messaging thing.

Related

Callback OnStreamMessageHandler in Unity return only half of cyrillic string

I'm trying to implement Agora.io text chat in Unity. Using SendStreamMessage method to send message and OnStreamMessageHandler callback to get the stream message. Everything works as expected when I send\receive latin alphabet string. But when I try to receive cyrillic string message, it gets only half of string. Is it some SDK bug or what it can be?
Fixed it by sending text through json byte array

Send plain text mixed with Emojis as Unicode data via SMS by using C# in Unity

I am writing an Android app in Unity using C#. The app will send SMS text messages that include a mixture of text and emojis.
My initial thought is to send the Unicode values of the respective emojis inline with any plain text. I have searched StackOverflow and I haven't found a concise example that solves this problem.
Here is code I have tried:
string mobile_num = "+18007671111; //Placeholder
string text = "Test: \\uFFFd\\uFFFd"; //(smile emoji Unicode value)
char[] chars = text.ToCharArray();
byte[] bytes = Encoding.UTF8.GetBytes(chars);
string message = HttpUtility.UrlEncode(bytes);
string sms = string.Format("sms:{0}?body={1}", mobile_num, message);
Application.OpenURL(sms);
I need to know:
1. Is this the correct approach?
a. if not, please help me correctly encode text + emoji data
b. What is the step required to covert so that the final message can be sent via SMS?
So after much searching, I found the simplest way in C# is to use:
\U########
Where:
\ is an escape character
U is a constant to define a Unicode sequence follows
## is the hex value of the emoticon encoded in exactly 8 characters left filled with zeros if necessary.
For example:
string u = "Smile: \U0001F601";
Will send:
Smile: 😁
Thank you Jeppe Stig Nielsen for your insight. For the full discussion follow this link:
How to convert numbers between hexadecimal and decimal

Open New Email with HTML body from URL [duplicate]

If I wanted to prepopulate an email link like: (in a really simple format, pardon for the bad example.)
Email 3 Barney Today!
and have the html actually show as html, is there a way to do so.
What you're looking to do is not part of the design of the mailto anchor href, according to RFC 2368:
The special hname "body" indicates that the associated hvalue is the
body of the message. The "body" hname should contain the content for
the first text/plain body part of the message. The mailto URL is
primarily intended for generation of short text messages that are
actually the content of automatic processing (such as "subscribe"
messages for mailing lists), not general MIME bodies.
To do as you describe, you would be better off looking into a pre-processor like PHP.

Encoding/Decoding PDU 7bit septets GSM long messages

I'm looking for Encoding/Decoding algorithm.
I have tried this:
http://codeproblem.hamaraquetta.com/articles/languages/81-net-framework/76-encoding-sms-in-pdu-format-in-net?showall=&start=1
and no luck. :(
Here is what I'm trying
This is the text:
This is a long text message greater than 160 characters. You can encode it to PDU format using the SMS-PDU lib for .NET, It also supports UCS-2 encoding, and special characters like { [ ] } are also supported. Its quite simple to use in your code.
From this text there should 2 messages encoded to septets and after I should be able to submit the message.
This is the result i get:
Part 1:
0041000C917952205197720000A00500033F0201A8E8F41C949E83C220F6DB7D06D1CB783AA85D9ECFC3E732E82C2F87E96539888E0EBB41311B0C344687E5E131BD2C9FBB40D9771D340EBB4165F7F84D2E83D27410FD0D8212AB20F35BDE0ED341F579DA7D06D1D165D0B4396D418955103B2D0699DF7290CB59A4B240493A28CC9EBF41F33A1CFE96D3E7A0EA70DA9281CAEEF19B9C769F59
Part 2:
0041000C917952205197720000690500033F020240613719348797C7E9301B344687E5E131BD2C9F83D8E97519B44181363CD0C607DAA4406179191466CFDFA0791D0E7FCBE965B20B94A4CF41F17A9A5E06CDD36D38BB0CA2BF41F57919947683F2EFBA1C347E93CB2E
this is doesn't work.
How do I solve this?
Btw: this is the phonenumber i know it's important.
+972502157927
Library works completely correctly. ComposeLongSms() returns a string array of PDUs and you should send("submit" as you said) all these PDUs to your GSM modem like separate SMSes. Any concatenating won't work, you can notice that each PDU starts with the same part, which contains encoded additional information for outgoing SMS. You can verify your PDUs here

"End of Message" String for Sockets

What's a good end of message marker for a socket message schema in order to separate messages as they are received?
I had been using <EOF> but that seems a byte or too long and could POSSIBLY be sent in a message, especially if XML data was being sent.
Thanks!
One method is to approach this similar to AMF3: Before each message, send a 4-byte length indicating the number of bytes of data which will be sent as the message. In this way, even a 0-byte "empty message" can be sent, and no escape mechanism is needed.
If you're restricting the message data to printable characters, there are several control characters to choose from (ETX, EOT, Ctrl-Z, FS, EM, etc.) that historically have been used to signal end of message.

Categories