# SMS Port number

**URL:** <https://forum.sierrawireless.com/t/sms-port-number/3889>\
**Category:** Around the water cooler\
**Created:** [November 21, 2009, 12:08am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889 "2009-11-21T00:08:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.sierrawireless.com/u/davidc)\
**Post date:** [November 21, 2009, 12:08am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/1 "2009-11-21T00:08:37Z")

</div>

Hi All,

This is only applicable here as the modem being used is a Wavecom 1306B…it’s not strictly a OpenAT issue.

A friend of a friend is trying to receive and deliver info to mobile handsets via SMS. It appears that they are using either Java J2ME or Java MIDP to do this - at least from the phone end. Anyway, to send a SMS using the Java SMS API, what appears to be an URL is created - along the lines of “sms://destphoneno:portno”, then the data is sent once the connection is opened. On the server end, my contact is using a 1306B and having problems sending SMS’s via the Java API.

My Question: What is this port number? is it part of the SMS standard, or is it a Java enhancement to the SMS system?

I’ve looked through a couple of Java SMS examples on the web (and I’m not a proficient Java programmer by any means, although I can work my way around it), and it appears that there is a mechanism similar to a webserver (i.e. listens on a range of ports) in the Java engine embedded in the phone. It looks like the programmer can attach an applet to a “port” on the phone and manage data sent via SMS without the data ending up in the conventional text message UI.

I’ve looked through the SMS AT commands in the AT Commands Interface Guide, and can’t find anything that indicates a port number is required. In fact, all I can find is that there are two modes - text mode (160 x 7 bit chars) or PDU mode (140 x 8 bit (binary) characters).

Can anyone shed some light about this “port number” and maybe some comments on how it integrates into the “standard” SMS system as implemented by Wavecom?

All help gratefully appreciated.

ciao, Dave

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [November 21, 2009, 9:15am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/2 "2009-11-21T09:15:11Z")

</div>

> [@davidc](#):
>
> it’s not strictly a OpenAT issue.

Correct - it has nothging to do with Open-AT at all.

> [@](#):
>
> is it part of the SMS standard

See: [viewtopic.php?f=37&t=3259&p=12648&hilit=sms+port#p12648](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?f=37&t=3259&p=12648&hilit=sms+port#p12648)

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [November 21, 2009, 10:03am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/3 "2009-11-21T10:03:46Z")

</div>

Just found this: [ozekisms.com/index.php?owpn=221](http://www.ozekisms.com/index.php?owpn=221)

 ![](https://us1.discourse-cdn.com/flex025/uploads/sierrawireless/original/2X/f/f9338af4e7a72940d0b99a2866703297b53358ba.jpeg)

> [@OZEKI NG SMS Gateway Developers Guide](#):
>
> Hints
> 
> If you use a GMS i[/i] modem, please note that port numbers work only if PDU mode is configured.

So it does look like this could be a useful feature to add to the ADL API…

Cross-ref: [viewtopic.php?f=23&t=4253#p16914](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?f=23&t=4253#p16914)

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [November 21, 2009, 10:28am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/4 "2009-11-21T10:28:01Z")

</div>

You’ve got me interested now, so I did some more research…

Some stuff about the User Data Header (UDH): [viewtopic.php?f=23&t=4253#p16914](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?f=23&t=4253#p16914)

My favourite site about the PDU format: [dreamfabric.com/sms/](http://www.dreamfabric.com/sms/)  
The first octet of the SMS-DELIVER PDU contains the TP-UDHI User data header indicator: This bit is set to 1 if the User Data field starts with a header [dreamfabric.com/sms/deliver\_fo.html](http://www.dreamfabric.com/sms/deliver_fo.html)  
Similarly in the first octet of the SMS-SUBMIT PDU: [dreamfabric.com/sms/submit\_fo.html](http://www.dreamfabric.com/sms/submit_fo.html)

The GSM Short Message Service is defined in GSM 03.40, “Technical realization of the Short Message Service (SMS)”  
[3gpp.org/ftp/Specs/html-info/0340.htm](http://www.3gpp.org/ftp/Specs/html-info/0340.htm)

Application Port Addressing is defined in sections 9.2.3.24.3 (8-bit) and 9.2.3.24.4 (16-bit)

> [@GSM 03.40](#):
>
> This facility allows short messages to be routed to one of multiple applications in the TE (terminal equipment), using a method similar to TCP/UDP ports in a TCP/IP network. An application entity is uniquely identified by the pair of TP-DA/TP-OA and the port address. The port addressing is transparent to the transport, and also useful in Status Reports.

PC-based tools for decoding SMS PDUs:  
[scampers.org/steve/sms/tools.htm](http://www.scampers.org/steve/sms/tools.htm)  
[nobbi.com/pduspy.html](http://www.nobbi.com/pduspy.html)

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.sierrawireless.com/u/davidc)\
**Post date:** [November 22, 2009, 6:28am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/5 "2009-11-22T06:28:14Z")

</div>

Hiya,

> [@awneil](#):
>
> You’ve got me interested now, so I did some more research…

Thanks for the help - it’s much appreciated.

You have been busy - interesting, as I put SMS Port Number into Google and didn’t find ANY of the links that you found. I did find a lot referencing the Java J2ME standard though - it appears that the “sms://phone:port” construct is only applicable to J2ME, not standard Java as implemented on the PC.

I’ve passed on your info to my friend. Hopefully this will let them get the job finished (or maybe I’ll pick up some work 😃 ).

Thanks again.  
Dave

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [November 23, 2009, 6:59am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/6 "2009-11-23T06:59:53Z")

</div>

> [@davidc](#):
>
> I put SMS Port Number into Google and didn’t find ANY of the links that you found.

I think the key term was the “User Data Header” (UDH) - which I got from the post by [wismo\_coder](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?f=37&t=3259&p=12648&hilit=UDH#p12648)

---

<div class="post-metadata">

**Author:** ![DrLan](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@DrLan](https://forum.sierrawireless.com/u/DrLan)\
**Post date:** [December 11, 2009, 10:12am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/7 "2009-12-11T10:12:49Z")

</div>

Hi there.

I will try to make my little contribution in this question 😃  
Here is the my function to send SMS in PDU mode to specific port. The function works well, but optimization of the code is welcome 😒

1. Your own specific port number you can fill in UDH part with 16-bit hex number mark with comment:

```auto
// J2ME port Number:	5000 = 0x1388
```

1. Characters that you can use in your UD Message are: “a…z”, “A…Z”, “.,:;!-/+\*”, space, “0…9”. You can use other characters gsm 7-bit alphabet, but they require more several strings in code inside the function.
2. Inside this func You have to use global variable SMS\_Handle which you receive with adl\_smsSubscribe func.

```auto
s8 SendRawPDU_SMS ( ascii * Dst_Address,
   						        ascii * Ascii_Text)
{
    s8 smsSend_Handle;
    ascii telbuf[12];
    ascii buf[8];
    ascii out[200];
    ascii Phone[12];
    ascii len[2];
    u16 i, j;

    ascii UDLBuf[1000];

    // DecToBin part variables
    float del, d;
    double div;

	wm_memset(telbuf, '\0', 12);
	wm_memset(out, '\0', 200);
	wm_memset(Phone, '\0', 12);
	wm_memset(len, '\0', 2);

	wm_strcat(Phone, Dst_Address);

	// SMSC FLAGS: 0x00
	// SMSC ADDRESS: NOT SPECIFIED (USED IN SIM)
	wm_strcat(out, "00");

	// MESSAGE FLAGS: 0x51
	// MESSAGE TYPE: SmsSubmit
	// REJECT DUPLICATES: NO
	// VALIDITY PERIOD: Relative
	// STATUS REPORT: NO
	// USER DATA HEADER: YES
	// REPLY PATH: NO
	wm_strcat(out, "51");

	// MESSAGE REFERENCE: 0x00
	wm_strcat(out, "00");

	// DESTINATION ADDRESS TYPE: 0x91
	// TYPE OF NUMBER: 0x01 (International)
	// NUMBERING PLAN: 0x01 (ISDN/telephone)
	// CONVERT IT TO PDU MODE
	wm_strcat(out, "0B91");

	wm_strncat(telbuf, &Phone[2], 1);
	wm_strncat(telbuf, &Phone[1], 1);
	wm_strncat(telbuf, &Phone[4], 1);
	wm_strncat(telbuf, &Phone[3], 1);
	wm_strncat(telbuf, &Phone[6], 1);
	wm_strncat(telbuf, &Phone[5], 1);
	wm_strncat(telbuf, &Phone[8], 1);
	wm_strncat(telbuf, &Phone[7], 1);
	wm_strncat(telbuf, &Phone[10], 1);
	wm_strncat(telbuf, &Phone[9], 1);
	wm_strcat(telbuf, "F");
	wm_strncat(telbuf, &Phone[11], 1);
	wm_strcat(out, telbuf);

	// PROTOCOL ID: 0x00 (SME-to-SME protocol)
	wm_strcat(out, "00");

	// DATA CODING SCHEME: 0x00
	// CODING GROUP: 0x00 (General Coding)
	// COMPRESSED: NO
	// CLASS SPECIFIED: NO
	// ALPHABET: 0x00 (Default alphabet)
	// RESERVED: 0x00
	wm_strcat(out, "00");

	// MESSAGE VALIDITY: 27d
	wm_strcat(out, "C1");

	// USER DATA LENGTH = UDH-LENGTH + UD-MESSAGE + 1
	wm_itohexa(len, (7+wm_strlen(Ascii_Text)+1),2);
	wm_strcat(out, len);

	// UDH LENGTH: 7
	// UDH: 06050413880000
	// J2ME port Number:	5000 = 0x1388
	wm_strcat(out, "06050413880000");

	// USER DATA MESSAGE
	wm_memset(UDLBuf, '\0', 1000);

	// REPRESENT MESSAGE IN 7-BIT GSM ALPHABET IN UDLBuf
	// AFTER THIS WE HAVE TO
	for (i = 0; i < wm_strlen(Ascii_Text); ++i)
	{
				wm_memset(buf,'\0',8);

				ascii buf2[8];

				wm_memset(buf2, '\0', 8);

				if ( wm_isascii(Ascii_Text[i]) ) {
				j=0;
				d = 2.0;

				del = (u32)(Ascii_Text[i]);
				while ( d >= 1 )
					{
						d = abs ((u32)del / 2);
						div = del - (d * 2);
						del = d;
						wm_sprintf( &buf2[j], "%d", (u16)div );
						j++;
					}
	}	else	{
		// SPECIAL SYMBOLS CODE'S IN 7-BIT GSM-CODING DIFFER
		// FROM GENERAL ASCII CODES AND WE HAVE TO
		// REPRESENT THEM MANUALLY
					if ((char)(Ascii_Text[i]) == ' ') {
						wm_sprintf( buf2, "0000010");
					} else if ((char)(Ascii_Text[i]) == '.') {
						wm_sprintf( buf2, "0111010");
					} else if ((char)(Ascii_Text[i]) == ';') {
						wm_sprintf( buf2, "1101110");
					} else if ((char)(Ascii_Text[i]) == '!') {
						wm_sprintf( buf2, "1000010");
					} else if ((char)(Ascii_Text[i]) == ',') {
						wm_sprintf( buf2, "0011010");
					} else if ((char)(Ascii_Text[i]) == '-') {
						wm_sprintf( buf2, "1011010");
					} else if ((char)(Ascii_Text[i]) == '/') {
						wm_sprintf( buf2, "1111010");
					} else if ((char)(Ascii_Text[i]) == '+') {
						wm_sprintf( buf2, "1101010");
					} else if ((char)(Ascii_Text[i]) == '*') {
						wm_sprintf( buf2, "0101010");
					} else if ((char)(Ascii_Text[i]) == ':') {
						wm_sprintf( buf2, "0101110");
					} else if ((char)(Ascii_Text[i]) == '0') {
						wm_sprintf( buf2, "0000110");
					} else if ((char)(Ascii_Text[i]) == '1') {
						wm_sprintf( buf2, "1000110");
					} else if ((char)(Ascii_Text[i]) == '2') {
						wm_sprintf( buf2, "0100110");
					} else if ((char)(Ascii_Text[i]) == '3') {
						wm_sprintf( buf2, "1100110");
					} else if ((char)(Ascii_Text[i]) == '4') {
						wm_sprintf( buf2, "0010110");
					} else if ((char)(Ascii_Text[i]) == '5') {
						wm_sprintf( buf2, "1010110");
					} else if ((char)(Ascii_Text[i]) == '6') {
						wm_sprintf( buf2, "0110110");
					} else if ((char)(Ascii_Text[i]) == '7') {
						wm_sprintf( buf2, "1110110");
					} else if ((char)(Ascii_Text[i]) == '8') {
						wm_sprintf( buf2, "0001110");
					} else if ((char)(Ascii_Text[i]) == '9') {
						wm_sprintf( buf2, "1001110");
					}
				}
				wm_strncat(UDLBuf, buf2, wm_strlen(buf2));
	}

	// LAST BYTE (MEAN 8-BIT) WE HAVE TO FILL WITH '0'
	j = fmod(wm_strlen(UDLBuf),8);
	if ( (8-j) != 0 ){
		for (i = 1; i <= (8-j) ; ++i) {
			wm_strcat(UDLBuf,"0");
		}
	}

	i = j =0;

	// AND THEN BACK REPRESENT TO HEX NUMBERS
	//	FROM 8-BIT BINARY STRUCTURES
	for (i = 0; i < wm_strlen(UDLBuf)/8; ++i)
	{
		u32 m1, m2, sum;
		sum =0;

		for ( j = 0; j< 8; ++j)
		{
			m1 = m2 = 0;
			m1 = pow( 2, (j) );

			if ( (char)UDLBuf[j + i*8] == '1' ) {
				m2 = 1;
			} else	{
				m2 = 0;
				}

			sum = sum + m1* m2;
		}
			ascii bufc[2];
			wm_memset(bufc, '\0', 2);
			wm_itohexa(bufc, (sum),2);
			wm_strncat(out, bufc, wm_strlen(len));
	}

    smsSend_Handle = adl_smsSend ( SMS_Handle, NULL, out, ADL_SMS_MODE_PDU);

    return smsSend_Handle;
}
```

1. Dst\_Address is TP-DA phone number in International format +XXXXXXXXXXX only!
2. Ascii\_Text can not contain more than 119 characters.
3. Function return handle receive from adl\_smsSend in PDU format.

I’ll be glad to see your comments and suggestions. 🙂

---

<div class="post-metadata">

**Author:** ![spahlavan](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@spahlavan](https://forum.sierrawireless.com/u/spahlavan)\
**Post date:** [September 29, 2012, 11:41am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/8 "2012-09-29T11:41:42Z")

</div>

Hello my friend  
What is the call function

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [September 29, 2012, 2:03pm UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/9 "2012-09-29T14:03:30Z")

</div>

> [@spahlavan](#):
>
> What is the call function

What “call function” are you asking about ❓

---

<div class="post-metadata">

**Author:** ![spahlavan](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@spahlavan](https://forum.sierrawireless.com/u/spahlavan)\
**Post date:** [September 30, 2012, 7:08am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/10 "2012-09-30T07:08:56Z")

</div>

hi  
How to call function  
SendRawPDU\_SMS (ascii \* Dst Address, ascii \* Ascii Text)  
What is the  
😃  
What is the function of the input values

---

<div class="post-metadata">

**Author:** ![spahlavan](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@spahlavan](https://forum.sierrawireless.com/u/spahlavan)\
**Post date:** [September 30, 2012, 7:51am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/11 "2012-09-30T07:51:44Z")

</div>

I want to write a program that would send him to pdu  
Please help on a specific port

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [September 30, 2012, 3:42pm UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/12 "2012-09-30T15:42:08Z")

</div>

Do you have any embedded ‘C’ programming experience ❓

Do you have any programming experience at all ❓

---

<div class="post-metadata">

**Author:** ![spahlavan](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@spahlavan](https://forum.sierrawireless.com/u/spahlavan)\
**Post date:** [October 2, 2012, 4:55am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/13 "2012-10-02T04:55:22Z")

</div>

I have programming experience  
But this code does not work well if you can help me

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [October 2, 2012, 5:52am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/14 "2012-10-02T05:52:40Z")

</div>

> [@spahlavan](#):
>
> I have programming experience

But do you have ‘C’ experience? Specifically, embedded ‘C’ experience?

> [@](#):
>
> But this code does not work well if you can help me

That’s like saying, “My car won’t go - what’s wrong with it?”

What, exactly, have you tried?

What were the results?

What results were you expecting?

What have you done to reconcile the expected results with the actual results?

In other words, what debugging have you done?

Here’s some debugging tips to get you started:

[8052.com/faqs/120313](http://www.8052.com/faqs/120313)

[eetimes.com/discussion/break … geNumber=0](http://www.eetimes.com/discussion/break-point/4027526/Developing-a-good-bedside-manner?pageNumber=0)

---

<div class="post-metadata">

**Author:** ![spahlavan](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@spahlavan](https://forum.sierrawireless.com/u/spahlavan)\
**Post date:** [October 2, 2012, 6:18am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/15 "2012-10-02T06:18:37Z")

</div>

Hello my friend  
I’m sending a pdu with q24  
What should i do

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [October 2, 2012, 6:39am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/16 "2012-10-02T06:39:13Z")

</div>

Are you using Open-AT?

Does your PDU need to address a “port” number?

---

<div class="post-metadata">

**Author:** ![spahlavan](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@spahlavan](https://forum.sierrawireless.com/u/spahlavan)\
**Post date:** [October 2, 2012, 8:13am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/17 "2012-10-02T08:13:30Z")

</div>

yes

---

<div class="post-metadata">

**Author:** ![spahlavan](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@spahlavan](https://forum.sierrawireless.com/u/spahlavan)\
**Post date:** [October 2, 2012, 8:16am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/18 "2012-10-02T08:16:41Z")

</div>

How to make pdu  
And how to send it on a specific port  
With open at

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [October 2, 2012, 9:20am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/19 "2012-10-02T09:20:42Z")

</div>

Isn’t that exactly what the code so kindly posted by DrLan does ❓❗

You will, of course, need to spend time studying the Open-AT documentation and learning how to use it…

You should also study the links already given, and other materials, to understand the PDU format, User Data Header, Port Addressing, etc,…

---

<div class="post-metadata">

**Author:** ![spahlavan](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@spahlavan](https://forum.sierrawireless.com/u/spahlavan)\
**Post date:** [October 2, 2012, 9:45am UTC](https://forum.sierrawireless.com/t/sms-port-number/3889/20 "2012-10-02T09:45:14Z")

</div>

Please give me the code pdu  
I’m working on a project  
I’ve been on this part of the problem.

[Next page](https://forum.sierrawireless.com/t/sms-port-number/3889.md?page=2)
