Appendix   A
 

GSM SMS Adapter

This appendix describes an adapter that uses the messaging API with the GSM Short Message Service.

A.1.0 GSM SMS Message Structure

The GSM SMS messages are defined in the GSM 03.40 standard [1]. The message consists of a fixed header and a field called TP-User-Data. The TP-User-Data field carries the payload of the short message and optional header information that is not part of the fixed header. This optional header information is contained in a field called User-Data-Header. The presence of optional header information in the TP-User-Data field is indicated by a separate field that is part of the fixed header.

The TP-User-Data can use different encodings depending on the type of the payload content. Possible encodings are a 7-bit alphabet defined in the GSM 03.38 standard, 8-bit binary data, or 16-bit UCS-2 alphabet.

A.1.1 Message Payload Length

The maximum length of the SMS protocol message payload depends on the encoding and whether there are optional headers present in the TP-User-Data field. If the optional header information specifies a port number, then the payload which fits into the SMS protocol message will be smaller. Typically, the message is displayed to the end user. However, this Java API supports the use of port numbers to specify a Java application as the message target.

The messages that the Java application sends can be too long to fit in a single SMS protocol message. In this case, the implementation MUST use the concatenation feature specified in sections 9.2.3.24.1 and 9.2.3.24.8 of the GSM 03.40 standard [1]. This feature can be used to split the message payload given to the Java API into multiple SMS protocol messages. Similarly, when receiving messages, the implementation MUST automatically concatenate the received SMS protocol messages and pass the fully reassembled payload to the application via the API.

A.1.2 Message Payload Concatenation

The GSM 03.40 standard [1] specifies two mechanisms for the concatenation, specified in sections 9.2.3.24.1 and 9.2.3.24.8. They differ in the length of the reference number. For messages that are sent, the implementation can use either mechanism. For received messages, implementations MUST accept messages with both mechanisms.

Note: Depending on which mechanism is used for sending messages, the maximum length of the payload of a single SMS protocol message differs by one character/byte. For concatenation to work, regardless of which mechanism is used by the implementation, applications are recommended to assume the 16-bit reference number length when estimating how many SMS protocol messages it will take to send a given message. The lengths in Table A-1 below are calculated assuming the 16-bit reference number length.

Implementations of this API MUST support at least 3 SMS protocol messages to be received and concatenated together. Similarly, for sending, messages that can be sent with up to 3 SMS protocol messages MUST be supported. Depending on the implementation, these limits may be higher. However, applications are advised not to send messages that will take up more than 3 SMS protocol messages, unless they have reason to assume that the recipient will be able to handle a larger number. The MessageConnection.numberOfSegments method allows the application to check how many SMS protocol messages a given message will use when sent.

Table A-1: Number of SMS protocol messages needed for different payload lengths

Optional Headers Encoding
No port number present (message to be displayed to the end user)
Port number present (message targeted at an application)
 
Length
SMS messages
Length
SMS messages
GSM 7-bit alphabet
0-160 chars
1
0-152 chars
1
 
161-304 chars
2
153-290 chars
2
 
305-456 chars
3
291-435 chars
3
8-bit binary data
0-140 bytes
1
0-133 bytes
1
 
41-266 bytes
2
134-254 bytes
2
 
267-399 bytes
3
255-381 bytes
3
UCS-2 alphabet
0-70 chars
1
0-66 chars
1
 
71-132 chars
2
67-126 chars
2
 
133-198 chars
3
127-189 chars
3

Table A-1 assumes for the GSM 7-bit alphabet that only characters that can be encoded with a single septet are used. If a character that encodes into two septets (using the escape code to the extension table) is used, it counts as two characters in this length calculation.

Note: the values in Table A-1 include a concatenation header in all messages, when the message can not be sent in a single SMS protocol message.

Character Mapping Table

