PDA

View Full Version : گفتگو: روش شاخت پيام به صورت PDU



ali_mohamadi8928
شنبه 11 خرداد 1387, 17:09 عصر
سلا به دوستاني كه توي اين مبحث فعاليت دارن

من به كمكتون نياز دارم . مخصوصا اقاي noorsoft كه تازه هم مدير شده و مديريتش رو تبريك ميگم :خجالت:

من يك توضيح كامل در مورد تبديل يك متن به پيام به صورت PDU ميخوام . همچنان روش برگردوندش رو به حالت متن

مثلا شماره تلفني كه ميخواييم پيام رو بهش ارسال كنيم داشته باشيم و شماره سرويس رو هم داشته باشيم و مت رو هم از كاربر بگيريم و تبديل به PDU كنيم و يا برعكس PDU رو بگيريم و به زبان خودمون تبديلش كنيم .

لطفا براي ساخت PDU فارسي و برگردوندنش رو هم توضيح بديد .

در واقع من يك توضح جامع ميخوام تا تبديلش كنم به يك برنامه ...

بدون شك مطالب اين تاپيك به درد خيلي ها خواهد خورد . لطفا با توضيحات جامع خودتون بار علمي اين تاپيك رو بالا ببريد .

منتظرم :لبخندساده:

noorsoft
شنبه 11 خرداد 1387, 19:48 عصر
یکسری رفرنس اصلی کامل براتون میزارم

SMS PDU mode

The PDU mode offers to send binary information in 7 bit or 8 bit format. That is helpful if you have to send compressed data, binary data or you you like to build your own encoding of the characters in the binary bit stream. If you go back on the old encoding of a Fernschreiber, then there are only 5 bit needed to send an alphanumeric text. By 5 bit coding you can contain 224 characters instatt of 160 characters in 7 bit Text mode. An others reason could be the sending of integer data.
If you would like to have the full control of your transmited data in Text mode you have to understand the PDU mode, because there are a few commands where you can set numeric parameters that change the kind od send and receive of a SMS in text mode also.
Please note that there are a few differences of in the kind of implemetation of the PDU mode and by the other AT commands.



SMS and the PDU format

Introduction

The SMS message, as specified by the Etsi organization (documents GSM 03.40 and GSM 03.38), can be up to 160 characters long, where each character is 7 bits according to the 7-bit default alphabet. Eight-bit messages (max 140 characters) are usually not viewable by the phones as text messages; instead they are used for data in e.g. smart messaging (images and ringing tones) and OTA provisioning of WAP settings. 16-bit messages (max 70 characters) are used for Unicode (UCS2) text messages, viewable by most phones. A 16-bit text message of class 0 will on some phones appear as a Flash SMS (aka blinking SMS or alert SMS).
The PDU format

There are two ways of sending and receiving SMS messages: by text mode and by PDU (protocol description unit) mode. The text mode (unavailable on some phones) is just an encoding of the bit stream represented by the PDU mode. Alphabets may differ and there are several encoding alternatives when displaying an SMS message. The most common options are "PCCP437", "PCDN", "8859-1", "IRA" and "GSM". These are all set by the at-command AT+CSCS, when you read the message in a computer application. If you read the message on your phone, the phone will choose a proper encoding. An application capable of reading incoming SMS messages, can thus use text mode or PDU mode. If text mode is used, the application is bound to (or limited by) the set of preset encoding options. In some cases, that's just not good enough. If PDU mode is used, any encoding can be implemented.
Receiving a message in the PDU mode

The PDU string contains not only the message, but also a lot of meta-information about the sender, his SMS service center, the time stamp etc. It is all in the form of hexa-decimal octets or decimal semi-octets. The following string is what I received on a Nokia 6110 when sending the message containing "hellohello" from www.mtn.co.za.


07
917238010010F5
040BC87238880900F100009930925161958003C16010


This octet sequence consists of three parts: An initial octet indicating the length of the SMSC information ("07"), the SMSC information itself ("917238010010F5"), and the SMS_DELIVER part (specified by ETSI in GSM 03.40).

Note: on some phones (e.g. Ericssson 888?) the first three (colored) parts are omitted when showing the message in PDU mode!


