Solved

Decode PDU for SMS

Posted on 2004-04-21
14
4,507 Views
Last Modified: 2007-12-19
I need a function to convert the incomming message in PDU mode when using the AT+CMGL command on a Siemens S55 mobile. If the incoming string was
07 917283010010F5 040BC87238880900F10000993092516195800AE8329BFD4697D9EC37
 Does anyone have a ready-made function/s to translate all the elements, especially the sms message at the end?
0
Comment
Question by:jxharding
  • 4
  • 4
  • 3
  • +3
14 Comments
 
LVL 21

Expert Comment

by:tovvenki
ID: 10885543
Hi,
In which language do you need the function.

regards,
Venki
0
 

Author Comment

by:jxharding
ID: 10885928
vb6 if possible please,  .net would do as well
thank you
0
 
LVL 21

Expert Comment

by:tovvenki
ID: 10886579
Hi,
I am sorry I have not done that in Vb6 or .Net but have alook at this link on SMS Messages and PDU then try to implement the logic in vb6 or .Net
http://www.dreamfabric.com/sms/

I hope that this helps you.

Venki
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:jxharding
ID: 10887040
thanks venki, can i ask in what language do you have it,
maybe i can have a look at the logic and implement it.
thanks!
0
 
LVL 21

Expert Comment

by:tovvenki
ID: 10887513
Hi,
I had it java, but I am sorry I can't release the source code because of an agreement. But decoding the sms message is very easy. Just have alook at the url that I have mentioned you. First manually separate the messages as specified in the article. Then you can just code that manual logic in Vb or Vb.net

Regards,
Venki
0
 
LVL 4

Expert Comment

by:venishjoe
ID: 10892710
Hai,

Have a look at it

Dim objDecoder As New SMSEngineLib.SMSMessageManager
Dim objSMSMessage As SMSEngineLib.SMSMessage
Dim objPictureMessage As SMSEngineLib.PictureMessage
Dim objPDU As SMSEngineLib.PDU

'Decode the incoming PDU
Set objSMSMessage = objDecoder.DecodePDU( _
    "07912121212121F2440B911313131313F100F5301071514" & _
    "521448A0605041583000000480E01000000000000000000" & _
    "0000000000000000000C00060000C1B031F00C00660000C" & _
    "1B033181E00600000633873181E1EF6C33C363873001233" & _
    "66C3661C3CF1C0333066667E1C3CF07033306666603637B" & _
    "0183F30663C606337B31861B3661866C1B33318619E3618" & _
    "3CC1B331F0000000000000000000000000000000000000")

'Do we have the complete PDU?
If objSMSMessage.State = Waiting Then Exit Sub 'Come back later with the next PDU

If objSMSMessage.MessageType = PictureMessage Then

    'Cast to a PictureMessage message to get specific properties
    Set objPictureMessage = objSMSMessage

    'Report on some of the incoming message properties
    Debug.Print "Image for Picture Message: " + objPictureMessage.BitmapFileName
    Debug.Print "Sent from: " + objPictureMessage.SenderAddress
    Debug.Print "Message arrived: " + objPictureMessage.PDUs.Item(1).ArrivalDate

End If

The SDK is present in http://www.businesms.com/samplecode_sms.htm

HAVE A LOOK AT THE FOLLOWING LINK.ITS VERY GOOD
http://www.codeproject.com/library/smpplib.asp

Also Refer

http://www.componentsource.com/Catalog.asp?fl=&bc=&sc=CS&sr=Decode%20PDU%20for%20SMS%20.net&bhcp=1

Hope this helps

Regards
Venish
0
 
LVL 4

Accepted Solution

by:
SimonTay earned 500 total points
ID: 10900667
Or in VB6 source :

Attribute VB_Name = "SMS"
Option Explicit
Public Const A1C = 1     'these are used to construct appropriate PDU for each modem
Public Const M1C = 2

Type SMSType        ' Create user-defined type.
    PDULength As Integer   ' Define elements of data type.
    PDU As String * 500