GSM 7-bit
UCS-2
Character name
0x00
0x0040
COMMERCIAL AT
0x01
0x00a3
POUND SIGN
0x02
0x0024
DOLLAR SIGN
0x03
0x00a5
YEN SIGN
0x04
0x00e8
LATIN SMALL LETTER E WITH GRAVE
0x05
0x00e9
LATIN SMALL LETTER E WITH ACUTE
0x06
0x00f9
LATIN SMALL LETTER U WITH GRAVE
0x07
0x00ec
LATIN SMALL LETTER I WITH GRAVE
0x08
0x00f2
LATIN SMALL LETTER O WITH GRAVE
0x09
0x00c7
LATIN CAPITAL LETTER C WITH CEDILLA
0x0a
0x000a
control: line feed
0x0b
0x00d8
LATIN CAPITAL LETTER O WITH STROKE
0x0c
0x00f8
LATIN SMALL LETTER O WITH STROKE
0x0d
0x000d
control: carriage return
0x0e
0x00c5
LATIN CAPITAL LETTER A WITH RING ABOVE
0x0f
0x00e5
LATIN SMALL LETTER A WITH RING ABOVE
0x10
0x0394
GREEK CAPITAL LETTER DELTA
0x11
0x005f
LOW LINE
0x12
0x03a6
GREEK CAPITAL LETTER PHI
0x13
0x0393
GREEK CAPITAL LETTER GAMMA
0x14
0x039b
GREEK CAPITAL LETTER LAMDA
0x15
0x03a9
GREEK CAPITAL LETTER OMEGA
0x16
0x03a0
GREEK CAPITAL LETTER PI
0x17
0x03a8
GREEK CAPITAL LETTER PSI
0x18
0x03a3
GREEK CAPITAL LETTER SIGMA
0x19
0x0398
GREEK CAPITAL LETTER THETA
0x1a
0x039e
GREEK CAPITAL LETTER XI
0x1b
xxx
escape to extension table
0x1c
0x00c6
LATIN CAPITAL LETTER AE
0x1d
0x00e6
LATIN SMALL LETTER AE
0x1e
0x00df
LATIN SMALL LETTER SHARP S
0x1f
0x00c9
LATIN CAPITAL LETTER E WITH ACUTE
0x20
0x0020
SPACE
0x21
0x0021
EXCLAMATION MARK
0x22
0x0022
QUOTATION MARK
0x23
0x0023
NUMBER SIGN
0x24
0x00a4
CURRENCY SIGN
0x25
0x0025
PERCENT SIGN
0x26
0x0026
AMPERSAND
0x27
0x0027
APOSTROPHE
0x28
0x0028
LEFT PARENTHESIS
0x29
0x0029
RIGHT PARENTHESIS
0x2a
0x002a
ASTERISK
0x2b
0x002b
PLUS SIGN
0x2c
0x002c
COMMA
0x2d
0x002d
HYPHEN-MINUS
0x2e
0x002e
FULL STOP
0x2f
0x002f
SOLIDUS
0x30
0x0030
DIGIT ZERO
0x31
0x0031
DIGIT ONE
0x32
0x0032
DIGIT TWO
0x33
0x0033
DIGIT THREE
0x34
0x0034
DIGIT FOUR
0x35
0x0035
DIGIT FIVE
0x36
0x0036
DIGIT SIX
0x37
0x0037
DIGIT SEVEN
0x38
0x0038
DIGIT EIGHT
0x39
0x0039
DIGIT NINE
0x3a
0x003a
COLON
0x3b
0x003b
SEMICOLON
0x3c
0x003c
LESS-THAN SIGN
0x3d
0x003d
EQUALS SIGN
0x3e
0x003e
GREATER-THAN SIGN
0x3f
0x003f
QUESTION MARK
0x40
0x00a1
INVERTED EXCLAMATION MARK
0x41
0x0041
LATIN CAPITAL LETTER A
0x42
0x0042
LATIN CAPITAL LETTER B
0x43
0x0043
LATIN CAPITAL LETTER C
0x44
0x0044
LATIN CAPITAL LETTER D
0x45
0x0045
LATIN CAPITAL LETTER E
0x46
0x0046
LATIN CAPITAL LETTER F
0x47
0x0047
LATIN CAPITAL LETTER G
0x48
0x0048
LATIN CAPITAL LETTER H
0x49
0x0049
LATIN CAPITAL LETTER I
0x4a
0x004a
LATIN CAPITAL LETTER J
0x4b
0x004b
LATIN CAPITAL LETTER K
0x4c
0x004c
LATIN CAPITAL LETTER L
0x4d
0x004d
LATIN CAPITAL LETTER M
0x4e
0x004e
LATIN CAPITAL LETTER N
0x4f
0x004f
LATIN CAPITAL LETTER O
0x50
0x0050
LATIN CAPITAL LETTER P
0x51
0x0051
LATIN CAPITAL LETTER Q
0x52
0x0052
LATIN CAPITAL LETTER R
0x53
0x0053
LATIN CAPITAL LETTER S
0x54
0x0054
LATIN CAPITAL LETTER T
0x55
0x0055
LATIN CAPITAL LETTER U
0x56
0x0056
LATIN CAPITAL LETTER V
0x57
0x0057
LATIN CAPITAL LETTER W
0x58
0x0058
LATIN CAPITAL LETTER X
0x59
0x0059
LATIN CAPITAL LETTER Y
0x5a
0x005a
LATIN CAPITAL LETTER Z
0x5b
0x00c4
LATIN CAPITAL LETTER A WITH DIARESIS
0x5c
0x00d6
LATIN CAPITAL LETTER O WITH DIARESIS
0x5d
0x00d1
LATIN CAPITAL LETTER N WITH TILDE
0x5e
0x00dc
LATIN CAPITAL LETTER U WITH DIARESIS
0x5f
0x00a7
SECTION SIGN
0x60
0x00bf
INVERTED QUESTION MARK
0x61
0x0061
LATIN SMALL LETTER A
0x62
0x0062
LATIN SMALL LETTER B
0x63
0x0063
LATIN SMALL LETTER C
0x64
0x0064
LATIN SMALL LETTER D
0x65
0x0065
LATIN SMALL LETTER E
0x66
0x0066
LATIN SMALL LETTER F
0x67
0x0067
LATIN SMALL LETTER G
0x68
0x0068
LATIN SMALL LETTER H
0x69
0x0069
LATIN SMALL LETTER I
0x6a
0x006a
LATIN SMALL LETTER J
0x6b
0x006b
LATIN SMALL LETTER K
0x6c
0x006c
LATIN SMALL LETTER L
0x6d
0x006d
LATIN SMALL LETTER M
0x6e
0x006e
LATIN SMALL LETTER N
0x6f
0x006f
LATIN SMALL LETTER O
0x70
0x0070
LATIN SMALL LETTER P
0x71
0x0071
LATIN SMALL LETTER Q
0x72
0x0072
LATIN SMALL LETTER R
0x73
0x0073
LATIN SMALL LETTER S
0x74
0x0074
LATIN SMALL LETTER T
0x75
0x0075
LATIN SMALL LETTER U
0x76
0x0076
LATIN SMALL LETTER V
0x77
0x0077
LATIN SMALL LETTER W
0x78
0x0078
LATIN SMALL LETTER X
0x79
0x0079
LATIN SMALL LETTER Y
0x7a
0x007a
LATIN SMALL LETTER Z
0x7b
0x00e4
LATIN SMALL LETTER A WITH DIARESIS
0x7c
0x00f6
LATIN SMALL LETTER O WITH DIARESIS
0x7d
0x00f1
LATIN SMALL LETTER N WITH TILDE
0x7e
0x00fc
LATIN SMALL LETTER U WITH DIARESIS
0x7f
0x00e0
LATIN SMALL LETTER A WITH GRAVE
0x1b 0x14
0x005e
CIRCUMFLEX ACCENT
0x1b 0x28
0x007b
LEFT CURLY BRACKET
0x1b 0x29
0x007d
RIGHT CURLY BRACKET
0x1b 0x2f
0x005c
REVERSE SOLIDUS
0x1b 0x3c
0x005b
LEFT SQUARE BRACKET
0x1b 0x3d
0x007e
TILDE
0x1b 0x3e
0x005d
RIGHT SQUARE BRACKET
0x1b 0x40
0x007c
VERTICAL LINE
0x1b 0x65
0x20ac
EURO SIGN

The GSM 7-bit characters that use the escape code for a two septet combination are represented in this table with the hexadecimal representations of the two septets separately. In the encoded messages, the septets are encoded together with no extra alignment to octet boundaries.

A.2.0 Message Addressing

The syntax of the URL connection strings that specify the address are described in Table A-2.

Table A-2: Connection Strings for Message Addresses

String
Definition
smsurl
::== "sms://" address_part
address_part
::== foreign_host_address | local_host_address
local_host_address
::== port_number_part
port_number_part
::== ":" digits
foreign_host_address
::== msisdn | msisdn port_number_part
msisdn
::== "+" digits | digits
digit
::== "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
digits
::== digit | digit digits

Examples of valid URL connection strings are:

sms://+358401234567
sms://+358401234567:6578
sms://:3381

When this adapter is used and the Connector.open() method is passed a URL with this syntax, it MUST return an instance implementing the javax.wireless.messaging.MessageConnection interface.

A.2.1 Specifying Recipient Addresses

In this URL connection string, the MSISDN part identifies the recipient phone number and the port number part of the application port number address as specified in the GSM 3.40 SMS specification [1] (sections 9.2.3.24.3 and 9.2.3.24.4). The same mechanism is used, for example, for the WAP WDP messages.

When the port number is present in the address, the TP-User-Data of the SMS MUST contain a User-Data-Header with the Application port addressing scheme information element.

When the recipient address does not contain a port number, the TP-User-Data MUST NOT contain the Application port addressing header. Java applications cannot receive this kind of message, but it will be handled as usual in the recipient device; for example, text messages will be displayed to the end user.

A.2.2 Client Mode and Server Mode Connections

Messages can be sent using this API via client or server type MessageConnections. When a message identifying a port number is sent from a server type MessageConnection, the originating port number in the message is set to the port number of the MessageConnection. This allows the recipient to send a response to the message that will be received by this MessageConnection.

However, when a client type MessageConnection is used for sending a message with a port number, the originating port number is set to an implementation-specific value and any possible messages received to this port number are not delivered to the MessageConnection.