Octet(s)
Description
07
Length of the SMSC information (in this case 7 octets)
91
Type-of-address of the SMSC. (91 means international format of the phone number)
72 38 01 00 10 F5
Service center number(in decimal semi-octets). The length of the phone number is odd (11), so a trailing F has been added to form proper octets. The phone number of this service center is "+27831000015". See below.
04
First octet of this SMS-DELIVER message.
0B
Address-Length. Length of the sender number (0B hex = 11 dec)
C8
Type-of-address of the sender number
72 38 88 09 00 F1
Sender number (decimal semi-octets), with a trailing F
00
TP-PID. Protocol identifier.
00
TP-DCS Data coding scheme
99 30 92 51 61 95 80
TP-SCTS. Time stamp (semi-octets)
0A
TP-UDL. User data length, length of message. The TP-DCS field indicated 7-bit data, so the length here is the number of septets (10). If the TP-DCS field were set to indicate 8-bit data or Unicode, the length would be the number of octets (9).
E8329BFD4697D9EC37
TP-UD. Message "hellohello" , 8-bit octets representing 7-bit data.


All the octets above are hexa-decimal 8-bit octets, except the Service center number, the sender number and the timestamp; they are decimal semi-octets. The message part in the end of the
PDU string consists of hexa-decimal 8-bit octets, but these octets represent 7-bit data
(see below).
The semi-octets are decimal, and e.g. the sender number is obtained by performing internal swapping within the semi-octets from "72 38 88 09 00 F1" to "27 83 88 90 00 1F".
The length of the phone number is odd, so a proper octet sequence cannot be formed by this number. This is the reason why the trailing F has been added. The time stamp, when parsed, equals
"99 03 29 15 16 59 08", where the 6 first characters represent date, the following 6 represents time, and the last two represents time-zone related to GMT.
Interpreting 8-bit octets as 7-bit messages

This transformation is described in detail in GSM 03.38, and an example of the "hellohello" transformation is shown here. The transformation is based on the 7 bit default alphabet , but an application built on the PDU mode can use any character encoding.
Sending a message in the PDU mode

The following example shows how to send the message "hellohello" in the PDU mode from a Nokia 6110.

AT+CMGF=0 //Set PDU mode AT+CSMS=0 //Check if modem supports SMS commands AT+CMGS=23 //Send message, 23 octets (excluding the two initial zeros) >0011000B916407281553F80000AA0AE8329BFD4697D9EC37Th ere are 23 octets in this message (46 'characters'). The first octet ("00") doesn't count, it is only an indicator of the length of the SMSC information supplied (0). The PDU string consists of the following:


Octet(s)
Description

00
Length of SMSC information. Here the length is 0, which means that the SMSC stored in the phone should be used. Note: This octet is optional. On some phones this octet should be omitted! (Using the SMSC stored in phone is thus implicit)

11
First octet of the SMS-SUBMIT message.

00
TP-Message-Reference. The "00" value here lets the phone set the message reference number itself.

0B
Address-Length. Length of phone number (11)

91
Type-of-Address. (91 indicates international format of the phone number).

6407281553F8
The phone number in semi octets (46708251358). The length of the phone number is odd (11), therefore a trailing F has been added, as if the phone number were "46708251358F". Using the unknown format (i.e. the Type-of-Address 81 instead of 91) would yield the phone number octet sequence 7080523185 (0708251358). Note that this has the length 10 (A), which is even.

00
TP-PID. Protocol identifier

00
TP-DCS. Data coding scheme.This message is coded according to the 7bit default alphabet. Having "02" instead of "00" here, would indicate that the TP-User-Data field of this message should be interpreted as 8bit rather than 7bit (used in e.g. smart messaging, OTA provisioning etc).

AA
TP-Validity-Period. "AA" means 4 days. Note: This octet is optional, see bits 4 and 3 of the first octet

0A
TP-User-Data-Length. Length of message. The TP-DCS field indicated 7-bit data, so the length here is the number of septets (10). If the TP-DCS field were set to 8-bit data or Unicode, the length would be the number of octets.

