Read SMS message
Hello,
I have Wavecom GSM/GPRS modem connected via MAX2323E to my propeller. I Have no problem to send sms with AT commands, but i can't figure out how to recieve a sms message.
I use this code to send:
Is there anyone who can help me with a tip how i can recieve a message and for example show it in the Serial Terminal.
Grateful for any help!
/Mikael
I have Wavecom GSM/GPRS modem connected via MAX2323E to my propeller. I Have no problem to send sms with AT commands, but i can't figure out how to recieve a sms message.
I use this code to send:
{{Mickes GSM 1.0}}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
obj
gsm: "FullDuplexSerial"
debug: "Parallax Serial Terminal"
var
long stack[90]
pub main
debug.start (115200)
gsm.start (26, 27, 0, 9600)
waitcnt (clkfreq * 2 + cnt)
gsm.str (string("AT+CMGS=")) 'send sms command
gsm.tx(34) ' send a "
gsm.str (string("+46708667705")) 'phonenumber
gsm.tx(34)
gsm.tx(13) ' CR
waitcnt (clkfreq * 2 + cnt)
gsm.str (string("Hello World!!"))
waitcnt (clkfreq * 2 + cnt)
gsm.tx(26) 'ctr-z to send message
debug.str(string("Klar!"))
Is there anyone who can help me with a tip how i can recieve a message and for example show it in the Serial Terminal.
Grateful for any help!
/Mikael
Comments
The string to read an SMS in a memory slot N (N is an integer!!) is:
AT+CMGR=N
To have a list of all the stored SMS use:
AT+CMGL="ALL"
Let me know if it works.
Massimo
AT command Meaning
+CNMI New message indications
+CMGL List messages
+CMGR Read messages
+CNMA New message acknowledgement
Below shows a simple example
AT
OK
AT+CMGF=1
OK
AT+CMGL="ALL"
+CMGL: 1,"REC READ","+85291234567",,"06/11/11,00:30:29+32" Hello, welcome to our SMS tutorial.
+CMGL: 2,"REC READ","+85291234567",,"06/11/11,00:32:20+32" A simple demo of SMS text messaging.
OK
AT+CMGR=2
+CMGR: 2,"REC READ","+85291234567",,"06/11/11,00:32:20+32" A simple demo of SMS text messaging.
OK
OK
I forget to tell, i'm a newbee....!
I have the AT commands, but i can´t figure out how to read the serial string from the modem...
I suspect you can do the same on the Wavecom
Is there any "trick" with the wiring of the max3232 that can go wrong? I have just wired the tx and rx directly to the prop pins, is that ok?
Thanks!
/Micke
There are a couple of traps. With the Telit modules you connect TXD of the modem to TX on the prop, and RXD to RX. This is slightly counter-intuitive as often one would connect TX and RX, and RX to TX. I'm not sure if Wavecom is the same or not - which exact module are you using?
If connecting directly to the prop you need to check the compatibility of the logic levels. Telits have 2.8v logic and a small resistor helps protect too much current from flowing. Or there are proper level shifting ICs if you want to do the job properly.
I'll PM you code I know works with the Telit in case its helpful
cheers
tubular
I will test the code as soon as possible ( have to work first...!)
The modem is a wavecom fastrack M1203. I think it uses TTL because i have -5v on one of the tx or rx pins when it is not connected.
/Micke
It sounds like you may be having some connection/hardware issues. Once those are resolved if you have further questions you might find some useful information in this thread or in some of the links therein.
http://forums.parallax.com/showthread.php?129927-Help-parsing-SMS
pb
But, to my next problem, i use the Extended FD_Serial obj to recieve the serial strings. Is it possible to extend the recieved bytes from 16 to 25?
I Have read on the forum thats its possible, but i cant figure out how, is there any example that i have missed?
Thanks!
/Mikael
Now i am stucked in next problem. When i try to use STRCOMP to parse the message from the modem with a string, i get no luck.
The code works fine until it get to the strcomp section, it just wont send it to the right PUB.
{{Mickes GSM 1.0}} CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 obj gsm: "Extended_FDSerial" debug: "Parallax Serial Terminal" var byte message[16], phonenumber[16], mess1[16], mess2[16], mess3[16], mess5[16], mess6[16], mess7[16] dat on byte "on", 0 off byte "off", 0 pub main debug.start (115200) gsm.start (26, 27, 0, 9600) waitcnt (clkfreq * 2 + cnt) dira[2] :=1 readmessage pub readmessage repeat waitcnt (clkfreq * 5 + cnt) gsm.rxflush gsm.str (string("AT+CMGR=1")) 'Read sms in first memory gsm.tx(13) 'CT debug.str (string("Get message in memory1...")) debug.newline gsm.RxStrTime(300,@mess1) gsm.RxStrTime(300,@mess2) gsm.RxStrTime(300,@mess3) gsm.RxStrTime(300,@phonenumber) gsm.RxStrTime(300,@mess5) gsm.RxStrTime(300,@mess6) gsm.RxStrTime(300,@mess7) gsm.RxStrTime(300,@message) waitcnt (clkfreq * 1 + cnt) gsm.str(string("AT+CMGD=1")) 'Delete message in first memory gsm.tx(13) waitcnt (clkfreq * 1 + cnt) debug.newline debug.str(@mess1) debug.newline debug.str(@mess2) debug.newline debug.str(@mess3) debug.newline debug.str(@phonenumber) debug.newline debug.str(@mess5) debug.newline debug.str(@mess6) debug.newline debug.str(@mess7) debug.newline debug.str(@message) if strcomp (@message, string("on")) on2 elseif strcomp (@message, string("off")) off2 debug.str(string("no message, repeat")) debug.newline pub on2 debug.str(string("Output2 on")) outa[2] :=1 waitcnt (clkfreq * 2 + cnt) gsm.str(string("AT+CMGS=")) 'gsm.tx(34) ' send a " gsm.str (@phonenumber) 'phonenumber 'gsm.tx(34) gsm.tx(13) ' CR waitcnt (clkfreq * 2 + cnt) gsm.str (string("Output on")) waitcnt (clkfreq * 4 + cnt) gsm.tx(26) return pub off2 debug.str(string("Output2 off")) outa[2] :=0 waitcnt (clkfreq * 2 + cnt) gsm.str(string("AT+CMGS=")) 'gsm.tx(34) ' send a " gsm.str (@phonenumber) 'phonenumber 'gsm.tx(34) gsm.tx(13) ' CR waitcnt (clkfreq * 2 + cnt) gsm.str (string("Ouput off")) waitcnt (clkfreq * 4 + cnt) gsm.tx(26) return