Solved

Sending SMS messages via GPRS

Posted on 2010-11-22
50
1,673 Views
Last Modified: 2013-12-27
I want to develope an application which will send SMS through GPRS, if GPRS is available,  if not- send the SMS in the conventional way.

Initially, I'm hoping to develop it using C#.net and Windows Mobile 6.

Could someone point me the right direction to get me started on this.
0
Comment
Question by:Spike_66
  • 22
  • 13
  • 9
  • +2
50 Comments
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34187042
0
 

Author Comment

by:Spike_66
ID: 34187088
Hi
Thanks for the reply. I think I need to explain it a bit more fully.
I'm writing an application that is to sit on a phone and send messages at a regular rate at quite frequent intervals top a modem. To save SMS being used, I want to send the messages via GPRS, if available.
Cheers
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34187092
I understand, what I meant is that you need to open com port to communicate to GPRS on the phone and send AT commands. For regular SMS sending simply use PocketOutlook assembly (numerous samples everywhere on the net, just google it).
0
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 34187109
0
 

Author Comment

by:Spike_66
ID: 34187154
Regular sending of SMS messages is not a problem (I've written the application to regularly send SMS messages already.). i want to convert it to send these messages over GPRS instead.
I might be missing something, alexey_gusev, but aren't the links to articles explaining how to send GPRS messages from Hyperterminal on your PC?
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34187158
ignore that it is about PC, the main idea is to open the com port and feed it AT command :)
it doesn't matter if that happens via hyperterminal or you do it yourself. AT commands is what you need, and how you send it it's up to you.
0
 
LVL 2

Expert Comment

by:dinudany
ID: 34187192
it seems that you want to send SMS from your mobile phone, using the GPRS technology.
If so, then you can purchase sms service from the service providers, like some companies provide you a push link where you have to input you senders mobile number, your login details and message. then the sms is sent to the respective number, note: their are multiple options for this costing very less for single sms
0
 

Author Comment

by:Spike_66
ID: 34189950
I understand the idea about sending it AT commands and have cobbled together the code to do this.
What I'm struggling with at the moment is getting my head around the opening of the COM port on the phone. I'm unsure of the settings required to open the COM port.
i.e.
port.PortName = how can I tell which port to use, or would it always be COM1?
Cheers
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34190706
no, it wouldn't be COM1 usually, but the rest of the settings may be as follows:

7 bit, 115200 baud (this may vary), 1 stop bit, hardware control

Re. com port name, you might want to look at HKLM\Drivers\BuiltIn to find what port corresponds to Unimodem. Or maybe there will be something about GSM as well, depends on the device.
0
 

Author Comment

by:Spike_66
ID: 34194955
So the COM port  is device dependant and would  change depending on the phone being used?
How is this delt with as far as developing applications for different handsets, let alone OS?
Cheers
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34195265
yes, this is device dependant. if you look at the registry, you can find there something about gprs or gsm. for instance, on my custom WinCE50 device there is the following key:

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\GPRS2440]

which tells me in its values that it can be accessed as "DSK1:"  :)  

So if I were you I would probably set the com port via some kind of configuration means. In general, if you want some 'auto-discovery' feature, you might try to open COM ports in a loop, writing there eg "ATZ" command and waiting for "OK", something like that.
0
 

Author Comment

by:Spike_66
ID: 34195407
OK- I've found a the following key in the registry:
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\CODEC_GSM610] There is no reference to GSM or GPRS.
I take it it is the Prefix value I need- I was expecting Value!
Cheers

0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34195508
just try COM ports from 1 to 9 and see if any of them returns you "OK" on "ATZ"
0
 

Author Comment