E8329BFD4697D9EC3 7
TP-User-Data. These octets represent the message "hellohello". How to do the transformation from 7bit septets into octets is shown here

ali_mohamadi8928
شنبه 11 خرداد 1387, 19:58 عصر
ممنونم ولي من اين رو قبلا ديده بودم .. از شما خواستم كه به زبان فارسي يكم توضيح بديد .. راستش از اين من هيچي نفهميدم ...

اگه اين كار رو انجام بديد خيلي ازتون ممنون ميشم ...

noorsoft
شنبه 11 خرداد 1387, 21:43 عصر
چشم
اول توضیحات 7بیت را میدم که برای ارسال پیام انگلیسی استفاده میشه
دو بایت اول : نشان دهنده طول بیتهای تشکیل دهنده یک کاراکتر یعنی 07
دو بایت بعدی : برای گزارش ارسال (دلایوری) که در اینجا 11 وارد میشه
دو بایت بعدی شماره رفرنس پیام که 00 وارد میشه و خود مودم ان را مقدار دهی میکنه
دوبایت بعدی برای مشخص کردن تعداد شماره های مقصد استفاده میشه توجه داشته باشین اعداد باید زوج باشن پس شماره موبایل های ما که 11 رقمی باید 12 رقمی در نظر گرفته بشن پی مقداری 0B را برای این قسمت وارد میکنیم
دوبایت بعدی برای مشخص کردن نوع شماره است که 91 برای شماره های بین المللی و 81 برای شماره های محلی استفاده میشه
کارکترهای بعدی شماره تلفنی است که قراره پیام را دریافت کنه که به طریق زیر کد میشه

مثلا 12345678901 اگه شماره موبایل باشه باید یک F به اون اضافه بشه تا طولش 12 کارکتر بشه و بعد اعداد دو به دو جابه جا میشن 2134567809F1

---- شرمنده اجازه بدین بقیه پست را بعدا کامل میکنم

ali_mohamadi8928
شنبه 11 خرداد 1387, 22:52 عصر
ممنونم noorsoft جان ... مشتاقانه منتظر ادامه ي موضوع هستم .

لطفا يه جور واضح و الگوريتمي توضيح بده تا بتونم برنامش رو بنويسم و بزارم همين جا و يكمرجع كامل فارسي بشه .

منتظرم .

noorsoft جان يه چيزي اينجا ازت ديدم كه اميدوار شدم ميتونم روت براي اين PDU حساب كنم . خواهشا مطلبي رو دريغ نكن و در حق بچه هاي اينجا اين لطف رو بكن و PDU رو كاملا توضيح بده ( هم براي فارسي هم براي انگليسي ) . يك دنيا ممنون

http://forum.iranled.com/showthread.php?tid=8969

noorsoft
یک شنبه 12 خرداد 1387, 17:06 عصر
چشم
اول توضیحات 7بیت را میدم که برای ارسال پیام انگلیسی استفاده میشه
دو بایت اول : نشان دهنده طول بیتهای تشکیل دهنده یک کاراکتر یعنی 07
دو بایت بعدی : برای گزارش ارسال (دلایوری) که در اینجا 11 وارد میشه
دو بایت بعدی شماره رفرنس پیام که 00 وارد میشه و خود مودم ان را مقدار دهی میکنه
دوبایت بعدی برای مشخص کردن تعداد شماره های مقصد استفاده میشه توجه داشته باشین اعداد باید زوج باشن پس شماره موبایل های ما که 11 رقمی باید 12 رقمی در نظر گرفته بشن پی مقداری 0B را برای این قسمت وارد میکنیم
دوبایت بعدی برای مشخص کردن نوع شماره است که 91 برای شماره های بین المللی و 81 برای شماره های محلی استفاده میشه
کارکترهای بعدی شماره تلفنی است که قراره پیام را دریافت کنه که به طریق زیر کد میشه

مثلا 12345678901 اگه شماره موبایل باشه باید یک F به اون اضافه بشه تا طولش 12 کارکتر بشه و بعد اعداد دو به دو جابه جا میشن 2134567809F1



