my dog learned polymorphism*
The moose likes Java Micro Edition and the fly likes SMS port numbers (possibly FAO M. Yuan?) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "SMS port numbers (possibly FAO M. Yuan?)" Watch "SMS port numbers (possibly FAO M. Yuan?)" New topic
Author

SMS port numbers (possibly FAO M. Yuan?)

Mark Greene
Greenhorn

Joined: Apr 07, 2004
Posts: 18
I have a midlet running on a Sony p900 listening for incoming sms messages on a port e.g. 16500.
I am using Object XP's 'jSMS' to send sms's, this is the application that Michael Yuan mentions in his excellent book & he provides a snippet of code (here : http://www-106.ibm.com/developerworks/java/library/wi-p2pmsg/ ) showing how to send an sms via jSMS.
However! I don't know how to specify a destination *port* for my sms. e.g. my p900 midlet will be expecting an sms along the lines of +35386XXXXXXX:16500
Does anyone have any idea how to specify the port number in an SMS destination address..? Micahel's code example doesn't show/mention specifying a destination port from the server.
From some web searches I've seen 'user data headers' mentioned which could (hopefully?) allow me to specify the destination port however jSMS has no example of how this is done. I've tried a few things with their API but so far the only results have been none-too-descriptive exceptions like "udhnsp" - although I guess this could be shorthand for "User Data Header Not Supported" which might make sense seeing as I am using only the trial version (Obviously I'm not buying it until I know it satisfies my application's needs..).
So any code on how to specify a destination port via jSMS would be ideal! ;-) I've also been using a free product called 'jsmsengine' to send sms's but however this doesn't mention anything about ports or user data headers etc..
any help/advice greatly appreciated,
thanks,
Mark
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
I know the commercial simplewire toolkit recently added support for SMS ports. Also, JSR 212 is working a standard server side SMS/MMS API spec. Nokia is supposed to provide an reference implementation. It supports SMS port numbers as well. But you need to have an agreement with a carrier to plug it into the live network.
A ugly (and hacky) solution similar to jSMS to use an extra phone in your server room as the SMS "gateway". The gateway phone runs a MIDlet app 24/7 and polls a HTTP/Email server for new messages. When a message comes in, it forwards to the specified phone number and port number.


Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Also, does the p900 provides an API extension to access the native SMS Inbox (along with the native addressbook etc)? If so, you can poll the SMS Inbox and filter "portless" messages intended for the MIDlet.
Marko Knezovic
Greenhorn

Joined: Apr 12, 2004
Posts: 2
Hi Mark!
The SMS port number depends on the SMSC used by the carrier. The SMSC communicates with the phone using the UCPxx protocol family.
Best regards,
Marko
Mark Greene
Greenhorn

Joined: Apr 07, 2004
Posts: 18
Responding to my own thread here - I found out how to use jSMS to specify the destination port (from the server) on the receiving device. here's the code:
final int DEST_PORT = 16200;
final int SRC_PORT = 0;
SmsMessage msg = new SmsMessage();
SmsHeader hdr = new SmsHeader();
hdr.add(new PortAddressingHeaderElement(false, DEST_PORT, SRC_PORT));
msg.setUserDataHeader(hdr.getBytes());
msg.setMessage("Hello World");
Ikasari Widiyanto
Greenhorn

Joined: May 31, 2004
Posts: 29
Hi...

I am also developing a similar application with yours. the difference is that I'm using Nokia 6600 instead of Sony. I have tried to add your code in my application but i have error:[udhnsp]. Can you help me solved the problem? Thank you in advance.
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
I think the above referenced code is not intended for J2ME. It is for computer servers running J2SE and the jSMS library.
Ikasari Widiyanto
Greenhorn

Joined: May 31, 2004
Posts: 29
hmmm... I think my application is similar with that one. I am developing a Java application in the PC to send and receive SMS using jSMS. I am able to send and receive the SMS but when I send the message I want it to be received in my application's not in the native inbox. I think its because I have to specify the port number but I dun know how to specify it. when I tried the code. I got the above error message. can you help me how to solve it? Thank you in advance
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Since you mentioned that code works for SE but not 6600, I thought you were running it on the device. Where did you see the error message? On the jSMS PC or on the device when the message arrives? If it is a jSMS related problem, make sure that you are using the latest version of the jSMS (delete all old JARs in your classpath).
harvey hao
Greenhorn

Joined: May 14, 2004
Posts: 5
I use jsms 1.8.2 on PC and send the SMS from PC to MIDP app listening the specified port on Cell phone.

The following codes run on my PC by using jsms libary and got some errors. the source code and errors are as follows:

Could you please tell me why? Thank you very much!

import java.io.File;
import java.io.IOException;
import com.objectxp.msg.GsmSmsService;
import com.objectxp.msg.MessageException;
import com.objectxp.msg.SmsMessage;
import com.objectxp.msg.SmsService;
import com.objectxp.msg.util.*;


