CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Sending AT Command to Nokia 7110

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
New Member
Guest







Sending AT Command to Nokia 7110
PostPosted: Thu Aug 14, 2003 3:50 pm     Reply with quote

Hello to all members.

I am student doing a project and wuld like to have the experts and experienced member to help in order to progress further.

I am trying to use a PIC16F877 to communicate to the Nokia 7110 GSM phone and send SMS text message. But I have spend so much time on the AT command and still no luck of getting it to work.

I can confirmed that the phone will work when I use the AT command on teh HyperTerminal as follows:

Note: where <CR> is carriage return, ^Z is Control-Z to indicate the end of text message.

AT+CMGF=1 <CR> (put into text mode)
OK (reponse from phone)
AT+CSCA="+447785016005" <CR> (set the message centre number)
OK (reponse from phone)
AT+CMGS="+447918816621" <CR> (set the destination phone number)
> This is a test message ^Z (Phone response with a promt >
+CMGS = 9

The above AT Command seems to work fine, i.e. the destination phone will actually receives the message "This is a test message".

My problem now is that I am trying to duplicate the above command in the PIC C code as shown below. But I can't get it to work. I must point out that I haven't done any C programming before, therefore I am a newbie to C programming.

What I'm trying to do is to sent out the AT command and also display the reponse from the phone so that I can see what the phone is actually receiving. From the following code all I can see is character "A" is being displayed on the LCD, and no SMS text message is being sent.

I also have a question for the members who can help.
(1) Do I need to send the promp ">" prior to my text message to the phone to simulate the above AT Cmmand shown in the above HyperTerminal?
(2) Do I need to use flow control on the serial communciation?. At the moment I haven't, this is because that I haven't use it in the HyperTerminal and it works fine.

I would apprecaite any help on the problem I am having, so that I can progress on my college project.


#include <16F877.h> // Defines chip

#use delay(clock=20000000) // Defines delay_clock
#include <lcdd.c>
#use rs232(baud=19200, XMIT=Pin_c6, rcv=pin_c7, parity=n, bits=8)


char received_from_phone[8];
const int CR=0x0d;
int i=0;
void main()
{
lcd_init();
{

printf("AT+CMGF=1");
putc(CR);
received_from_phone[i]=getc();

printf(LCD_putc, "\%C", received_from_phone[i]);

delay_ms(2000);
printf("AT+CSCA=\"+447785016005\"");
putc(CR);

printf(LCD_putc, "\%C", received_from_phone[i]);

received_from_phone[i]=getc();
delay_ms(2000);
printf("AT+CMGS=\"+447919916721\"");
putc(CR);

printf(LCD_putc, "\%C", received_from_phone[i]);

delay_ms(2000);
printf("THIS IS TEST MESSAGE");

putc(0x1A);

}

do{}
while(1); // so that the chip is not in sleep mode.
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516972
Dale Botkin
Guest







Re: Sending AT Command to Nokia 7110
PostPosted: Thu Aug 14, 2003 6:00 pm     Reply with quote

:=What I'm trying to do is to sent out the AT command and also display the reponse from the phone so that I can see what the phone is actually receiving. From the following code all I can see is character "A" is being displayed on the LCD, and no SMS text message is being sent.
:=

Big clue there... it's says "A", not "O" or "OK". Check to see if HyperTerminal is set for full or half duplex; probably full, which means your phone is echoing characters back to you.

:=I also have a question for the members who can help.
:=(1) Do I need to send the promp ">" prior to my text message to the phone to simulate the above AT Cmmand shown in the above HyperTerminal?

:=(2) Do I need to use flow control on the serial communciation?. At the moment I haven't, this is because that I haven't use it in the HyperTerminal and it works fine.

HyperTerm defaults to hardware flow control, so unless you have changed that it probably is still doing it. Check your phone's interface specs or settings - I've never dealt with a phone serial port, but at any rate if you know the signals it can't hurt to wire it for hardware flow control and try it.

:=#include <16F877.h> // Defines chip
:=
:=#use delay(clock=20000000) // Defines delay_clock
:=#include <lcdd.c>
:=#use rs232(baud=19200, XMIT=Pin_c6, rcv=pin_c7, parity=n, bits=8)
:=
:=
:=char received_from_phone[8];
:=const int CR=0x0d;
:=int i=0;
:=void main()
:={
:= lcd_init();
:= {
:=
:= printf("AT+CMGF=1");
:= putc(CR);

**WARNING****WARNING****WARNING**
Untested code ahead. These are suggestions, I'm not writing this so they may be wrong. Use at your own risk. 8-)
**WARNING****WARNING****WARNING**

Try printf("AT+CMGF=1\n"); or puts("AT+CMGF=1");

:= received_from_phone[i]=getc();
:= printf(LCD_putc, "\%C", received_from_phone[i]);
Using gets() instead of getc() is probably a better idea. Getc() only gets one character, gets() takes all input up to a newline or CR. Also, you're telling printf() to only print one character from your string.

Also, since your phone will apparently be echoing the data you sent THEN sending "OK", you may want to do this just for testing - for real use you'd want to do some more involved error checking and handling:

gets(received_from_phone);
printf(lcd_putc,"\%C",received_from_phone);
gets(received_from_phone);
printf(lcd_putc,"\%C",received_from_phone);

:=
:= delay_ms(2000);
:= printf("AT+CSCA=\"+447785016005\"");
:= putc(CR);

See above.

:=
:= printf(LCD_putc, "\%C", received_from_phone[i]);
:=

Ditto.

:= received_from_phone[i]=getc();
:= delay_ms(2000);
:= printf("AT+CMGS=\"+447919916721\"");
:= putc(CR);
:=
:= printf(LCD_putc, "\%C", received_from_phone[i]);
:=
:= delay_ms(2000);
:= printf("THIS IS TEST MESSAGE");
:=
:= putc(0x1A);
:=
:= }
:=
:=do{}
:=while(1); // so that the chip is not in sleep mode.
:=}

Anyway, maybe that will help some.

Dale
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516978
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group