End Type
Dim SMS As SMSType
Public Function EncodeOutgoingSMS(PDUType As Integer, Number As String, Message As String, PDUInternational As Integer) As String
 Dim i As Integer
 EncodeOutgoingSMS = ""
 If PDUType = A1C Then EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(&H0) 'TP-MTI etc
 If PDUType = M1C Then EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(&H1)   'PDU type
 If PDUType = A1C Then EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(&H11)   'PDU type
 EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(&H0)        'increment each time TP-MR message reference, the M1 does this for you
 EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(Len(Number))     'length of destination address
 If PDUInternational Then
  EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(&H91)      'International number and national numbering plan
 Else
  EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(&H81)      'National numbering plan
 End If
 For i = 1 To Len(Number) / 2
  EncodeOutgoingSMS = EncodeOutgoingSMS & Mid(Number, i * 2, 1) & Mid(Number, i * 2 - 1, 1)
 Next i
 If Len(Number) / 2 <> Int(Len(Number) / 2) Then EncodeOutgoingSMS = EncodeOutgoingSMS & "F" & Mid(Number, i * 2 - 1, 1)
 EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(&H0)        ' TP-PID
 EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(&H0)          'TP-DCS
 If PDUType = A1C Then EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(&HAA)      'TP-VDF
EncodeOutgoingSMS = EncodeOutgoingSMS & ASCIIHex(Len(Message))
 EncodeOutgoingSMS = EncodeOutgoingSMS & MessageEncode(Message)
End Function
Private Function MessageEncode(InMsg As String) As String
 Dim i As Integer, Byterev As Integer, Bits As Integer, Eightbit As Integer
 Dim Msg As String
 For i = 1 To Len(InMsg)
  Byterev = Byterev * 128       'shift left 7 bits
  Byterev = Byterev + Rev(Asc(Mid(InMsg, i, 1)), 7)
  Bits = Bits + 7
  While Bits >= 8
   Eightbit = Int(Byterev / 2 ^ (Bits - 8))
   Byterev = Byterev - Eightbit * 2 ^ (Bits - 8)
   Bits = Bits - 8
   Msg = Msg & ASCIIHex(Rev(Eightbit, 8))
  Wend
 Next i
 If Bits > 0 Then
  Byterev = Byterev * 128       'shift left 7 bits
  Bits = Bits + 7
  Eightbit = Int(Byterev / 2 ^ (Bits - 8))
  Msg = Msg & ASCIIHex(Rev(Eightbit, 8))
 End If
 MessageEncode = Msg
End Function
Function Rev(Byted As Integer, B As Integer) As Integer
 Dim j As Integer, Value As Integer
 For j = 0 To B - 1
  If Byted And 2 ^ j Then Value = Value + 2 ^ (B - 1 - j)
 Next j
 Rev = Value
End Function
Private Function ASCIIHex(Value) As String
 ASCIIHex = Right("0" & Hex$(Value), 2)
End Function

Simon
0
 

Author Comment

by:jxharding
ID: 10912075
Hi SimonTay
I have working code for the outgoing, I am looking for the incomming code. I am receiving an sms using "at+cmgl" and I need to decode the pdu message. If you could be so kind as to post the incomming code I would be grateful. Thank you for the code Venishjoe, but the sdk only demo's a send and not a receive. I have to show my prospective client the full program and once he purchases my product then I will buy the full version and incorporate it into my program. Thanks once again.

0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10946133
0
 
LVL 4

Expert Comment

