Sending message to a gsm modem

Sending message to a gsm modem SearchSearch
Author Message
asha rajput
New member
Username: Asha619

Post Number: 1
Registered: 11-2011
Posted on Thursday, November 24, 2011 - 09:53 pm:   

hello,
i just discovered nowsms(it's great) and im using it for my J2ME project.
the problem i have is sending a message to a gsm modem from my emulator.all the code that is out there is for sending sms to a phone(client based) however mine is server side.

i would appreciate if u could help me with this code(it's within a thread):

String destAddress = "sms://0712893128:5000";
//0712893128 is the number of the modem line and 5000 the midlet port
MessageConnection smsConnection = (MessageConnection)Connector.open(destAddress);
TextMessage textmsg = (TextMessage)smsConnection.newMessage( MessageConnection.TEXT_MESSAGE);
textmsg.setAddress(destAddress);
textmsg.setPayloadText(details.getString());
smsConnection.send(textmsg);
smsConnection.close();

now i want to send this to the gsm modem that i've successfully tested and added to nowsms.
what do i need to edit.thanks
asha rajput
New member
Username: Asha619

Post Number: 2
Registered: 11-2011
Posted on Thursday, November 24, 2011 - 10:10 pm:   

or can anyone share a portion of their J2ME code on how to go about this..i'd really appreciate itthanks
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3620
Registered: 08-2008
Posted on Saturday, November 26, 2011 - 02:38 pm:   

Hi,

I'm not sure I understand the point of confusion. Wouldn't you just change the destination address to be that of the modem?

--
Des
NowSMS Support
asha rajput
New member
Username: Asha619

Post Number: 3
Registered: 11-2011
Posted on Saturday, November 26, 2011 - 05:47 pm:   

thanks but sorry that's not what i intended to ask.
i firsr want to open a connection to the modem:
MessageConnection sconn = (MessageConnection)
Connector.open("sms://:3333");..THIS IS WHAT I DON'T KNOW HOW TO CHANGE{E.G I KNOW THE PORT IS COM2(HOW DO I INCORPORATE THAT?)
TextMessage msg =(TextMessage) sconn.newMessage(
MessageConnection.TEXT_MESSAGE); msg.setAddress("sms://+254712893128:50000");
msg.setPayloadText( "Hello World" );
sconn.send(msg);
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3624
Registered: 08-2008
Posted on Monday, November 28, 2011 - 05:25 pm:   

I don't believe there is any way for you to do what you are trying to do in that fashion ... that is client side code.

Overall I'm confused about what exactly you are trying to do.

Are you trying to receive a message that was sent "to" the modem, or are you trying to send a message out "through" the modem?

If you are trying to receive a message that was sent to the modem, you need to create a 2-way command in NowSMS. NowSMS receives the message and then either runs a command line program, or issues an HTTP request to pass the message details to your application. http://www.nowsms.com/doc/2-way-sms-support

If you are trying to send a message out "through" the modem, here are some details for how to interface from Java to NowSMS for sending messages: http://www.nowsms.com/nowsms-java-example-send-sms-message


--
Des
NowSMS Support
asha rajput
New member
Username: Asha619

Post Number: 4
Registered: 11-2011
Posted on Tuesday, November 29, 2011 - 04:03 pm:   

hi,thanks
i am actually trying to send through the modem for a two-way processing in nowsms.
I am doing it with J2ME and i would really appreciate if you provided an example because the ones above are for sending sms from JSP/Java and J2ME cannot run java classes.(Do you have an example for sending sms from a J2ME Midlet to nowesms thgrough a gsm modem?)
Kindly assist me.
Thanks
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3633
Registered: 08-2008
Posted on Tuesday, November 29, 2011 - 11:47 pm:   

Are you sure you can't use that code from J2ME?

The link to the actual underlying code is included in the second article I referenced.
Article at http://www.nowsms.com/nowsms-java-example-send-sms-message
Code at http://www.nowsms.com/download/sendsms.java.txt

All the code does is build an HTTP URL to connect to NowSMS and send a message. The URL format for submitting a text message can be found here: http://www.nowsms.com/doc/submitting-sms-messages/sending-sms-text-messages

To send to a port, just encode the phone number as 999999999:2222

Processing a received message is more complicated. NowSMS will either connect to a URL (meaning your application runs on a web server and accepts URL parameters), or NowSMS spawns a command line application and passes parameters on the command line.

--
Des
NowSMS Support
asha rajput
New member
Username: Asha619

Post Number: 5
Registered: 11-2011
Posted on Wednesday, November 30, 2011 - 08:30 pm:   

thanks DES,
the material was very helpful.
However is there a way that i can be able to send sms from my app directly without using HTTP connection,just to send an sms directly to to nowsms because my app uses sms communication.
thanks.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3634
Registered: 08-2008
Posted on Thursday, December 01, 2011 - 12:39 am:   

HTTP is the best route, even if on the same physical machine. It is easiest to implement and widely implemented in different environments.
asha rajput
New member
Username: Asha619

Post Number: 6
Registered: 11-2011
Posted on Thursday, December 01, 2011 - 10:32 am:   

so i can't send an sms directly to nowsms(the way a phone sends an sms to another phone) unless i use HTTP connection?
I am doing a J2ME health app for an NGO that wants nurses to send daily reports via sms to them.Now it is based in some remote location where internet connectivity is just terrible so that's why i'm checking whether another option is available.(e.g like what i was trying to do in the third post)

and could you kindly please link me up with this person's(Pedric) e-mail address from this post
http://support.nowsms.com/discus/messages/1/22981.html
.I think he managed to achieve what i'm intending to do.Please.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3639
Registered: 08-2008
Posted on Thursday, December 01, 2011 - 01:29 pm:   

I'm sorry, but you have me thoroughly confused. A diagram or simple explanation of what resides where would be helpful.

You don't need Internet connectivity to perform an HTTP transaction with NowSMS running on the same system (you use the internal loop back address of 127.0.0.1).

I cannot give out other email addresses, however, if you approve, I can forward your email address to Pedric, and ask if he would be willing to email you. That message thread is 4 years old, so the email we have might no longer be valid, but I will try.

--
Des
NowSMS Support
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3640
Registered: 08-2008
Posted on Thursday, December 01, 2011 - 01:38 pm:   


quote:

so i can't send an sms directly to nowsms(the way a phone sends an sms to another phone) unless i use HTTP connection?




And to be clear, yes, of course you can send an SMS from a phone to NowSMS via a modem.

I reread your messages, and I think I understand what you are asking a little better.

I think we are having difficulty understanding each other, because from your earlier responses, I thought you were trying to send SMS messages out through NowSMS...this is the scenario in which you would use HTTP.

For processing a message received by the modem, the 2-way command facility is used.

Create a J2ME application that either runs under a local web server on the NowSMS machine, or that can be run from a command line.

By command line, I mean a program that you could run from a command prompt, passing information about the received message.

With the 2-way facility, NowSMS can run this program or issue an HTTP request every time a message is received. This is how NowSMS tells your application about a received message.

I hope this better answers your question.

--
Des
NowSMS Support
asha rajput
New member
Username: Asha619

Post Number: 7
Registered: 11-2011
Posted on Thursday, December 01, 2011 - 03:04 pm:   

thanks.
the app will send an sms to nowsms and then nowsms processes the message and sends back a reply via its 2-way facility which i've read about from the guide and have no issues with.

The point i was raising was about sending an sms from the Midlet to nowsms via the sms protocol and not HTTP connection.Any material on that?

thanks for forwarding my contact to Pedric.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3643
Registered: 08-2008
Posted on Thursday, December 01, 2011 - 04:28 pm:   


quote:

The point i was raising was about sending an sms from the Midlet to nowsms via the sms protocol and not HTTP connection.Any material on that?




Where is this midlet running?
asha rajput
New member
Username: Asha619

Post Number: 8
Registered: 11-2011
Posted on Thursday, December 01, 2011 - 05:59 pm:   

the Midlet runs within the app.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3645
Registered: 08-2008
Posted on Friday, December 02, 2011 - 10:53 am:   

But where does the app run?

You don't need Internet connectivity to perform an HTTP transaction with NowSMS running on the same system (you use the internal loop back address of 127.0.0.1).
asha rajput
New member
Username: Asha619

Post Number: 9
Registered: 11-2011
Posted on Sunday, December 04, 2011 - 01:38 pm:   

currently i am developing and running the app from my laptop.
so is there a way i can use the normal J2ME SMS format to send an sms to nowsms by specifying the various addresses like message.setAddress();?
what address would i set?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3655
Registered: 08-2008
Posted on Monday, December 05, 2011 - 11:17 am:   

No.
asha rajput
New member
Username: Asha619

Post Number: 10
Registered: 11-2011
Posted on Tuesday, December 06, 2011 - 11:05 am:   

Ok thanks,you have any material or examples on how to send sms(via sms protocol) to nowsms using J2ME or any idea on how that can be achieved?
thanks.
Ali
New member
Username: Ali30

Post Number: 3
Registered: 11-2011
Posted on Tuesday, December 06, 2011 - 11:16 am:   

hi,
i have been having the same problem with J2ME.I managed to send an sms using the java code provided but now i want to do the same with J2ME but re-invent the wheel a bit because i want to send an sms to nowsms via sms protocol?

i am using a gsm modem connected to my machine.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3658
Registered: 08-2008
Posted on Tuesday, December 06, 2011 - 07:26 pm:   

I'm sorry, but I do not know of any way to configure J2ME, running on a computer (not a phone), to send an SMS message out using the SMS protocol (MessageConnection object).

The J2ME WMA Reference Implementation (http://java.sun.com/j2me/docs/pdf/WMA-RI.pdf) does state that SMPP can be used as an SMS protocol.

NowSMS can be configured to act as an SMPP server (see http://www.nowsms.com/using-nowsms-as-an-smpp-server-for-another-application).

However, I do not know how to configure the Java ME environment to send/receive SMS using SMPP. At a minimum, this would require, in the Java ME environment, configuring a host name or IP address for the SMPP server, port number for the SMPP server, and a username/password. The J2ME WMA Reference Implementation does not explain how this is possible.

--
Des
NowSMS Support