Gas sensor with SMS led control

Hey there,
I am just trying out the sms relay control coding along with gas sensor detection. I seem to be facing a bit of a problem though. When I remove the coding related to the gas sensor the led works fine. There is no response when I use the below coding. Some where I am going wrong?(using an arduino uno)

#include <SoftwareSerial.h>

int gasPin=12;
int gasState = 0;
// EN: String buffer for the GPRS shield message
String msg = String("");
// EN: Set to 1 when the next GPRS shield message will contains the SMS message
int SmsContentFlag = 0;
//control pins of relay.

// EN: Code PIN of the SIM card (if applied)
//String SIM_PIN_CODE = String( "XXXX" );

void setup()
{
Serial.begin(9600);
// the GPRS baud rate
// Initialize PINs
pinMode( 13, OUTPUT );

digitalWrite( 13, LOW );

Serial.println( "AT+CMGF=1" );
delay(200);
}

void loop()
{
char SerialInByte;
void gas();
delay(8000);
if(Serial.available())
{
SerialInByte = (unsigned char)Serial.read();
delay(5);

// -------------------------------------------------------------------
// EN: Program also listen to the GPRS shield message.
// -------------------------------------------------------------------
// EN: If the message ends with then process the message
if( SerialInByte == 13 ){
// EN: Store the char into the message buffer
ProcessGprsMsg();
}
if( SerialInByte == 10 ){
// EN: Skip Line feed
}
else {
// EN: store the current character in the message string buffer
msg += String(SerialInByte);
}
}
}
void gas()
{
gasState = digitalRead(gasPin);
if(gasState == HIGH)
{
//Baud rate of the GSM/GPRS Module
Serial.print("\r");
delay(1000);
Serial.print("AT+CMGF=1\r");
delay(1000);
Serial.print("AT+CMGS="+919884499852"\r"); //Number to which you want to send the sms
delay(1000);
Serial.print("gas leak\r"); //The text of the message to be sent
delay(1000);
Serial.write(0x1A);
delay(1000);
return;
}
}
// EN: Make action based on the content of the SMS.
// Notice than SMS content is the result of the processing of several GPRS shield messages.
void ProcessSms( String sms ){

if( sms.indexOf("ona") >= 0 ){
digitalWrite( 13, HIGH );
}
if( sms.indexOf("offa") >= 0 ){
digitalWrite( 13, LOW );
}

}
// EN: Request Text Mode for SMS messaging
void GprsTextModeSMS(){
Serial.println( "AT+CMGF=1" );
}

void GprsReadSmsStore( String SmsStorePos ){
Serial.print( "AT+CMGR=" );
Serial.println( SmsStorePos );
}

// EN: Clear the GPRS shield message buffer
void ClearGprsMsg(){
msg = "";
}

// EN: interpret the GPRS shield message and act appropiately
void ProcessGprsMsg() {
if( msg.indexOf( "Call Ready" ) >= 0 ){
// Serial.println( "*** GPRS Shield registered on Mobile Network ***" );
GprsTextModeSMS();
}

// EN: unsolicited message received when getting a SMS message
if( msg.indexOf( "+CMTI" ) >= 0 ){
// Serial.println( "*** SMS Received ***" );
// EN: Look for the coma in the full message (+CMTI: "SM",6)
// In the sample, the SMS is stored at position 6
int iPos = msg.indexOf( "," );
String SmsStorePos = msg.substring( iPos+1 );
// Serial.print( "SMS stored at " );
// Serial.println( SmsStorePos );
// EN: Ask to read the SMS store
GprsReadSmsStore( SmsStorePos );
}

// EN: SMS store readed through UART (result of GprsReadSmsStore request)
if( msg.indexOf( "+CMGR:" ) >= 0 ){
// EN: Next message will contains the BODY of SMS
SmsContentFlag = 1;
// EN: Following lines are essentiel to not clear the flag!
ClearGprsMsg();
return;
}

// EN: +CMGR message just before indicate that the following GRPS Shield message
// (this message) will contains the SMS body
if( SmsContentFlag == 1 ){
// Serial.println( "*** SMS MESSAGE CONTENT " );
// Serial.println( msg );
// Serial.println( "
END OF SMS MESSAGE ***" );
ProcessSms( msg );
}

ClearGprsMsg();
// EN: Always clear the flag
SmsContentFlag = 0;
}

    void gas();

Why do you have a function prototype in loop()? This is NOT calling the function.

Oops, I initially declared the function inside the loop, must have forgotten to make the changes. :stuck_out_tongue: thanx for spotting that. But anyway why isn't the led responding to "ona" and "offa" command when I send the sms?

This very same code worked perfectly fine before I included the sensor part.