You are here:
ActiveXperts.com > SMS and MMS Toolkit > About SMS > Sending SMS Data Messages using SMPP
Quicklinks
Besides sending text messages, SMS can also be used to send small data messages. A single SMS message can contain up to 140 bytes of user data. These messages can be used for custom applications, telemetry and over the air programming of the phone or SIM card. Messages such as ringtones, operator logos and WAP Push messages are also encoded as datamessages.
To send a simple data message to a device that can process the messages by itself, you only have to change the 'DCS' parameter of the message. This is used for instance by telemetry devices.
Valid values for this 'DCS' paramater are:
0xF5 - Send the 8 bit datamessage to an application on the phone 0xF6 - Send the 8 bit datamessage to an application on the SIM (SIM Toolkit)
In some languages, when the standard GSM Alphabet is not sufficient, 8 bit data SMS is also used to send text messages.
You can find a sample for sending a simple data message using an SMPP connection:
Option Explicit
'Declare Variables
Dim objSmsProtocol
Dim objSmsMessage
Dim objSmsConstants
Dim strHex
' Create Objects
Set objSmsProtocol = CreateObject ( "ActiveXperts.SmsProtocolSmpp" )
Set objSmsMessage = CreateObject ( "ActiveXperts.SmsMessage" )
Set objSmsConstants = CreateObject ( "ActiveXperts.SmsConstants" )
'Define Data
strHex = "000102030405060708090A0B0C0D0E0F"
' Set connection properties
objSmsProtocol.Server = "smpp.activexperts-labs.com"
objSmsProtocol.ServerPort = 2775
objSmsProtocol.SystemID = "AX008"
objSmsProtocol.SystemPassword = "812056"
objSmsProtocol.SystemType = "SMPP"
objSmsProtocol.ServerTimeout = 3000
objSmsProtocol.SystemMode = objSmsConstants.asSMPPMODE_TRANSMITTER
' Set Logfile
objSmsProtocol.LogFile = "C:\SmsData.log"
' Set Message Properties
objSmsMessage.Clear ()
objSmsMessage.Recipient = "+31647134225"
objSmsMessage.Data = strHex
objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_DATA
'Send the message
objSmsProtocol.Connect
WScript.Echo "Connect, result: " & objSmsProtocol.LastError & " (" & objSmsProtocol.GetErrorDescription ( objSmsProtocol.LastError ) & ")"
If( objSmsProtocol.LastError <> 0 ) Then
WScript.Quit
End If
objSmsProtocol.Send ( objSmsMessage )
objSmsProtocol.Disconnect
' Display the result
WScript.Echo "Sending data message, result: #" & objSmsProtocol.LastError & " (" & objSmsProtocol.GetErrorDescription ( objSmsProtocol.LastError ) & ")"
Mobile phones have the capability to listen to a specific port number, similar to UDP/TCP ports in a TCP/IP Network. You can send data to a specific phone port by using the WDP (Wireless Datagram Protocol) Protocol. This protocol can be encapsulated in the UDH (User Data Header) of the SMS.
The following UDH bytes are used to send data to port 1234 on the mobile phone:
06 05 04 04D2 0000 06 Length of UDH Header 05 Port addressing 04 Destination Port D2 1234 ( 0x04D2 HEX ) 00 Source Port 00 0
To notify the receiving phone that you included an User Data Header in your message, you should set the UDH indicator bit in the SMS. The bit is bit 6 of the esm_class byte in the SMPP submit_sm packet of the message. The sample below demonstrates how to send data to an application port of a mobile phone:
Option Explicit 'Declare Variables Dim objSmsProtocol Dim objSmsMessage Dim objSmsConstants Dim strHex ' Create Objects Set objSmsProtocol = CreateObject ( "ActiveXperts.SmsProtocolSmpp" ) Set objSmsMessage = CreateObject ( "ActiveXperts.SmsMessage" ) Set objSmsConstants = CreateObject ( "ActiveXperts.SmsConstants" ) ' Set UDH Header strHex = "06050404D20000" 'Define Data strHex = strHex + "000102030405060708090A0B0C0D0E0F" ' Set connection properties objSmsProtocol.Server = "smpp.activexperts-labs.com" objSmsProtocol.ServerPort = 2775 objSmsProtocol.SystemID = "AX008" objSmsProtocol.SystemPassword = "812056" objSmsProtocol.SystemType = "SMPP" objSmsProtocol.ServerTimeout = 3000 objSmsProtocol.SystemMode = objSmsConstants.asSMPPMODE_TRANSMITTER ' Set Logfile objSmsProtocol.LogFile = "C:\SmsData.log" ' Set Message Properties objSmsMessage.Clear () objSmsMessage.Recipient = "+31647134225" objSmsMessage.Data = strHex objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_DATA_UDH 'Send the message objSmsProtocol.Connect WScript.Echo "Connect, result: " & objSmsProtocol.LastError & " (" & objSmsProtocol.GetErrorDescription ( objSmsProtocol.LastError ) & ")" If( objSmsProtocol.LastError <> 0 ) Then WScript.Quit End If objSmsProtocol.Send ( objSmsMessage ) objSmsProtocol.Disconnect ' Display the result WScript.Echo "Sending data message, result: #" & objSmsProtocol.LastError & " (" & objSmsProtocol.GetErrorDescription ( objSmsProtocol.LastError ) & ")"
There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/xmstoolkit.