vb6 if possible please, .net would do as well
thank you
Main Topics
Browse All TopicsI 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 040BC87238880900F100009930
Does anyone have a ready-made function/s to translate all the elements, especially the sms message at the end?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
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
I hope that this helps you.
Venki
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
Hai,
Have a look at it
Dim objDecoder As New SMSEngineLib.SMSMessageMan
Dim objSMSMessage As SMSEngineLib.SMSMessage
Dim objPictureMessage As SMSEngineLib.PictureMessag
Dim objPDU As SMSEngineLib.PDU
'Decode the incoming PDU
Set objSMSMessage = objDecoder.DecodePDU( _
"07912121212121F2440B91131
"521448A060504158300000048
"0000000000000000000C00060
"1B033181E0060000063387318
"66C3661C3CF1C0333066667E1
"0183F30663C606337B31861B3
"3CC1B331F0000000000000000
'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.BitmapFi
Debug.Print "Sent from: " + objPictureMessage.SenderAd
Debug.Print "Message arrived: " + objPictureMessage.PDUs.Ite
End If
The SDK is present in http://www.businesms.com/s
HAVE A LOOK AT THE FOLLOWING LINK.ITS VERY GOOD
http://www.codeproject.com
Also Refer
http://www.componentsource
Hope this helps
Regards
Venish
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
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.
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(
DecodeIncomingSMS = MessageDecode(sms_deliver(
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
TRY this .Net component
http://www.sharkysms.com/S
it will do the stuff you want
Business Accounts
Answer for Membership
by: tovvenkiPosted on 2004-04-21 at 21:52:06ID: 10885543
Hi,
In which language do you need the function.
regards,
Venki