File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SMS port numbers (possibly FAO M. Yuan?)

 
Mark Greene
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1427
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1427
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1427
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Raina
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would like to know how to set serial port address in the code.
 
Sanchit Mendiratta
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic