|
But InParts is readonly, so how can I send long messages?
|
|
|
|
|
Really? Try to implement setter for this property. I've never sent long message with my library, so do it yourself. If it's possible tell me about results.
|
|
|
|
|
This library does not support sending long messages. The properties InPartsID, InParts, Part aren't used.
|
|
|
|
|
I've got a lot to achieve.
|
|
|
|
|
To send longer messages, you should encode your sms text using 7bit Encoder, because text length in Unicode Encoding should not exceed 70 symbols. Encode7bit method is not implemented in this library so I try to write my own.
public static byte[] Encode7bit(string src)
{
char[] arr = src.ToCharArray();
Array.Reverse(arr);
string binary = string.Empty;
foreach (char b in arr)
binary += Convert.ToString(b, 2).PadLeft(7,'0');
binary = binary.PadLeft(binary.Length + 8 - binary.Length % 8, '0');
string result = string.Empty;
List<byte> arrRet = new List<byte>();
for (int i = 1; i <= binary.Length / 8; i++)
arrRet.Add(Convert.ToByte(binary.Substring(binary.Length - i*8, 8), 2));
return arrRet.ToArray();
}
And also do not forget to change limitation from 70 symblos to 160 in Message property in sms.cs.
if (value.Length > 160)
throw new ArgumentOutOfRangeException....
|
|
|
|
|
0791290304000011640C91290364973308000070105122940102A00500037C030340E2B09B8C0EBB598AFB1B240EBBC9E8B01BA47E83C4EEB0BB0C6A87D3207DB81D769741E272990E5287E965053A9C6629D46937BA0C42D7DB2031FACD06A9C3F432081D4E83EE6F101C9D9683D6E9FC1B940F9341617A19840EA7598AB41B5D7683E0E8B41C342F83C4E8F79B1D769741ED701AA40FB7C3EE32485C2ED341EA30BDAC4087D3
what is wrong in this message...your has exception
public static string Decode7bit(string source, int length)
{
byte[] bytes = GetInvertBytes(source);
string binary = string.Empty;
foreach (byte b in bytes)
binary += Convert.ToString(b, 2).PadLeft(8, '0');
string result = string.Empty;
for (int i = 1; i <= length; i++)
//here is error on 154 index
result += (char) Convert.ToByte(binary.Substring(binary.Length - i *
7, 7), 2);
return result.Replace('\x0', '\x40');
}
The exception is (ArgumentOutOfBound Exception)
StartIndex cannot be less than zero.
U m A i R
|
|
|
|
|
Please, change source code at file SMSBase.cs. Method Decode7bit must look like this:
public static string Decode7bit(string source, int length)<br />
{<br />
byte[] bytes = GetInvertBytes(source);<br />
<br />
string binary = string.Empty;<br />
<br />
foreach (byte b in bytes)<br />
binary += Convert.ToString(b, 2).PadLeft(8, '0');<br />
<br />
binary = binary.PadRight(length * 7, '0');<br />
<br />
string result = string.Empty;<br />
<br />
for (int i = 1; i <= length; i++)<br />
result += (char) Convert.ToByte(binary.Substring(binary.Length - i * 7, 7), 2);<br />
<br />
return result.Replace('\x0', '\x40');<br />
}<br />
Best, Ed.
|
|
|
|
|
Hello,
You have one bug (?) in decoding 7bit multi part messages.
PDU:
07 91 246030500200 64 0C 91 247013015183 00 00 70106151516440 A0 050003140301886FB1BC0...
What is wrong?
Header parsing is OK...
So we have only this left:
050003140301886FB1BC0C9287DD6F96FA0DD2AFEBF3B2FB3...
This is message WITH part id and part number (050003140301). You will correctly parse this informations out and you will strip this part. AND THIS IS THE PROBLEM. You can't do that for 7bit encoding. If You do this, You won't be able to decode the text.
public static void Fetch(SMS sms, ref string source)<br />
{<br />
string source_7bit = "";<br />
<br />
SMSBase.Fetch(sms, ref source);<br />
<br />
if (sms._direction == SMSDirection.Submited)<br />
sms._messageReference = PopByte(ref source);<br />
<br />
sms._phoneNumber = PopPhoneNumber(ref source);<br />
sms._protocolIdentifier = PopByte(ref source);<br />
sms._dataCodingScheme = PopByte(ref source);<br />
<br />
if (sms._direction == SMSDirection.Submited)<br />
sms._validityPeriod = PopByte(ref source);<br />
<br />
if (sms._direction == SMSDirection.Received)<br />
sms._serviceCenterTimeStamp = PopDate(ref source);<br />
<br />
sms._userData = source;<br />
<br />
if (source == string.Empty)<br />
return;<br />
<br />
int userDataLength = PopByte(ref source);<br />
<br />
if (userDataLength == 0)<br />
return;<br />
<br />
if (sms._userDataStartsWithHeader)<br />
{<br />
source_7bit = source;<br />
byte userDataHeaderLength = PopByte(ref source);<br />
<br />
sms._userDataHeader = PopBytes(ref source, userDataHeaderLength);<br />
<br />
userDataLength -= userDataHeaderLength + 1;<br />
}<br />
<br />
if (userDataLength == 0)<br />
return;<br />
<br />
switch ((SMSEncoding)sms._dataCodingScheme & SMSEncoding.ReservedMask)<br />
{<br />
case SMSEncoding._7bit:<br />
if (source_7bit == "")<br />
{<br />
sms._message = Decode7bit(source, userDataLength);<br />
}<br />
else<br />
{<br />
string tmp_string = Decode7bit(source_7bit, userDataLength + 6);<br />
sms._message = tmp_string.Substring(7);<br />
}<br />
break;<br />
case SMSEncoding._8bit:<br />
sms._message = Decode8bit(source, userDataLength);<br />
break;<br />
case SMSEncoding.UCS2:<br />
sms._message = DecodeUCS2(source, userDataLength);<br />
break;<br />
}<br />
}
What I do... When Multi part sms is detected, i store pdu source before partId and partNumber parsing (string source_7bit). Now when 7bit decoding is called, I "hacked" the input params, so I can send my "source_7bit" string and i added 6 to userDataLength (not yet fully tested, but this will prevent lost of last few chars). When data is parsed, I just strip first 7 chars (part id and part number).
This is just quick fix, so there can be problems and this can be fixed more complex. But helped us in parsing multi part sms with 7bit encoding.
Please try to look at this
Ladislav Soukup
|
|
|
|
|
|
|
I recieved the following message on a siems TC 63. It had no problems parsing the message in textmode. In pdu mode it doesn't make sense. Message header is OK, but message turned out bad.
MSG:
06915404950000440A91542282969200F16011021132634096050003C9030375201079DD92DD68301068BE7EDBD97537B9DC503414331788192416A7D42293597435140D0515999D4E8B4ED0525A85421B8A601334A53EA5D2A233385C16A5205A4371B3C566391068199432A7D22AB2D8503414C1AA912A0D1E752090B4993CB240C22093599456A1A01728C8AC368BC3270BF424169DD36243D15000
Can you figure it out! I cann't.
Best regrads, Nikolai
NMR
|
|
|
|
|
You have a EMS message with picture or ring tone. My library can't parse those messages.
|
|
|
|
|
Hello Nikolai
When decoding the pdu string I get:
é@øH<¿¡: dk-2740 skovlunde
3. LADESTELLE.
THYSSEN KRUPP
AM STORRENACKER 4
76139 KARLSRUHE
I was using my own pdu-decoder ( found here: www.frada.net/pdusms/PDU_SMS.zip ) to decode it.
The funny sting 'é@øH<¿¡' should be further decoded (it is simple) and then you would get the name of the service-center that sent this replay for your address query.
I am also using my pdu routines in this SMS-logger: www.frada.net/pdusms/SMS_Logger.zip
regards
Frank, Norway
|
|
|
|
|
Thanks a lot, actually I've been developping my own version, but yours is much more advanced and teached me a lot!
Thanks again!
|
|
|
|
|
Hi bro, this is an excelent piece of work.
it will be good if you can help us even further by enabling us compose flash sms, vcards and even vcalendar with your code.
Thanks.
Keep up the great work.
|
|
|
|
|
if you want to compose flash sms (i really don't know what is this...) and vcards you can extend compose functionality by deriving SMSBase class and override Compose method.
I think that information about vcard (for example) stored at UserDataHeader bytes array. You can use this knowledge as start point.
Good luck, Ed.
p.s. if you want to entrust this job to me, we can come to an agreement for some donation.
|
|
|
|
|
|
Can you recommend few products on SMS server? Both Free and Non-Free.
|
|
|
|
|
This library was developed for reading and compising sms which pdu received and sent to mobile phone via bluetooth or data cable via AT commands.
So, I don't use any SMS server. Sorry.
Best, Ed.
|
|
|
|
|
This is what I did with you project:
1. changed the phone number
2. run the project and clicked on encode butto
Result: It gave me encoded message only. The message did not go to the target phone.
I am guessing this project simply encodes message.
Let me know if my assumptions are correct or not.
Is there any additional steps involved to get the message sent to the target phone? Pardon my ignorance. I will appreciate if you could point to additional resources. Thanks.
|
|
|
|
|
Your assumptions are correct. Library only decode and encode sms from/to PDU (protocol data unit).
I can explain how to send sms via cellular phone connected to PC via bluetooth (serial port profile) or data cable.
Best, Ed.
|
|
|
|
|
Re: "I can explain how to send sms via cellular phone connected to PC via bluetooth (serial port profile) or data cable."
- If you can help me with the explanation... I'll greatly appreciate it. Just rated your article.
I'd like to learn additional detail on this as I plan to send text messages via a mobile application that i've been developing.
|
|
|
|
|
using .net 2.0 you can create instance of SerialPort class.
<br />
SerialPort port = new SerialPort();<br />
port.Port = "COM1";
port.Open();<br />
port.NewLine = "\r";<br />
<br />
string pdu = mySMS.Compose(SMS.SMSEncoding.UCS2);
<br />
port.WriteLine(string.Format("AT+CMGS={0}", (pdu.Length / 2) - 1));<br />
Thread.Sleep(1000);
<br />
port.WriteLine(string.Format("{0}\x1A", pdu));<br />
That's all. This is a very dirty sample but it should works
NB: Don't forget connect your phone to PC before start application.
|
|
|
|
|
Thank you VERY VERY much... I just making SMS server to work with several SMS gates (wavecom, ateus) and PDU mode is the most depressing think I have to deal with... I do not have any "full" reference of PDU mode and I still have compatibility problems. If I can read special chars, I can't merge long SMS... or if I can merge long SMS I lost special chars
You realy helped me! Your lib is nice, clean and it WORKS!
Thank You.
Ladislav Soukup
Czech Republic
|
|
|
|
|
Welcome Please, notificate about bugs... Especially pay attention to messages with UserDataHeader (like long SMS), i have one long sms pdu in my collection, which not recognizable by my library as long sms...
Best, Ed.
|
|
|
|