PDUDecoder ---我在CodeProject上写的一篇文章[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 hesicong 的 blog

sample screenshot

introduction

   wish to develop sms or ems application? what you read from your mobile? pdu code.
pdu is a format which you send to phone to send a sms or an ems. you can find more in gsm 03.40.

what is a pdu code and how can i decode it?

   let us take a simple look at pdu code. here i created a sms "hello,my pretty world!" in my siemens m55 mobile and send it to 1861. i use hyperterminal to communicate with my phone using at command set.
   first i set my character set to unicode:
   at+cscs="ucs2"
   then i set my preferred message storage to mt
   at+cpms="mt"
   at last i read all my sms out.
   at+cmgl=4
   i find the sms i just created in pdu format:
0891683108200805f01151048181160000ff16c8329bfd66b5f320b8bc4ca7e741f7b79c4d0e01
    now we decode it manually.
  08: length of service center number
  91: indicate there is a plus at the beginning of service center number
  683108200805f: service center number: 8613800280500 note when the length of number is an odd number, add f.
  11: indicate this sms will be sent.
  51: tp-mr message reference, not common used.
  04: length of destination number. here 1861.
  81: no plus here.
  8161: destination number 1861.
  00: tp-pid. see gsm 03.40
  00: tp-dcs. tp-ud is coded by 7bit charactor method. see gsm 03.38
  ff: tp-vp. valid period. here is infinity.
  16: hex value equals to 22. this indicates there are 22 charactors in tp-ud
  c8329bfd66b5f320b8bc4ca7e741f7b79c4d0e01: tp-ud, decode it using 7bit charactor method.
   ha-ha, now you may know more about pdu code. let start our program.

what is the structure of my pdu decoder?

   i created a must inherit class sms, it provides basic structure a sms must have. for example: something relate to service center, first octet, tp_pid and so on.
   in this class i provide a must override sub getorignaldata, this help me to do further work on the orignal data from pdu code.
   here are also a few of shared functions:
   getbyte(),getstring(),getdate(),swap(),getaddress(),getsmstype(),decodeunicode90,decode7bit()
   there shared functions will be used frequently.
   after sms class, i create sms_received,sms_submit,ems_received,ems_submit,sms_status_report class that inherits from sms class.

how it works?

    i want once you created an instance of one class with a pdu code, it decode it immediately. so i write some code in every sub new.

本文关键:PDUDecoder ---我在CodeProject上写的一篇文章
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top