8051 microcontroller 8051 microcontroller
Forums

Page 2 of 6    1 [2] 3 4 5 6
Moderators: Ajay Bhargav, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph, ExperimenterUK, DavesGarage, majoka
Author Post
majoka
Wed Feb 15 2012, 05:50AM

Registered Member #22104
Joined: Thu Sep 10 2009, 03:04PM
Location (Home Town): Wah Cantt, Pakistan
Posts: 3900
@ Alvanbert
yes the code is correct
i use it with gsm modem and its works
u need t capture a event of new message notification
same thing is for cell phone as well as modem
which cell phone or modem ur using
Back to top
Alvanbert
Wed Feb 15 2012, 09:14AM
Registered Member #37274
Joined: Fri Feb 10 2012, 02:33PM
Location (Home Town): Kampala
Posts: 33
Hi Majoka, Thanks for yr reply. Pliz show me how i can integrate the capture of the new message notification into the code.
the Code above the last post i made has a code from Ajay that Kiran told me to use which i think is meant for this but i dont know how to integrate it.

Am using a Huawei Modem E160...its A USB modem
Back to top
kirangowle
Wed Feb 15 2012, 10:50PM

Registered Member #26972
Joined: Thu Mar 18 2010, 09:18AM
Location (Home Town): Bangalore, Karnataka
Posts: 587
In that same post its there read notification()
implement it in main program. u ll get.

Back to top
Alvanbert
Thu Feb 16 2012, 10:07AM
Registered Member #37274
Joined: Fri Feb 10 2012, 02:33PM
Location (Home Town): Kampala
Posts: 33
hi guys. i av been working on different though am yet to come to a successful conclusion. i want u to tell me whether this would be possible.

1. Is it possible to increment the 1 using aloop in the the command in the line ..SMSString( "AT+CMGR= 1 \r");...so that it can be able to read
( "AT+CMGR= 2 \r");, ( "AT+CMGR= 3 \r"); ( "AT+CMGR= 4 \r");...so that it can check from address 1-5 using a variable e.g n

2.If The above is okay....in case my simcard receives messages greater that the variable stated, i want it to delete the oldest message..which in this case would be the message at n=1 and replace it with the newest and the loop continues.
Back to top
kirangowle
Thu Feb 16 2012, 11:04PM

Registered Member #26972
Joined: Thu Mar 18 2010, 09:18AM
Location (Home Town): Bangalore, Karnataka
Posts: 587
In SMSString() its not possible to increment no.
Do like this
SMSString("AT+CMGR=");
tx0(var++);
SMSString("\r");

Second method also can be done.As soon as you receive a msg read/store it and delete it.So that when next msg arrives it sits in 1st location only.
Back to top
Alvanbert
Fri Feb 17 2012, 09:44AM
Registered Member #37274
Joined: Fri Feb 10 2012, 02:33PM
Location (Home Town): Kampala
Posts: 33
Thanks Kiran. But the problem now is tx0 function is supposed to output unsigned characters and yet i think the variable will be an integer.
i have tried to declare the (var) as an integer globally but wen the program runs the "AT+CMGR = " doesnt pick up the digit..so in the terminal it displays as shown in the snapshot below


secondly, KiRAN said
Second method also can be done.As soon as you receive a msg read/store it and delete it.So that when next msg arrives it sits in 1st location ony


How can i do this.. thought it would be easier to read from message location 1,2,3,4,5 then back to 1...through the loop i was suggesting above...
so when a new message arrives after location 5 has been filled..instead of storing it in 6, i will delete message in location 1 and place it there and the loop continues..... I hope am clear enough..

THANKS
Back to top
Ajay Bhargav
Tue Feb 21 2012, 06:06PM
Rickey's World Admin


Registered Member #1
Joined: Fri Feb 24 2006, 07:56AM
Location (Home Town): Punjab, India
Posts: 12597
var must be converted to ascii first before sending it to modem. and "AT+CMGR=" without spaces around '=' sign
Back to top
Alvanbert
Wed Feb 22 2012, 05:47PM
Registered Member #37274
Joined: Fri Feb 10 2012, 02:33PM
Location (Home Town): Kampala
Posts: 33
Thanx A jay but problem is i dnt knw how 2 convert variable 2 ascii. Pliz enlighten me on how to do this. Thanx
Back to top
ExperimenterUK
Wed Feb 22 2012, 06:08PM

Registered Member #9602
Joined: Tue Aug 05 2008, 07:15PM
Location (Home Town): Manchester
Posts: 2856
Alvanbert wrote ...

Thanx A jay but problem is i dnt knw how 2 convert variable 2 ascii. Pliz enlighten me on how to do this. Thanx

For numbers up to 10 the best method is just to add 0x30 to the value.
EG
0 becomes 0x30 which is ascii '0'
1 becomes 0x31 which is ascii '1' etc.

For 10 or above use "printf", "sprintf" or "itoa"
"printf" will often add a lot of code so is best avoided.
Back to top
Alvanbert
Fri Feb 24 2012, 07:27AM
Registered Member #37274
Joined: Fri Feb 10 2012, 02:33PM
Location (Home Town): Kampala
Posts: 33
Thanx alot guys for your help...now am getting some output on the screen.

Now am left with one disturbing issue though it should be easy.
am failing to create a loop that can display the message onto the lcd from at+cmgr=1 to at+cmgr=5
below is the part of the code where i want to set up the loop pliz help.
CODE:

SMSString("AT\r"); // AT commands to initialize gsm modem
delay_sms(1000);

SMSString( "ATe0\r"); // turn off echo
delay_sms(1000);

SMSString( "AT&W\r"); // save settings
delay_sms(1000);

SMSString( "AT+CMGF=1\r"); // select text mode for sms
delay_sms(1000);

SMSString( "AT+CNMI=2,1,0,0,0\r"); // notification of new sms
delay_sms(1000);

SMSString( "AT+CMGR="); // AT command to read sms
tx0(var++);
SMSString( "\r");

IE=0X90;   // Enable serial interrupt
delay_sms(2000);

/* i get a response like this

// +CMGR: "REC READ" ,"+2347060580383","10/10/23,14:29:33+04"
// device1 off
// Ok. */


// read sms and store in buffer msg1
read_text(msg1);
delay_sms(2000);
IE=0X00;     // Disable all interrupt
while(1);
 


Back to top
Page 2 of 6    1 [2] 3 4 5 6  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

© 2010 Rickey's World
Render time: 0.0787 sec, 0.0089 of that for queries. DB queries: 69. Memory Usage: 2,934kB