📄 sms.vb
字号:
TP_SCTS = GetDate(GetString(PDUCode, 14))
TP_DP = GetDate(GetString(PDUCode, 14))
Select Case GetByte(PDUCode)
Case 0
Status = EnumStatus.Success
Case 96
Status = EnumStatus.NotSend
Case 98
Status = EnumStatus.NoResponseFromSME
End Select
'Status report do not have content so I set it a zero length string
TP_UD = ""
End Sub
End Class
''' -----------------------------------------------------------------------------
''' Project : SMS Solution
''' Class : SMS.Decoder.PDUDecoder
'''
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [AMDXP2500] 2005-7-25 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class PDUDecoder
''' -----------------------------------------------------------------------------
''' Project : SMS Solution
''' Class : SMS.Decoder.PDUDecoder.BaseInfo
'''
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [AMDXP2500] 2005-7-25 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class BaseInfo
Public SourceNumber As String
Public DestinationNumber As String
Public ReceivedDate As Date
Public Text As String
Public Type As SMS.Decoder.SMSBase.SMSType
Public EMSTotolPiece As Integer
Public EMSCurrentPiece As Integer
Public StatusFromReport As SMS_STATUS_REPORT.EnumStatus
Public DestinationReceivedDate As Date
End Class
Sub New(ByVal PDUCode As String)
Decode(PDUCode)
End Sub
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <param name="PDUCode"></param>
''' <returns></returns>
''' <remarks>
''' </remarks>
''' <history>
''' [AMDXP2500] 2005-7-25 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Shared Function Decode(ByVal PDUCode As String) As BaseInfo
Dim Result As New BaseInfo
Try
Dim T As SMSBase.SMSType = SMSBase.GetSMSType(PDUCode)
Result.Type = T
Select Case T
Case SMSBase.SMSType.EMS_RECEIVED
Dim s As New EMS_RECEIVED(PDUCode)
Result.SourceNumber = s.SrcAddressValue
If s.SrcAddressType = &H91 Then Result.SourceNumber = "+" + Result.SourceNumber
Result.ReceivedDate = s.TP_SCTS
If Not (s.IE Is Nothing) Then
Dim Data As String = s.IE(0).Data
Result.EMSTotolPiece = CInt(Mid(Data, 5, 2))
Result.EMSCurrentPiece = CInt(Mid(Data, 7, 2))
End If
If s.TP_DCS = 0 Then
Result.Text = SMSBase.Decode7Bit(s.TP_UD, CInt(s.TP_UDL - 8 * (1 + s.TP_UDHL) / 7))
Else
Result.Text = SMSBase.DecodeUnicode(s.TP_UD)
End If
Case SMSBase.SMSType.SMS_RECEIVED
Dim s As New SMS_RECEIVED(PDUCode)
Result.SourceNumber = s.SrcAddressValue
If s.SrcAddressType = &H91 Then Result.SourceNumber = "+" + Result.SourceNumber
Result.ReceivedDate = s.TP_SCTS
If s.TP_DCS = 0 Then
Result.Text = SMSBase.Decode7Bit(s.TP_UD, s.TP_UDL)
Else
Result.Text = SMSBase.DecodeUnicode(s.TP_UD)
End If
Case SMSBase.SMSType.EMS_SUBMIT
Dim s As New EMS_SUBMIT(PDUCode)
Result.DestinationNumber = s.DesAddressValue
If s.DesAddressType = &H91 Then Result.DestinationNumber = "+" + Result.DestinationNumber
If Not (s.IE Is Nothing) Then
Dim Data As String = s.IE(0).Data
Result.EMSTotolPiece = CInt(Mid(Data, 5, 2))
Result.EMSCurrentPiece = CInt(Mid(Data, 7, 2))
End If
If s.TP_DCS = 0 Then
Result.Text = SMSBase.Decode7Bit(s.TP_UD, CInt(s.TP_UDL - 8 * (1 + s.TP_UDHL) / 7))
Else
Result.Text = SMSBase.DecodeUnicode(s.TP_UD)
End If
Case SMSBase.SMSType.SMS_SUBMIT
Dim s As New SMS_SUBMIT(PDUCode)
Result.DestinationNumber = s.DesAddressValue
If s.DesAddressType = &H91 Then Result.DestinationNumber = "+" + Result.DestinationNumber
If s.TP_DCS = 0 Then
Result.Text = SMSBase.Decode7Bit(s.TP_UD, s.TP_UDL)
Else
Result.Text = SMSBase.DecodeUnicode(s.TP_UD)
End If
Case SMSBase.SMSType.SMS_STATUS_REPORT
Dim s As New SMS_STATUS_REPORT(PDUCode)
Result.SourceNumber = s.SrcAddressValue
If s.SrcAddressType = &H91 Then Result.SourceNumber = "+" + Result.SourceNumber
Result.ReceivedDate = s.TP_SCTS
Result.DestinationReceivedDate = s.TP_DP
Result.StatusFromReport = s.Status
If s.TP_DCS = 0 Then
Result.Text = SMSBase.Decode7Bit(s.TP_UD, s.TP_UDL)
Else
Result.Text = SMSBase.DecodeUnicode(s.TP_UD)
End If
Case Else
Stop
End Select
Catch err As Exception
Result.Text = "PDU解码错误:" & PDUCode
End Try
Return Result
End Function
End Class
End Namespace
Namespace Encoder
''' -----------------------------------------------------------------------------
''' Project : SMS Solution
''' Class : SMS.Encoder.SMS
'''
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [AMDXP2500] 2005-7-25 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class SMS
#Region "Enums"
Public Enum ENUM_TP_VPF
Relative_Format = 16 'b4=1 b3=0
End Enum
Public Enum ENUM_TP_SRI
Request_SMS_Report = 32
No_SMS_Report = 0
End Enum
Public Enum ENUM_TP_DCS
DefaultAlphabet = 0
UCS2 = 8
End Enum
Public Enum ENUM_TP_VALID_PERIOD
OneHour = 11 '0 to 143:(TP-VP+1)*5Min
ThreeHours = 29
SixHours = 71
TwelveHours = 143
OneDay = 167
OneWeek = 196
Maximum = 255
End Enum
#End Region
#Region "Private Data"
Protected SC_Number As String 'Note the plus!
Protected TP_MTI As Byte = 1
Protected TP_RD As Byte = 0
Protected TP_VPF As Byte = 16
Protected TP_UDHI As Byte
Protected TP_SRR As ENUM_TP_SRI
Protected TP_MR As Integer
Protected TP_DA As String
Protected TP_PID As Byte
Protected TP_DCS As ENUM_TP_DCS
Protected TP_VP As ENUM_TP_VALID_PERIOD
Protected TP_UDL As Integer
Protected TP_UD As String
#End Region
#Region "Properties"
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <value></value>
''' <remarks>
''' </remarks>
''' <history>
''' [AMDXP2500] 2005-7-25 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Property ServiceCenterNumber() As String
Get
Return SC_Number
End Get
Set(ByVal Value As String)
'Convert an ServiceCenterNumber to PDU Code
If InStr(Value, "+") > 0 Then
SC_Number = "91"
Else
SC_Number = "81"
End If
Value = Mid(Value, 2)
Dim i As Integer
If (Value.Length Mod 2) = 1 Then
Value += "F"
End If
For i = 1 To Value.Length Step 2
SC_Number += Swap(Mid(Value, i, 2))
Next
SC_Number = ByteToHex(CByte((SC_Number.Length - 2) / 2 + 1)) & SC_Number
End Set
End Property
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <value></value>
''' <remarks>
''' </remarks>
''' <history>
''' [AMDXP2500] 2005-7-25 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Property TP_Status_Report_Request() As ENUM_TP_SRI
Get
Return TP_SRR
End Get
Set(ByVal Value As ENUM_TP_SRI)
TP_SRR = Value
End Set
End Property
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <value></value>
''' <remarks>
''' </remarks>
''' <history>
''' [AMDXP2500] 2005-7-25 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Property TP_Message_Reference() As Integer
Get
Return TP_MR
End Get
Set(ByVal Value As Integer)
TP_MR = Value
End Set
End Property
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <value></value>
''' <remarks>
''' </remarks>
''' <history>
''' [AMDXP2500] 2005-7-25 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Property TP_Destination_Address() As String
Get
Return TP_DA
End Get
Set(ByVal Value As String)
TP_DA = ""
If InStr(Value, "+") > 0 Then
TP_DA += "91"
Else
TP_DA += "81"
End If
Value = Value.Replace("+", "")
TP_DA = Format(Value.Length, "X2") + TP_DA
Dim i As Integer
If (Value.Length Mod 2) = 1 Then
Value += "F"
End If
For i = 1 To Value.Length Step 2
TP_DA += Swap(Mid(Value, i, 2))
Next
End Set
End Property
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <value></value>
''' <remarks>
''' </remarks>
''' <history>
''' [AMDXP2500] 2005-7-25 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Property TP_Data_Coding_Scheme() As ENUM_TP_DCS
Get
Return TP_DCS
End Get
Set(ByVal Value As ENUM_TP_DCS)
TP_DCS = Value
End Set
End Property
''' -----------------------------------------------------------------------------
''' <summary>
'''
''' </summary>
''' <value></value>
''' <remarks>
''' </remarks>
''' <history>
''' [AMDXP2500] 2005-7-25 Created
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -