Tiliman’s Weblog

December 20, 2008

Replacing SMS on a Phone using Kannel SMS Gateway

Filed under: GSM — Tags: , , , , , — tiliman @ 11:35 am

What is Replace Message?

The 3GPP (ETSI) standard for GSM communication specifies a way to replace an existing message on a mobile phone by sending another message. I had a requirement to use this functionality with Kannel connected to an SMS GW that communicates over SS7/MAP.

Using Kannel to Replace Message

Sending a self destruct or replaceable message is pretty easy with Kannel as long as your SMSC supports it.

Send first SMS with pid=65
http://SERVER:PORT/cgi-bin/sendsms?from=55512345&username=me&password=mypass&
to=5551233&text=original+msg&pid=65

Send second SMS with pid=65

http://SERVER:PORT/cgi-bin/sendsms?from=55512345&username=me&password=mypass&
to=5551233&text=msg+replaced&pid=65

 

Quest for correct PID value

The documentation of Kannel doesn’t provide any information about the method at all. It however mentions the field PID that can be set while sending SMS. Looking at some forums related to NowSMS gateway, it appeared that PID can be used to send such SMS.

The next issue was to find out what exact value to provide as NowSMS GW allows a value of between 41--47 in decimal. This doesn’t work with Kannel.

3G TS 23.040 V3.2.0 (1999-10) on page 52-53 states this:

9.2.3.9 TP-Protocol-Identifier (TP-PID)
The TP-Protocol-Identifier parameter serves the purposes indicated in subclause 3.2.3. It consists of one octet, and the
bits in the octet are used as follows:
.
.
.
In the case where bit 7 = 0, bit 6 = 1, bits 5..0 are used as defined below
5 .. . .0
000000 Short Message Type 0
000001 Replace Short Message Type 1
000010 Replace Short Message Type 2
000011 Replace Short Message Type 3
000100 Replace Short Message Type 4
000101 Replace Short Message Type 5
000110 Replace Short Message Type 6
000111 Replace Short Message Type 7

Here is explanation of Replace Short Message from standard

The Replace Short Message feature is optional for the ME and the SIM but if implemented it shall be performed as
described here.
For MT short messages, on receipt of a short message from the SC, the MS shall check to see if the associated Protocol
Identifier contains a Replace Short Message Type code.
If such a code is present, then the MS will check the originating address and replace any existing stored message having
the same Protocol Identifier code and originating address with the new short message and other parameter values. If
there is no message to be replaced, the MS shall store the message in the normal way. The MS may also check the SC
address as well as the Originating Address. However, in a network which has multiple SCs, it is possible for a Replace
Message type for a SM to be sent via different SCs and so it is recommended that the SC address should not be checked
by the MS unless the application specifically requires such a check.

According to this 01000001 or in decimal 65 would give me Replace Short Message Type 1 and it can go upto 71.
I have tested this on Samsung, Nokia, HTC and iPhone. Seems to work fine on all of these.

Advertisements

5 Comments »

  1. Hi Friend,

    How can I use the Kannel SMS gateway in iPhone? Please explain the procedure to do that.

    Thanks.

    Comment by krishnan — February 21, 2010 @ 12:10 pm

    • Hi Krishnan

      Kannel is SMS Server/Gateway that is built on *nix systems. It is a server side software.
      If you are talking about using iPhone to send SMS via Kannel, then you could probably call HTTP API of a kannel server installed somewhere and send SMS.
      You question was pretty vague. You should read more about kannel.

      Comment by tiliman — February 21, 2010 @ 3:25 pm

  2. Come on Krishnan!! iPhone is GOOD, but not thaaat good.

    @tiliman – can you recommend any SMSC/Gateway that you have used/know of that supports this functionality?

    Comment by kenyangunner — June 15, 2010 @ 10:52 am

  3. Well all SMSCs that talk on SS7/MAP layer support it.

    Kannel doesn’t have SS7 driver but it handles this very well over SMPP when connected with other SS7 SMSC.

    I would say it should work everywhere because at the end it is just a param that is passed from network to phone and no one really bothers to change that in middle.

    Comment by tiliman — June 15, 2010 @ 11:09 am

  4. Hi, would it be possible in theory to develop an application for a handset that runs on a device such as a nokia/iphone/blackberry to be able to send sms directly to the SMSC with the replacement code?

    I understand how a software that connects to an SMS gateway or using a GSM modem could manipulate a message to include a replacement code.

    What I’m looking for is a way to be able to send “self destruct” messages directly from the handset. There are plenty of apps out there for various handsets that can replace the native messaging application. however I’m not aware of any that have the option to set the replace feature.

    Comment by Chris Woollam — December 7, 2010 @ 3:33 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: