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

SMS - Text Messages - GSM - Remote Control - UPDATE 06/05/13
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
Gabriel



Joined: 03 Aug 2009
Posts: 964
Location: Panama

View user's profile Send private message

PostPosted: Tue May 05, 2015 5:33 pm     Reply with quote

To search for the unknown string, first confirm you have a known string like "PHONE" in your example.

Then search the buffer individually for a O then an N and finally an E... if the conditions are met you are now standing at the beginning of your desired string.... after doing the above you now know exactly the index number of where in your buffer your desired string starts.... then just copy it one by one to your variable/temp string.

G.
_________________
CCS PCM 4.135 & CCS PCH 5.013
creative_35



Joined: 02 Jan 2007
Posts: 15

View user's profile Send private message

PostPosted: Wed May 06, 2015 8:07 am     Reply with quote

Thanks Gabriel for the instant reply, I wrote the code as follows
Code:
char *p;
p= strchr(Receive_String,'H');
if ((p+1)==strchr(Receive_String,'O')||(p+2)==strchr(Receive_String,'N')||(p+3)==strchr(Receive_String,'E'))

int k = p-Receive_String+4;
strncpy(SAVED_NUMBER,Receive_String+k,10);
fprintf (TERMINAL,"\r%s\n",SAVED_NUMBER);

Is is working, But I have to change the "SIZE_BUFFER" value to 90 and it's almost full the "RAM".
returning error If I change above 96 !!
(*** Error 74 "gsmtest.c" Line 178(1,2): Not enough RAM for all variables)

Any Idea to skip the first half portion of the message to reduce the BUFFER size? Thank you,
Gabriel



Joined: 03 Aug 2009
Posts: 964
Location: Panama

View user's profile Send private message

PostPosted: Wed May 06, 2015 8:19 am     Reply with quote

Remember that your message might include more than one 'H' so you need to keep checking the buffer for the "HONE" string until the end of buffer.

Else if you find an unrelated 'H' the subsequent IFs will fail even if the correct message is further down the buffer.

I've tried numerous ways of skipping the first part of the message and ive found it to be very impractical cause you lose a lot of information, you have to include stuff in you ISR. It is also very dependent on your PIC speed.
Doing string searches on the buffer that is still being filled might not yield good results... not impossible but cumbersome (IMO).

Mi current buffer is 255 chars long... considering SMS has a limit of 140 (160?) chars + the system info included by the modem.
_________________
CCS PCM 4.135 & CCS PCH 5.013
samuel



Joined: 04 May 2016
Posts: 14

View user's profile Send private message

PostPosted: Tue May 10, 2016 6:01 am     Reply with quote

Hello!

please what can i change in the main program if i should use pic16f877

because i tried including pic16f877a i receive error
Quote:
undefined identifier CCP_PULSE_STEERING_A
Gabriel



Joined: 03 Aug 2009
Posts: 964
Location: Panama

View user's profile Send private message

PostPosted: Tue May 10, 2016 1:57 pm     Reply with quote

Hi,

Just comment these two lines out:
Code:

setup_ccp1(CCP_PWM|CCP_PULSE_STEERING_A);   // Configure CCP1 as a PWM
set_pwm1_duty(416L);   // Set Duty to %50 (Drives LCD -Ve pump)

These are specific to MY hardware LCD which required a -Ve....
Most modern LCDs do not need this.

G.
_________________
CCS PCM 4.135 & CCS PCH 5.013
LazBoy



Joined: 17 Oct 2006
Posts: 8

View user's profile Send private message

PostPosted: Wed Jun 08, 2016 9:58 am     Reply with quote

Thank you Gabriel for your great driver.

I want to share my FLASH SMS routine based on mentioned driver
as follows:


Code:


void FLASH_SMS(char *GSM_Num,char *SMS_Mes)
{
   counter_read=0;
   printf("AT+CSMP=17,167,0,16\r");    // FLASH SMS Mode
   DELAY(5);
   counter_read=0;
   printf("AT+CMGS=");
   printf(GSM_Num);
   printf("\r");
   DELAY(5); 
   counter_read=0;
   printf("ALARM! condition triggered.\rCheck SMS messages.\r");
   putchar(0x1A); 
   
   while(STRING_SEARCH(OK)==0){}
   
   counter_read=0;
   printf("AT+CSMP=17,167,0,0\r");     // Normal SMS Mode
   DELAY(5); 
   counter_read=0;
   printf("AT+CMGS=");
   printf(GSM_Num);
   printf("\r");
   DELAY(5);       
   counter_read=0;
   printf(SMS_Mes);
   putchar(0x1A);
   DELAY(50);
   
}

Gabriel



Joined: 03 Aug 2009
Posts: 964
Location: Panama

View user's profile Send private message

PostPosted: Wed Jun 08, 2016 11:15 am     Reply with quote

Hey thanks for the addition!
I didn't know they were called flash sms!

I'll surely add this to my bag of tricks!

awesome share man!

G.
_________________
CCS PCM 4.135 & CCS PCH 5.013
samuel