by:SimonTay
ID: 10947096
Private Function DecodeIncomingSMS() As String
 Dim s As String, pid As Integer, udl As Integer, i As Integer, of As Integer
 
 Result.Cls
 
 s = SMS_Data
 For i = 1 To Len(s) / 2: sms_deliver(i) = Val("&H" + Mid$(s, i * 2 - 1, 2)): Next i
 'Debug.Print Mid$(s, 39, 2); Val("&H" & Mid$(s, 39, 2)), sms_deliver(20)
 If sms_deliver(1) = 7 Then 'this bit is assumed - we really don't know!!!
  Result.Print "A1 PDU"
  Result.Print "Type of address "; Hex$(sms_deliver(2))
  Result.Print "Service centre ";
  For i = 1 To 6
   Result.Print Chr(48 + (sms_deliver(2 + i) And 15)); Chr(48 + Int(sms_deliver(2 + i) / 16));
  Next i: Result.Print
  of = 8
 Else
  of = 0
 End If
 Result.Print "TP-RP "; Bit(sms_deliver(of + 1), 7)
 Result.Print "TP-UDHI "; Bit(sms_deliver(of + 1), 6)
 Result.Print "TP-SRI "; Bit(sms_deliver(of + 1), 5)
 Result.Print "TP-MMS "; Bit(sms_deliver(of + 1), 2)
 Result.Print "TP-MTI "; Bit(sms_deliver(of + 1), 1); Bit(sms_deliver(of + 1), 0)
 Result.Print "TP-OA Length"; sms_deliver(of + 2)
 Result.Print "Type of address "; Hex$(sms_deliver(of + 3))
 Result.Print "Originating address ";
 For i = 1 To sms_deliver(of + 2) / 2
  Result.Print Chr(48 + (sms_deliver(of + 3 + i) And 15)); Chr(48 + Int(sms_deliver(of + 3 + i) / 16));
 Next i: Result.Print
 
 pid = sms_deliver(of + 2) / 2 + of + 4
 Result.Print "TP-PID"; sms_deliver(pid)
 Result.Print "TP-DCS"; sms_deliver(pid + 1)
 Result.Print "SCTS";
 For i = 0 To 6: Result.Print (sms_deliver(pid + 2 + i) And 15) * 10 + Int(sms_deliver(pid + 2 + i) / 16);: Next i: Result.Print
 udl = pid + 9
 Result.Print "UDL"; sms_deliver(udl)
 If Bit(sms_deliver(of + 1), 6) = 1 Then
  'message has a header
 Else
  For i = 1 To sms_deliver(udl)
   dat(i) = sms_deliver(udl + i)
  Next i
  Result.Print MessageDecode(sms_deliver(udl)); "<end"
  DecodeIncomingSMS = MessageDecode(sms_deliver(udl))
 End If
End Function
Private Sub Delay(DelayTime As Double)
 MS50 = 0
 Do While MS50 < DelayTime
  DoEvents
 Loop
End Sub

Private Function MessageDecode(udl) As String
 Dim i As Integer, Byterev As Integer, Bits As Integer, sevenbit As Integer
 Dim Msg As String, p As Integer
 p = 1
 i = 1
 While p <= udl
  Byterev = Byterev * 256       'shift left 8 bits
  Byterev = Byterev + Rev(dat(i), 8)
  i = i + 1
  Bits = Bits + 8
  While Bits >= 7
   sevenbit = Int(Byterev / 2 ^ (Bits - 7))
   Byterev = Byterev - sevenbit * 2 ^ (Bits - 7)
   Bits = Bits - 7
   Msg = Msg & Chr(Rev(sevenbit, 7))
   p = p + 1
  Wend
 Wend
 MessageDecode = Msg
End Function

Function Rev(Byted As Integer, B As Integer) As Integer
 Dim j As Integer, Value As Integer
 For j = 0 To B - 1
  If Byted And 2 ^ j Then Value = Value + 2 ^ (B - 1 - j)
 Next j
 Rev = Value
End Function

This should help!

Simon

0
 

Author Comment

by:jxharding
ID: 10948241
Thank you Simon, you are a star. Could you tell me what the "bit"  function is?
0
 
LVL 4

Expert Comment

by:SimonTay
ID: 10950105
It just displays a 1 or a 0 depending on the value of the bit position, so bit(8,3) would display 1, bit (8,2) would display 0.
0
 
LVL 4

Expert Comment

by:SimonTay
ID: 10950116
Private Function Bit(Value, B) As Variant
 If Value And 2 ^ B Then
  Bit = "1"
 Else
  Bit = "0"
 End If
End Function
0
 
LVL 1

Expert Comment

by:Tutanhamon
ID: 12505847
TRY this .Net component
http://www.sharkysms.com/SMSModem.zip

it will do the stuff you want
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Coaxial cable bending There are several factors that govern the selection of coaxial cable for your Machine to Machine (M2M) application: the location of cable runs, either indoor or outdoor, inside or outside an enclosure, maximum bending and the…
This article is a step by step guide on how to create a basic PTP link using Ubiquiti airOS devices. This guide can be used on the following Ubiquiti AirMAX devices. Nanostation, Bullets, AirBridge, Nanobeam, NanoBridge to name a few. Please review …
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question