بعد از وارد کردن شماره دریافت کننده
دو بایت بعدی برای باید Tp-PID را وارد کنید که توضیحاتش را میتونین از اینجا ببینین
http://www.dreamfabric.com/sms/pid.html
که ما مقدار 00 را برای این قسمت در نظر میگیریم
دو بایت بعدی TP-DCS که مشخص کننده کلاس - نوع کد گذاری - فشرده سازی و ... است
که به این صورت ساخته میشه
Bit 1-0 شماره كلاس:
00 بدون كلاس
01 كلاس 1
10 كلاس 2
11 كلاس 3

Bit 3-2 كدگزاري:
00 Defualt (7bit)
01 8Bit
10 usc16
11 reserve

Bit 4 كلاس :
0 بدون كلاس
1 داراي كلاس

Bit 5 فشرده سازي:
0 فشرده نشده
1 فشرده شده

برای این قسمت شما 00 را در نظر بگیرید
دو بایت بعدیTP-Validity-Period که در واقع طول مدت اعتبار پیامه که به این صورت محاسبه میشه


0 to 143

(TP-VP + 1) * 5 minutes (i.e. 5 minutes intervals up to 12 hours)

144 to 167

12 hours + ((TP-VP - 143) * 30 minutes)

168 to 196

(TP-VP - 166) * 1 day

197 to 255

(TP-VP - 192) * 1 week



مثلا 7 روز میشه

دو بایت بعدی طول متن پیام PDU شماست TP-User-Data-Length
توجه داشته باشین که این طور برحسب طول پیام بر حسب هگزادسیمال باید وارد بشه نه اصل

بعد از اون شما باید پیام را که بصورت 7 بیت کد کردین قرار بدین

06543210 6543210

10654321 6543210

21065432 6543210

32106543 6543210

43210654 6543210

54321065 6543210

65432106 6543210

6543210




یک مثال


0011000b819031034881F80000AD023119
یک پیام با متن 12 برای شماره 09133084188 ارسال میکنه


00

11

00

0B

81

9031034881F8

00

00

AD

02

31 19

ali_mohamadi8928
یک شنبه 12 خرداد 1387, 20:54 عصر
ممنون noorsoft عزيز . فكر كنم دليل اين قاطي بودن مقالت اينه كه قبلا يه جايي نوشته بودي بعد كپيش كردي اينجا كه همه چي قاطي شده .. لطفا رسيديگي كن و درستش كن .

راستي يك سورس براي كار با PDU داري بزاري اينجا رو تكميل كني .. البته به زبانهاي دات نت نباشه ها !!!

مهران موسوی
دوشنبه 13 خرداد 1387, 14:16 عصر
دوست خوبم اقاي يعقوبي يك نمونه در بخش دلفي معرفي كردن ... ميتونيد يك جست جو كوچيك بزنيد توي بخش دلفي .. جزء اولين تاپيكهايي هست كه در نتيجه ي جست جو ديده ميشه ...

noorsoft
دوشنبه 13 خرداد 1387, 21:03 عصر
فعلا قویترین ابزار کنترل
Kylix SMS Server Version 2.1

farzad1
یک شنبه 19 خرداد 1387, 13:48 عصر
ايا با 7 بيت ميشه SMS فارسي فرستاد يا بايد 16 بيت باشه ؟

noorsoft
یک شنبه 19 خرداد 1387, 14:03 عصر
ايا با 7 بيت ميشه SMS فارسي فرستاد يا بايد 16 بيت باشه ؟


فقط با 16 بیت میشه پیام فارسی فرستاد


http://barnamenevis.org/forum/showthread.php?t=108432

prince-of-persia
دوشنبه 04 شهریور 1387, 15:15 عصر
سلام

اگر بخواهیم انتقال پیام به صورت فشرده مثل اون چیزی که همراه اول داده داشته باشیم در قالب PDU چطور باید این کار رو بکنیم ؟
یعنی 200 کاراکتر در مد UCS2 ؟

با تشکر

noorsoft
جمعه 08 شهریور 1387, 08:39 صبح
لطفا یک سوال را دوجا نپرسید.
براتون دنبال یکسری رفرنس هستم منتظر باشید