Joined: 04 May 2016
Posts: 14

View user's profile Send private message

interfacing GSM module and Pic
PostPosted: Sun Aug 14, 2016 8:59 am     Reply with quote

Hello!!!
Please creative_35 you said you tested it with SIM900 and it worked. I wish to know how you connected the GSM module to the pic. Was it direct or did you interface it with another IC ?
I am using SIM900A.
Thanks
samuel



Joined: 04 May 2016
Posts: 14

View user's profile Send private message

PostPosted: Mon Sep 05, 2016 7:07 am     Reply with quote

Hello
please i have used this driver with SIM900A GSM module but pic do not communicate with the module.

i am using pic16f877a
this is the link of the module am using

http://www.ebay.com/itm/1PCS-SIM900A-1800-1900-MHz-Wireless-Extension-Module-GSM-GPRS-Board-Antenna-/401085427053?hash=item5d628ded6d:g:VqkAAOSwh-1W4Cgh

i am using the middle pins on the module (5VR and 5VT) but it is not sending any message.

please i need your help
Gabriel



Joined: 03 Aug 2009
Posts: 964
Location: Panama

View user's profile Send private message

PostPosted: Mon Sep 05, 2016 3:55 pm     Reply with quote

how are your connections made?
is your modem TX/RX 5V or 3.3V or RS232

this driver was made with a modem working at 115Kbps, what baud is your modem using?

this driver was tested with a 16F886 which is pretty much the same as the '877A but you need to change one or two things.

are you simulating or using real hardware?

are you sure your connections are right?
are you using an LCD screen? what does it say?
This driver is very verbose and it literally tells you what is wrong, if you have an LCD connected as per PCM_Programmers FLEX_LCD driver.

G.
_________________
CCS PCM 4.135 & CCS PCH 5.013
samuel



Joined: 04 May 2016
Posts: 14

View user's profile Send private message

PostPosted: Tue Sep 06, 2016 4:39 am     Reply with quote

thank you very much for your reply
on that GSM module there are three sets of pins,
3VR and 3VT
5VR and 5VT
GND and VCC_MCU

i am using the pair of 5VR and 5VT
5VR ---->MCU TX
5VT -----> MCU RX
I am implementing it on hardware not simulation.

this is what the LCD screen is showing:
COMMS FAILED
RETRYING - STUCK
Code:

#include <16F877A.h>
#device ADC=8

#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,NODEBUG
//#FUSES NOWDT                    //No Watch Dog Timer
//#FUSES NOBROWNOUT               //No brownout reset
#define LCD_ENABLE_PIN PIN_D3
#define LCD_RS_PIN PIN_D1
#define LCD_RW_PIN PIN_D2
#define LCD_DATA4 PIN_D4
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7

#use delay(crystal=20000000)
#include <lcd.c>
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//#include "servos.c"




#include "string.h"
#include "gsm.c"
//#include "servos.c"
#include "servofunctions.c"