/**
* This example demonstrates how to send a Text SMS
using jSMS.
*/
public class ReceiveExample
{
public static void main(String[] args) throws
IOException, MessageException
{
if(args.length != 2 ) {
System.err.println("Usage: SendSMS <config-file>
<recipient>");
System.exit(1);
}

// Create and initialize the SmsService (Replace
GsmSmsService with
// the SmsService Implementation of your choice).
SmsService service = new GsmSmsService();
service.init(new File(args[0]));

// create message

SmsMessage msg = new SmsMessage();
SmsHeader hdr = new SmsHeader();
hdr.add(new PortAddressingHeaderElement(true, 5512,
4711));
msg.setUserDataHeader(hdr.getBytes());
msg.setRecipient(args[1]);
msg.setMessage("Hello World");

// connect, send message and disconnect
try {
service.connect();
service.sendMessage(msg);
service.disconnect();
} finally {
service.destroy();
}
}
}




com.objectxp.msg.MessageException: [udhnsp]

at com.objectxp.msg.GsmSmsService.a(Unknown Source)

at com.objectxp.msg.GsmSmsService.sendMessage(Unknown Source)

at com.objectxp.msg.GsmSmsService.sendMessage(Unknown Source)

at ReceiveExample.main(ReceiveExample.java:39)

Exception in thread "main"
Ikasari Widiyanto
Greenhorn

Joined: May 31, 2004
Posts: 29
Sorry for the late reply....

The error is the same with harvey hao's. I kept getting this "udhnsp" error. Tjis error is in the PC. I also have downloaded the latest version of jSMS. Do you have the solution for this error? Thank you.
Muthu Nedumaran
Greenhorn

Joined: Jan 02, 2005
Posts: 1
Hi there,

Anybody found a solution to the [udhnsp] message. I just downloaded the trial version (2.0) of JSMS and am hitting into the exact problem. Appreciate any pointers.
Dirk V. Schesmer
Greenhorn

Joined: Jan 25, 2005
Posts: 1
Hi there,
I have the same trouble as you describe it above when trying to send an SMS to a MIDlet listening on port 4711 for incoming SMS messages on another device.

My source device is a Nokia D211 card, target a Nokia 9500.

Sending the SMS to inbox works fine, but when trying to send to 4711, the system reports:
Error 31 SetCommConfig
Message could not be sent: [udhnsp]
I am using the originalo SendSMS caode extended by
...
SmsHeader hdr = new SmsHeader();
hdr.add(new PortAddressingElement(true, 4711, 0);
//hdr.add(new PortAddressingElement(true, 4711, 4711);//doesn't work,either
msg.setHeader(hdr.getBytes())
...
My application works perfectly when talking from Nokia 6600 to 9500 and vice versa, both using port 4711. Using the SimpleWire host and message router works using 4711, as well.
Any help would be highly appreciated!

Thanks, Dirk V. Schesmer
Kirk Bateman
Greenhorn

Joined: Oct 13, 2004
Posts: 9
udhnsp would make me suspect it is ... UDH (user data header) NSP (No Source Port)...

Try setting the source port to something other than 0.. for example, set it to the same as the destination port and see if that helps.

Cheers

Kirk Bateman
Synaptic Technologies Limited
http://synaptic-technologies.blogspot.com/
Notmy Name
Greenhorn

Joined: May 19, 2005
Posts: 2
Originally posted by Michael Yuan:
Also, does the p900 provides an API extension to access the native SMS Inbox (along with the native addressbook etc)? If so, you can poll the SMS Inbox and filter "portless" messages intended for the MIDlet.
Notmy Name
Greenhorn

Joined: May 19, 2005
Posts: 2
Originally posted by Michael Yuan:
Also, does the p900 provides an API extension to access the native SMS Inbox (along with the native addressbook etc)? If so, you can poll the SMS Inbox and filter "portless" messages intended for the MIDlet.


Did you ever get an answer to this question
Vaibhav Raina
Greenhorn

Joined: Mar 24, 2006
Posts: 2
Hi

I am also trying to send messages through my computer to My Nokia 3230 device. I am new to JSMS have download the API but somehow not able to configure it in classpath. I have gone through the code given for sending the SMS and would like to know as what parameters should be passed in msg.setRecipient() method so that i send SMS through the port to my mobile. What should be the port address?


I have installed the javax.com in my jdk. I am using jdk1.5.0_o6. I have copied comm.jar file in \jdk1.5.0_06\jre\lib\ext as mentioned in the help and javax.comm.properties in \jdk1.5.0_06\jre\lib. I have also changed my lincense fields as instructed. I am trying to check the simple program in Editplus and my classpath is set to jdk1.5.0_06\jre\lib.
Still i am not able to complie the program as the compiler returns package com.objectxp.message does not exist. It looks as i have some porblem in the installation process. Can you please guide me through the steps again or can rectify the mistake i have done while installing java.comm.

Reply will be greatly appreciated


Vaibhav
Vaibhav Raina
Greenhorn

Joined: Mar 24, 2006
Posts: 2
Would like to know how to set serial port address in the code.
Sanchit Mendiratta
Greenhorn

Joined: May 05, 2006
Posts: 2
vaibhav, wat i wud suggest is download n use jcreator instead of edit plus.. its similar, infact better, all u need to do is copy the jar files as u have already done n den define the profile, it will automatically configure.. while if u wanna do from dos... >class path = <path> w/o the brackets...

well my prob is how to define the config file.. i mean what is that.....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SMS port numbers (possibly FAO M. Yuan?)
 
Similar Threads
Apis For Recieving SMS
sending sms
How to send/recieve SMS in Java
install WMA RI into Sun one Studio
Sending SMS with the J2ME Wireless Messaging API