by:Spike_66
ID: 34195671
A bit confused now, sorry.
I've writen a quick application to send AT commands to the phone.
I've plugged in the phone via USB.
When I check which COM port is opened when I attach the phone, by checking the DeviceManager, no new COM port appears. The phone opens a new Network adapter (Microsoft Mobile Remote Adapter #4).
I've tried connecting to it using Hyperterminal, but the ports available don't work.
I could write a quick application to install on the phone to test which COM port to use, but shouldn't I be able to send it AT commands from Hypperterminal?
(I've upped the points- this is becoming more involved that I thought it would be).
0
 

Author Comment

by:Spike_66
ID: 34196293
Ok
An update- I've tried setting the phone up as a new  connection, via the Network and Sharing Centre (I'm using Windows 7). I tried adding it as a new Dial Up Connection and I received the message that a dial up modem could not be detected. The mobile is connected OK (it is listed up the Device Manager as a Portable Device rather than as  a Modem). Ideas?
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34197402
>> I'm writing an application that is to sit on a phone and send messages at a regular rate at quite frequent intervals top a modem
hold on, did I misunderstood you? Why are you trying to connect the phone to the desktop PC? As far as I perceive what you want to achieve is this:

- you have the phone which has GPRS/GSM modem
- you want to use it (the phone + GSM) to send SMS messages

So then you need to find the port GSM is sitting on, and send AT commands to that port. All this does NOT involve any desktop parts at all :) [ well, apart from using VS2005/2008 and ActiveSync/WMDC for debugging etc ]

Am I missing something?
0
 

Author Comment

by:Spike_66
ID: 34197656
I was going to send the commands via Hyperterminal just to detect the port.
No matter- I've moved on.
I believe I've got the right COM port, by writing a small app for the phone.
I'm just writing the bit to send a message, so hopefully I'm on the home straight now.
I'll leave this open for now and come back with any further issue soon.
If all goes well I'll close it this off shortly.
Cheers
0
 

Author Comment

by:Spike_66
ID: 34204699
Hi
Ok back to this - the idea of having the right port was wrong- possibly!
I can Open a port on the phone (OK- I can open a few, but I've tried the following with all of the ones that "open").
I have tried sending AT commands to the open port- but don't seem to  be getting any response.
However, when I opened the port , one setting I did't know what to enter was the encoding:( i.e.
port.Encoding). I'm guessing  this is required.
How can I determine what these settiungs should be?
Cheers
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34209592
it has to be ascii I think, so port settings are usually like that:

115200, 7 bit, No Parity, 1 Stop Bit

Have you tried all com ports from 1 to 9?
0
 

Author Comment

