|
You can use the free software PDUSpy (Google PDUSpy) to decode and reassemble long SMS received on your mobile phone, and then modify (or hack :p) the library to support long SMS. I don't know how difficult it will be do with this library, but this is how i do it for my own software.
---------------------
SMS Software@Expert
---------------------
|
|
|
|
|
Hi thx for this great tool! I've been trying to implement the multipart message option but no luck so far.
I want to use the UCS2 since we in Denmark has a lot of special chars æøå etc.
<= 70 chars everything works like a charm.
I've added:
if (UserDataStartsWithHeader)
_pduType = (byte) (_pduType | 0x40);
to the ComposePDUType method on the SMSBase.
If i send this to my phone i recieve a lot of square boxes in two messages. I guess I am missing something.
One thing that i have not figured out yet is the length of the header and the insertion of the header in the Message text. Are there some kind of header length max? how should the octet length be calculated (header.length/2?) and transformed into hex(05 = 5 octets)
Right now i am using the first 10 chars of the message as the header and i am writing their length as 05 octets. After that i paste the header into every message i send and transforms header(10 chars) and message(70 chars) to PDU which i send to the modem.
Any help would be highly appriciated and rewarded with a ½ L of brown sugarwater.
|
|
|
|
|
Hello again!
I try send 7bit coded sms but something was going wrong. It was lenght of message.
Usually it looks like that:
<br />
41 54 2B 43 4D 47 53 3D 32 33 0D AT+CMGS=23. <br />
<br />
Answer: 2007-04-29 20:25:18.79064 (+0.0469 seconds)<br />
<br />
0D 0A 3E 20 ..> <br />
<br />
Request: 2007-04-29 20:25:18.80564 (+0.0000 seconds)<br />
<br />
30 30 30 31 30 30 30 42 39 31 38 34 30 36 37 32 0001000B91840672<br />
37 39 37 39 46 35 30 30 30 30 30 42 36 31 42 31 7979F500000B61B1<br />
33 43 42 43 30 45 39 33 43 33 36 32 37 39 31 38 3CBC0E93C3627918<br />
1A . <br />
<br />
Answer: 2007-04-29 20:25:20.58764 (+2.7813 seconds)<br />
<br />
2B 43 4D 47 53 3A 20 31 35 31 0D 0A 30 0D +CMGS: 151..0.<br />
<br />
But in bold was 0A for message "abrakadabra".
I changed one part of code.
<br />
<br />
public virtual string Compose(SMSEncoding messageEncoding)<br />
{<br />
ComposePDUType();<br />
string encodedData = "";<br />
if (ServiceCenterNumber != null && ServiceCenterNumber.Length > 0)<br />
{<br />
encodedData += EncodePhoneNumber(ServiceCenterNumber);<br />
}<br />
else<br />
encodedData = "00";
encodedData += Convert.ToString(_pduType, 16).PadLeft(2, '0');
encodedData += Convert.ToString(MessageReference, 16).PadLeft(2, '0');<br />
encodedData += EncodePhoneNumber(PhoneNumber);<br />
encodedData += "00";
encodedData += Convert.ToString((int)messageEncoding, 16).PadLeft(2, '0');
<br />
if (_validityPeriodFormat != ValidityPeriodFormat.FieldNotPresent)<br />
encodedData += Convert.ToString(_validityPeriod, 16).PadLeft(2, '0');
<br />
<br />
byte[] messageBytes = null;<br />
<br />
switch (messageEncoding)<br />
{<br />
case SMSEncoding.UCS2:<br />
messageBytes = EncodeUCS2(_message);<br />
encodedData += Convert.ToString(messageBytes.Length, 16).PadLeft(2, '0');
break;<br />
case SMSEncoding._7bit:<br />
messageBytes = Encode7Bit(_message);<br />
encodedData += Convert.ToString(_message.Length, 16).PadLeft(2, '0');
break;<br />
default:<br />
messageBytes = new byte[0];<br />
break;<br />
}<br />
<br />
<br />
<br />
foreach (byte b in messageBytes)<br />
encodedData += Convert.ToString(b, 16).PadLeft(2, '0');<br />
<br />
return encodedData.ToUpper();<br />
}<br />
|
|
|
|
|
Will you support creating 7Bit messages?
I wrote sth like this:
<br />
public static byte[] Encode7Bit(string s)<br />
{<br />
string in_str = "";<br />
byte[] out_bytes;<br />
for (int ii = s.Length - 1; ii >= 0; ii--)<br />
{<br />
in_str += Convert.ToString((byte)s[ii], 2).PadLeft(7, '0');<br />
}<br />
if (0!=(in_str.Length)%8)<br />
in_str = in_str.PadLeft(in_str.Length + (8 - (in_str.Length) % 8), '0');<br />
out_bytes = new byte[in_str.Length / 8];<br />
for (int ii = 0; ii < in_str.Length / 8; ii++)<br />
out_bytes[ii] = Convert.ToByte(in_str.Substring(in_str.Length - ((ii + 1) * 8), 8), 2);<br />
return out_bytes;<br />
}<br />
Mayby it will be usefull.
Bye.
Paweł Paduch
-- modified at 20:03 Monday 11th June, 2007
|
|
|
|
|
Hi, i'm developing cellphone communicator,
using Serialport class(.net 2.0) and infrare is represented by comport to communicate with phone,
Connection is successful, but phone doesn't respond to my request (AT commands)..
When i used a cable (instead of irda), it worked good enought..
Please tell me why doesn't infrared work??
thx..
Sorry for my eng..
rimobul
|
|
|
|
|
I'm using BlueTooth communication. My SerialPort settings is:
BaudRate = 9600;
DtrEnabled = true;
RtsEnabled = true;
LineEnd = "\r";
Other settings set by default.
|
|
|
|
|
Hello, I can't decode a sms sent from Siemens M65 Phone. Could you please help.
Here is a PDU:
07917394010003F1640B917394418891F300007030211272920011050A03000A08906536FB8D2CB3D96F
The result should be "HelloHello" (without space), but instead of this I get "@2{h}["
Is this message encoded using 7bit Encoder ?
Thanks.
|
|
|
|
|
Hi there,
First of all: I love You for writing this library
BUT: How can I write longer messages (i.e. 160 characters)
/TheManDK
|
|
|
|
|
Hello. Try set InParts = true at all parts of large message and use same InPartsID for it.
Ed.
|
|
|
|
|
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.
|
|
|
|