void main()
{
  //init_servos();

int value=5;
   lcd_init();

   lcd_putc("\fReady...\n");
         delay_ms(1000);
       
                           int sms_index=1;
                           //enable_interrupts(int_rb);
                           //ENABLE_INTERRUPTS(GLOBAL);               // Enable Interrupts
                          // ENABLE_INTERRUPTS(INT_RDA);               // Enable Serial Interrupts
                           
                           
                             
                          // lcd_init();                          // Initialize LCD Screen
                       
                       
                        //**************************************************************************
                        // Clears the Comm buffer
                        //**************************************************************************
                           lcd_putc("\fyou are welcome\n");
                           CLEAR_BUFFER();
                           lcd_putc("\fBUFFER CLEARED\n");
                           DELAY(1);                           // Delay a maximum of X seconds
           
               while(1)
               {
           
            //**************************************************************************
            // Check if modem is attached
            //**************************************************************************
                     if(CHECK_COM())
                     {   
                        CLEAR_BUFFER();
                        lcd_putc("\fCOMMS ARE GOOD\n");
                        lcd_putc("\MOVING ON...\n"); 
                        DELAY(1);                     // Delay a maximum of X seconds
                     }
                     else
                     {
                     lcd_putc("\fCOMMS FAILED\n");
                     DELAY(1);                        // Delay a maximum of X seconds
                     while(!CHECK_COM())
                        {
                           lcd_putc("\RETRYING - STUCK IN LOOP\n");
                           DELAY(1);                  // Delay a maximum of X seconds
                        }
                        lcd_putc("\f");
                        lcd_putc("\fCOMMS ARE GOOD\n");
                     }
                     DELAY(1);                        // Delay a maximum of X seconds;
               
               //**************************************************************************
               // Set Modem to TXT mode
               //**************************************************************************
                     lcd_putc("\fSET MODEM TO TXT MODE\n");
                     DELAY(1);                        // Delay a maximum of X seconds
                     if(SET_PDU())
                     {
                        CLEAR_BUFFER();
                        lcd_putc("\OK! - MOVING ON...\n"); 
                        DELAY(1);                     // Delay a maximum of X seconds
                     }
                     else
                     {
                        lcd_putc("\ERROR - STUCK IN LOOP...\n");
                        while(1);
                      }
               
               //**************************************************************************
               // Set Prefered message Storage
               //**************************************************************************
                     lcd_putc("\fSETTING SMS MEMORY\n");
                     DELAY(1);                        // Delay a maximum of X seconds;
                     if(SET_MEM())
                     {
                        CLEAR_BUFFER();
                        lcd_putc("\OK! - MOVING ON...\n"); 
                        DELAY(1);                     // Delay a maximum of X seconds
                     }
                     else
                     {
                        lcd_putc("\ERROR - STUCK IN LOOP...\n");
                        while(1);
                      }
               //**************************************************************************
               // Set SMS Alert Message
               //**************************************************************************
                     lcd_putc("\fSETTING SMS ALERT\n");
                     DELAY(1);                        // Delay a maximum of X seconds;
                     if(SET_CNMI())
                     {
                        CLEAR_BUFFER();
                        lcd_putc("\OK! - MOVING ON...\n"); 
                        DELAY(1);                     // Delay a maximum of X seconds
                     }
                     else
                     {
                        lcd_putc("\ERROR - STUCK IN LOOP...\n");
                        while(1);
                      }
               
               //**************************************************************************
               // WAIT FOR SMS AND READ
               //**************************************************************************
                     lcd_putc("\fMODEM SETUP IS DONE\n");
                     lcd_putc("\CLEARING BUFFER...\n"); 
                     CLEAR_BUFFER();
                     lcd_putc("\DONE ---> RUN PROGRAM\n");
                     DELAY(1);                        // Delay a maximum of X seconds
               
               while(1)
                {
                 int value = 5;
                     lcd_putc("\f");
                     lcd_putc("\fsending message\n");
               
                     CLEAR_BUFFER();
                     SEND_SMS();
                     
                           DELAY(3);               // Delay a maximum of X seconds
                           DEL_SMS(sms_index);     //delete the received sms to create romm for further sms
                           sms_index++;            //
                           CLEAR_BUFFER();
                                                }

               }//--END OF MAIN WHILE

}
Gabriel



Joined: 03 Aug 2009
Posts: 964
Location: Panama

View user's profile Send private message

PostPosted: Tue Sep 06, 2016 9:32 am     Reply with quote

Hi, the LCD display is telling you what the problem is.

Your PIC is not communicating properly with the modem.
the pic is sending the "AT" command and looking for the "OK" response..
its not getting it.

1) check TX/RX connections (try swapping the TX/RX pins)
2) check your modem/PIC baud rate

can you set up a terminal and see what the pic is sending or what the modem is responding by snooping the TX/RX lines?

G.
_________________
CCS PCM 4.135 & CCS PCH 5.013
samuel



Joined: 04 May 2016
Posts: 14

View user's profile Send private message

PostPosted: Wed Sep 07, 2016 1:59 pm     Reply with quote

hello Gabriel!
these are some things i did.
1) i connected the GND of module to GND of pic
2)i simply put the sent function in a while loop without checking communication with the AT command and i could transmit
so it means the problem was as you said, the pic was not receiving an ok so it got stucked.
However though i can't still understand why, I think I am at 30% on the go
the next part which is the receiving i will try it tomorrow in the lab.
thanks!!!
samuel



Joined: 04 May 2016
Posts: 14

View user's profile Send private message

PostPosted: Thu Sep 15, 2016 4:34 am     Reply with quote

thank you very much Gabriel
i was trying to modify the code without first testing yours. after testing the sample code it worked. so i have to continue from there. but i have a worry
when an SMS arrives, it displays SMS RECEIVED however it stays there almost for 3 minutes before coming back to WAITING FOR SMS .
i cannot figure out why.

once more thanks for this powerful GSM driver and code.
xoom



Joined: 18 Nov 2016
Posts: 4

View user's profile Send private message

PostPosted: Fri Nov 18, 2016 8:26 am     Reply with quote

Quote:
while(1)
{
lcd_putc("\f");
lcd_putc("\fWAITING FOR SMS\n");

while(!STRING_SEARCH(CMTI)){}
lcd_putc("\fSMS RECEIVED!!!\n");
CLEAR_BUFFER();
sms_index=1;
while(READ_SMS(sms_index))
{
if(GET_SMS_COMMAND()==AIRE)lcd_putc("\PRENDE AIRE\n");
if(GET_SMS_COMMAND()==LUZ1)lcd_putc("\PRENDE LUZ 1\n");
if(GET_SMS_COMMAND()==LUZ2)
{
lcd_putc("\PRENDE LUZ 2\n");
CLEAR_BUFFER();
SEND_SMS();
}
DELAY(3); // Delay a maximum of X seconds
DEL_SMS(sms_index);
sms_index++;
CLEAR_BUFFER();
}


what sms sentence should i write to activate the SEND_SMS(); sentence above? pls
@Gabriel
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
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