by:Spike_66
ID: 34211453
Yes- (actually up to 10.)
When I try to set the port to open- I can get some of them to open OK (I check this by checking the status of the potrt).
However, I never get a response from any of them.
Currently, I'm runnning the application on the phone via my laptop, and deploying it on a Trio Pro.
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34211656
hmm, ok, this one should have GSM module. perhaps it simply doesn't have it? then opening the com port and sending AT commands won't work :(

Check also these links in case you're on CDMA and on on GSM, maybe it would help:

http://www.sendsms.cn/download/CDMA_AT_178.pdf
http://igor.chudov.com/manuals/AT_Commands-For-CDMA-Modems-Incl_Qualcomm_U300.pdf
0
 

Author Comment

by:Spike_66
ID: 34211703
I've actually now installed the app on the trio, and enabled the selection of which COM port to open. Still no joy in getting a message back.
0
 

Author Comment

by:Spike_66
ID: 34228924
Could someone comfirm whether you actually need a GPRS data contract with your SIM to be able to get message responses from sendning AT commands to the relevant port?
Cheers
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34229393
I use pay-on-the-go SIM on the device (WinCE 5.0) with GSM/GPRS, and sms sending works fine. GSM uses COM3 which I send to/read from.
0
 

Author Comment

by:Spike_66
ID: 34229930
Hi
Not really what I meant. I've enabled GPRS on the phone, but don't actually have a SIM with GPRS.
Will the phone still respond to simple AT commands in this case- or do I need to have a GPRS SIM to receive even "OK" back.
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34255965
If you attach a GSM device via a USB cable it won't automatically pop up as a COM port. Normally there is a bit of software which comes with the device which will enable a COM simulation. What is the name/type of device you are using?
0
 

Author Comment

by:Spike_66
ID: 34256193
Hi-
I've written a Windows Mobile applicsation  in C#
Rather than sending SMS messages I want use GPRS.
I am using Visual Stio to develop it.
I am using the Windows Mbile Device Centre to communicate with it.
I have added some code to the application just to test the sending of AT commands.
I can select the port to use on the phone (1-10)
I open the port (then display the state of the port (open/ closed).
I then send simple AT command to it to see if I can get the response "OK".
I have tried running this application from VS, deploying it to the phone (it deloys fine)- as well as actually installing it on the phone.
I never get OK back.
I have enable GPRS on the phone (but don't actually have a SIM account with GPRS).
Should I still get a OK back when sending AT commands?
Cheers
I
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34256282
You didn't answer my question.

If the phone actually does map to a COM port, then open HyperTerminal, select the relevant port and type ATZ or AT0 or just AT, followed by return. One of those commands must return either OK or an error. If nothing happens then there is no connection between a Windows virtual serial port and the device, probably because some software is missing. If you cannot even open the port, the software is definitely missing.
0
 

Author Comment

by:Spike_66
ID: 34256413
I'm not expecting that when I connect the phone  via a USB cable it won't automatically pop up as a COM port.  (I did when I started this- but I've moved on!). (The phone is a Trio, by the way.)
I'm opening the COM port on the phone via the phone appication - I'm not using Hyperterminal to send commands to the phone.
I have written an application that simply opens a COM port (on the phone) then sends AT commands. The application is running on the phone (or in VS and depoyed to the phone).
I can open (and close) each of the ports on the COM ports on the phone OK- and when I check their status it returns that it has been oppened or closed.
I have tried send AT commands to each of these ports  (that open), but get no response from them.
I  think hyperterminal will complicate it further as I can already send AT commands.
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34256608
Well, you can't send AT commands, since you don't get any reply. The simplest command ATZ resets the phone and should always give a OK response.

I'd open the COM port and set 8,N,1 as the bits per byte, parity and stop bit, then set 9600 speed (just to be on the safe side). Perhaps you might publish a bit of your code? PS sometimes you have to wait a bit for any reply. I time out after 5 seconds, longer when sending PDUs, but that's another matter.
0
 

Author Comment

by:Spike_66
ID: 34256698
Hi
I was trying to send more complicated commands but have reduced it to just AT- just to get a response!  I do seem to be able to open the ports OK.

To open the port:
~~~~~~~~~~~~~~
port.PortName = p_strPortName;                 // eg: COM1
port.BaudRate = p_uBaudRate;                   //9600
port.DataBits = p_uDataBits;                   //8
port.StopBits = StopBit.One;                  //1
port.Parity = Parity.None;                     //None
port.ReadTimeout = p_uReadTimeout;             //300
port.WriteTimeout = p_uWriteTimeout;           //300
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
port.Open();
port.DtrEnable = true;
 port.RtsEnable = true;

To write to the port:
~~~~~~~~~~~~~~~
port.DiscardOutBuffer();
port.DiscardInBuffer();
receiveNow.Reset();
port.Write(command + "\r"); //where command is just  AT at the moment

Then:
~~~~~~~~~~~~~~
string input = ReadResponse(port, responseTimeout); //where Timeout is currently set to 1000
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34256878
Can you tell me whether SerialDataReceivedEventHandler actually fires?

I suspect that port.Open() actually does nothing other than set up the software side.
0
 

Author Comment

by:Spike_66
ID: 34257140
I'll have get back to you on that.
I'm snowed in at the moment and the phone is at work!
I'm assuming the simulator woun't respond to AT commands- is there a bolt on GPRS simulator available anywhere?
By the way, I did remove:
port.Encoding = Encoding.GetEncoding("iso-8859-1");
as it caused errors- should I be using something similar?
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34258013
It is some time since I worked on out GPRS modem software and in those days I used the Nokia Tool Kit. You might find something on the Nokia site.

The encoding option is not an issue. Forget it.

In those days I had several phones to test the compatibility of our software and I always used Hyperterminal to establish that the phone actually had the interface. Some older phones did not support the establishment of a TCP/IP connection and therefore did not respond to AT commands or to specific comands. Your phone has actually three SIM cards in it. I don't think I was able to get my phone to work without a SIM card (if that's an issue?), and I'd like to know how you know with which SIM card one communicates with?
0
 

Author Comment

by:Spike_66
ID: 34258214
"Your phone has actually three SIM cards in it. "???  it has a O2 SIM card installed (no GPRS on the SIM)- am I missing something?
The reason I'm not using hyperterminal is that I couldn't seem to get it communicate at all.
When the phone was plugged in usin the USB cable, if you look back at my posts, you'll see when  I plugged in the phone via USB,  I check which COM port is opened by checking the DeviceManager, no new COM port appears. The phone opens a new Network adapter (Microsoft Mobile Remote Adapter #4).
I've tried connecting to it using Hyperterminal, but the ports available didn't work.
The phone is a very new Windows Mobile-based Palm Treo Pro.
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34259229
>>no GPRS on the SIM)- am I missing something?

No, you wrote "Trio" and not "Treo pro". The Trio is a multiple SIM device so that one can open more than one channel and multiplex TCP/IP over a slow network.
0
 

Author Comment

by:Spike_66
ID: 34259306
Sorry!
0
 

Author Comment

by:Spike_66
ID: 34281296
Hi

I'm still awaiting a response to the question Could someone comfirm whether you actually need a GPRS data contract with your SIM to be able to get message responses from sendning AT commands to the relevant port?"

Re:"Can you tell me whether SerialDataReceivedEventHandler actually fires?"
It's difficult to tell: for some reason I can't use breakpoints- they become disabled when I run the code (in debug moode)- both on the simulator and when deployed to the phone.

Cheers
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34300574
>>It's difficult to tell: for some reason

You build in a bit of code which writes the event into a file. If the file is empty no event.

I still think you ought to be able to test the device with Hyperterminal, since this is the only real way of ascertaining whether the device does implement AT commands.

>> Could someone comfirm whether you actually need a GPRS data contract with your SIM to be able to get message responses from sendning AT commands to the relevant port?"

It all depends on the device. I have always tested WITH a SIM card, since I wanted to actually SEND data, so I can't tell whether it is the case with your device. In any event one needs to know the exact model number in order to tell whether the device actually implements AT commands.
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34300722
if it works with Pay-as-You-Go SIM cards, then I believe the data plan is unnecessary.
0
 

Author Comment

by:Spike_66
ID: 34301040
"I still think you ought to be able to test the device with Hyperterminal, since this is the only real way of ascertaining whether the device does implement AT commands."

As stated in an earlier poat:

"The reason I'm not using hyperterminal is that I couldn't seem to get it communicate at all.
When the phone was plugged in using the USB cable, if you look back at my posts, you'll see when I plugged in the phone via USB, I check which COM port is opened by checking the DeviceManager, no new COM port appears. The phone opens a new Network adapter (Microsoft Mobile Remote Adapter #4).
I've tried connecting to it using Hyperterminal, but the ports available didn't work.
The phone is a very new Windows Mobile-based Palm Treo Pro. "

How do I get Hyperterminal to control it?




0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34301108
if you want hyperterminal, you might try this one: http://www.tsreader.com/ztermppc/index.html

or just open com ports from the code (as you have been trying already)
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34301542
>>port.PortName = how can I tell which port to use, or would it always be COM1?

Yes we are going around in circles because this is the primary problem.

A USB device HAS TO HAVE SOFTWARE installed to make it behave like a serial device. This might be com0com (freeeware) or it might be propierty. In order to tell whether the device HAS this option, I need the product name and it's model number. In that way we might to able to find out whether the device actually supports AT commands and if so how or with what driver/connector.
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 34301604
@BigRat: OP is doing it on Windows Mobile device [>> Initially, I'm hoping to develop it using C#.net and Windows Mobile 6.], so it is NOT a desktop and hence USB and com0com are nice but certainly not available :)
0
 
LVL 27

Accepted Solution

by:
BigRat earned 500 total points
ID: 34301781
I see, now I understand.

I think that the problem is that there are two standards and Windows Mobile hides them under an interface which simulates the AT commands.

I'd look at http://en.wikipedia.org/wiki/Radio_Interface_Layer
http://msdn.microsoft.com/en-us/library/ms890075.aspx

I think that RIL is the only way to low-level control the device.
0
 

Author Comment

by:Spike_66
ID: 34333776
I've had a look at these links and they look as if they will provide the answer.
However, whilst I was waiting, I've decided to probably use a Webservice instead!
I'm going to close this, accepting BigRat's solution- as it at least  points me in the right direction-(if I do change my mind again.)
Thanks for the help!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now