pic+gsm
Newbie level 4
- Joined
- Nov 24, 2012
- Messages
- 7
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,324
Can someone help me pleas I am not sure how I can receive a text message from the GSM such as LED1ON and switch an LED1 on I have tried few ways but I can’t make it work
Code:
void readtheUSART(char *recbuffer)
{
unsigned char recivedata;
do
{
recivedata = ReadUSART();
*recbuffer++ = recivedata;
}
while (recivedata != '\n');
}
/////////////////////////////////////////////
// in my main
////////////////////////////////////////////
char readmessage[10];
char readnewline[50];
char message_index;
// Set Text Mode
Comm("AT+CMGF=1\r\n");
delay(300);
// Read last SMS
delay(300);
for (aa= 0; aa<13; aa++) // recv2 = AT+CMGR=1\r\n;
{
if (recv2[aa] == 0)
break;
WriteUSART(recv2[aa]);
while ( BusyUSART() );
}
// Read +CMGL: <index>,<status>,<from_address>,<mr>,<scts>
readtheUSART(readnewline);
// Read message led1on, led1off
readtheUSART(readmessage);
// Read newline
readtheUSART(readnewline);
// Read message and return the value back
if(memcmp("LED1ON", &readmessage, 6) == 0) {
led1 = 1;
} else if(memcmp("LED1OFF", &readmessage, 7) == 0) {
led1 = 0;
}
// Delete last message
delay(300);
for (aa= 0; aa<13; aa++) // recv3 = AT+CMGD=1\r\n
{
if (recv3[aa] == 0)
break;
WriteUSART(recv3[aa]);
while ( BusyUSART() );
}