volatile byte _incomingFlag = 0;
void onIncoming () {
_incomingFlag = 1;
Serial.println(F("You got an interrupt"));
mySerial.println("ATH0");
}
void setup () {
/* First Start the module */
Serial.begin(9600);
Serial.println(F("Initializing module..."));
powerOn();
mySerial.begin(9600);
sendcommand(F("AT"), F("OK"), 1000);
sendcommand(F("AT+CLIP=1"), F("OK"), 1000);
sendcommand(F("AT+CMGF=1"), F("OK"), 1000);
/* We need to attach ringing Interrupt */
attachInterrupt(M_RING_INTERRUPT, onIncoming, FALLING);
delay(100);
}
void loop() {
if (_incomingFlag == 1) {
manageIncoming();
Serial.print(F("_incomingFlag: "));
Serial.println(_incomingFlag);
}else {
Serial.println(_incomingFlag);
Serial.println(F("not getting value"));
}
get_currentLocation();
send_Location();
}
void connectTCP(){
Serial.print(F("Memory Free : "));
Serial.println(memoryFree());
sendcommand( F("AT+CIPSHUT"), F("OK"), 5000 );
sendcommand( F("AT+CPIN?"), F("OK"), 1000 );
sendcommand( F("AT+CSQ"), F("OK"), 1000 );
sendcommand( F("AT+CGATT?"), F("OK"), 1000 );
sendcommand( F("AT+CSTT=\"CMNET\""), F("OK"), 10000 );
sendcommand( F("AT+CIICR"), F("OK"), 10000 );
sendcommand( F("AT+CIFSR"), F("OK"), 10000 );
sendcommand( F("AT+CIPSTART=\"TCP\",\"www.myweb.com\",80"), F("OK"), 10000 );
sendcommand( F("AT+CIPSEND"), F(">"), 10000 );
}
void postHTTP(const char* path, const char* data){
int8_t content_length = 0;
mySerial.print(F("POST "));
mySerial.print(path);
mySerial.println(F(" HTTP/1.1"));
mySerial.println(F("Host: www.myweb.com"));
mySerial.println(F("Content-Type: application/x-www-form-urlencoded"));
mySerial.println(F("User-Agent: Arduino"));
mySerial.print(F("Content-Length: "));
content_length = strlen(data);
mySerial.println(content_length);
mySerial.println();
mySerial.print(data);
mySerial.println((char)26);
readline(10000);
sendcommand( F("AT+CIPCLOSE"), F("OK"), 5000 );
}
I am trying to check the value of incomingFlag from the Loop() . When i get a call or an SMS the interrupt function is getting executed and incomingFlag is set to 1 but i am not getting that value from the Loop. Everytime its getting 0 if i check the value while the send_Location function is executing( data uploading part ). How can i access the value of incomingFlag from the main Loop().