Thus, only the server mode MessageConnections can be used for receiving messages. Any messages to which the other party is expected to respond should be sent using the appropriate server mode MessageConnection.

A.2.3 Handling Received Messages

When SMS messages are received by an application, they are removed from the SIM/ME memory where they may have been stored.

If the message information MUST be stored more persistently, then the application is responsible for saving it. For example, the application could could save the message information by using the RMS facility of the MIDP API or any other available mechanism.

The GSM SMS protocol does not guarantee to preserve the ordering when multiple messages are sent. When a large message is split into multiple GSM SMS sections as specified in A.1.2, ordering is handled correctly when they are automatically concatenated back into a single Message object. If the application sends multiple Messages to the same recipient, they might not be delivered in the correct order. The application must be written so that it is able to deal with this issue appropriately. However, even when the ordering may change during the delivery in the network, the implementation MUST guarantee that the messages are delivered to the application in the same order as they were received by the implementation of the recipient terminal.

A.3.0 Short Message Service Center Address

Applications might need to obtain the Short Message Service Center (SMSC) address to decide which recipient number to use. For example, the application might need to do this because it is using service numbers for application servers which might not be consistent in all networks and SMSCs.

The SMSC address used for sending the messages MUST be made available using System.getProperty with the property name described in Table A-3.

Table A-3: Property Name and Description for SMSC Addresses

Property name
Description
wireless.messaging.sms.smsc
The address of the SMS expressed using the syntax expressed by the msisdn item of thefollowing BNF definition:
msisdn ::== "+" digits | digits
digit ::== "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |"8" | "9"
digits ::== digit | digit digits

A.4.0 Using Port Numbers

The receiving application in a device is identified with the port number included in the message. When opening the server mode MessageConnection, the application specifies the port number that it will use for receiving messages.

The first application to allocate a given port number will get it. If other applications try to allocate the same port number while it is being used by the first application, an IOException will be thrown when they attempt to open the MessageConnection. The same rule applies if a port number is being used by a system application in the device. In this case, the Java applications will not be able to use that port number.

As specified in the GSM 03.40 standard [1], the port numbers are split into ranges. The IANA (Internet Assigned Numbers Authority) controls one of the ranges. If an application author wants to ensure that an application can always use a specific port number value, then it can be registered with IANA. Otherwise, the author can pick a number at random from the freely usable range and hope that the same number is not used by another application that might be installed in the same device. This is exactly the same way that port numbers are currently used with TCP and UDP in the Internet.

A.5.0 Message Types

SMS messages can be sent using the TextMessage or the BinaryMessage message type of the API. The encodings used in the SMS protocol are defined in the GSM 03.38 standard (Part 4 SMS Data Coding Scheme) [2].

When the application uses the TextMessage type, the TP-Data-Coding-Scheme in the SMS MUST indicate the GSM default 7-bit alphabet or UCS-2. The TP-User-Data MUST be encoded appropriately using the chosen alphabet. The 7-bit alphabet MUST be used for encoding if the String that is given by the application only contains characters that are present in the GSM 7-bit alphabet. If the String given by the application contains at least one character that is not present in the GSM 7-bit alphabet, the UCS-2 encoding MUST be used.

When the application uses the BinaryMessage, the TP-Data-Coding-Scheme in the SMS MUST indicate 8-bit data.

The application is responsible for ensuring that the message payload fits in an SMS message when encoded as defined in this specification. If the application tries to send a message with a payload that is too long, the MessageConnection.send() method will throw an IllegalArgumentException and the message will not be sent. This specification contains the information that applications need to determine the maximum payload for the message type they are trying to send.

All messages sent via this API MUST be sent as Class 1 messages GSM 3.40 SMS specification [1], Section 9.2.3.9 "TP-Protocol-Identifier".

A.6.0 Restrictions on Port Numbers for SMS Messages

For security reasons, Java applications are not allowed to send SMS messages to the port numbers listed in Table A-4. Implementations MUST throw a SecurityException in the MessageConnection.send() method if an application tries to send a message to any of these port numbers.

Table A-4: Port Numbers Restricted to SMS Messages

Port number
Description
2805
WAP WTA secure connection-less session service
2923
WAP WTA secure session service
2948
WAP Push connectionless session service (client side)
2949
WAP Push secure connectionless session service (client side)
5502
Service Card reader
5503
Internet access configuration reader
5508
Dynamic Menu Control Protocol
5511
Message Access Protocol
5512
Simple Email Notification
9200
WAP connectionless session service
9201
WAP session service
9202
WAP secure connectionless session service
9203
WAP secure session service
9207
WAP vCal Secure
49996
SyncML OTA configuration
49999
WAP OTA configuration


Copyright (C) 2004 Siemens AG, Germany. All rights reserved. Use is subject to license terms.