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 support@ccsinfo.com

GSM Modem AT+CMGS Error

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



Joined: 22 Oct 2009
Posts: 12

View user's profile Send private message

GSM Modem AT+CMGS Error
PostPosted: Tue Aug 02, 2011 8:55 pm     Reply with quote

Please check the code

Code:

#include <16F877A.h>
#include <string.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES XT                       //Crystal osc <= 4mhz

#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,BRGH1OK,ENABLE=pin_c0,RESTART_WDT)

#byte trisc= 0x87
char rxd[20],rx;

void sms_hi_temp(void);

char phonelist[3][13]={   "+94XXXXXXXX",
               "+94XXXXXXXX",
               "+94XXXXXXXX"};

void initz(){
   set_tris_b(0xFF);
   bit_clear(trisc,0);
   bit_clear(trisc,1);
   setup_psp(PSP_DISABLED);
      enable_interrupts(GLOBAL);
}
void init_gsm(){
   printf("AT+CMGF=1\r");
   delay_ms(1000);
   printf("AT+CMEE=1\r");
   delay_ms(1000);
   printf("AT+CPMS=");
   putc('"');
   printf("SM");
   putc('"');
   putc(',');
   putc('"');
   printf("SM");
   putc('"');
   putc(',');
   putc('"');
   printf("SM");
   putc('"');
   printf("\r");
   delay_ms(1000);
}
void main(){
   initz();
   output_high(pin_c1);
   output_high(pin_c2);
   delay_ms(1000);
   output_low(pin_c1);
   output_low(pin_c2);
   init_gsm();
      sms_hi_temp();
   while(true){

      }
}

#int_RDA
void  RDA_isr(void)
{
      gets(rxd);
}

/////////////////////////////////////////////////////////////
void sms_hi_temp(){
   int l=0,i;
      printf("AT+CMGS=");
   //   putc('"');   
      for(i=0;i<13;i++){
         putc(phonelist[l][i]);
      }
   //   putc('"');
      putc(13);
      delay_ms(2000);      
      printf("High TEMP");
      putc(26); //send the msg   

}




above is my gsm command program to send message to my phone. but nothing happened. so i tap the gsm moedm's TX pin to Hyper terminal and this is what it prints




AT+CMGF=1
OK
AT+CMEE=1
OK
AT+CPMS="SM","SM","SM"
+CPMS: 2,28,2,28,2,28

OK
AT+CMGS=+94XXXXXXXX
> High TEMP
+CMGS: 133

OK




but message never receive to my phone.

when i send "AT+CMGS=+94XXXXXXXX"(with the " ") instead of AT+CMGS=+94XXXXXXXX it returns CMS ERROR: 305 (Invalid Text mode parameter)


i connected to GSM module to hyper terminal and type the number (with and without " ") and it works both way.

can any one tell me what's going on?
sigma-mx



Joined: 02 Jun 2008
Posts: 3

View user's profile Send private message

PostPosted: Wed Aug 03, 2011 3:47 am     Reply with quote

Hi , try this ..
Code:

printf("AT+CMGF=1\r\n");    // just this enough
delay_ms(10);
printf("AT+CMGS=\"+94XXXXXXXXXX\"\r\n");
delay_ms(10);
printf("HIGH TEMP\r\n%c",26);
delay_ms(2000);

return any result......tanx
cbkulatunge



Joined: 22 Oct 2009
Posts: 12

View user's profile Send private message

PostPosted: Wed Aug 03, 2011 9:11 am     Reply with quote

thanks. it works i found the bug LF is missing
bassn1



Joined: 03 Aug 2011
Posts: 6

View user's profile Send private message

PostPosted: Wed Aug 03, 2011 10:32 am     Reply with quote

What type of gsm module are you using?
Mamat



Joined: 20 Jan 2011
Posts: 9

View user's profile Send private message Yahoo Messenger ICQ Number

gsm
PostPosted: Tue Oct 11, 2011 10:22 am     Reply with quote

so what work code now?
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