Connecting GSM board with gsm.begin() and status LED on GSM board turning off

I have a GSM shield http://arduino.cc/en/Main/ArduinoGSMShield and Mega 2650 board.

I’m trying to get the GSM shield connected to network, below is my code.

When running the code, the output shows only “Starting Arduino web client.” and “connection attempt”. I suspect that it is stuck at “(gsmAccess.begin(PINNUMBER)==GSM_READY) &
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY)”
or simply the process takes very long.

What I had to do is press the reset button on the board (again and again, for every ~1 min… until the GSM is connected), and at random chances, the GSM board could be connected (with output “connecting…”)
I tried to use while loop with timeout, but it does not work. How shall I fix it? It seems that the while loop has no effect on the gsmAccess.begin() or gprs.attachGPRS…

Another problem is sometimes, the status LED light on the GSM board turns off.
I stacked the GSM board on top of the Mega board, USB powering the Mega board, and also giving 5V electricity to the Vin/GND pin on the GSM board.
If I press the reset button, the status LED turns on again. Actually what is bugging the status LED? and what does the status LED mean? Can I know the status of the LED/ board from program?

Thanks!!

// libraries
#include <GSM.h>

// PIN Number
#define PINNUMBER ""

// APN data
#define GPRS_APN       "myAPN" // replace your GPRS APN
#define GPRS_LOGIN     ""    // replace with your GPRS login
#define GPRS_PASSWORD  "" // replace with your GPRS password

// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess; 
GSMServer servertest(80); // port 80 (http default)


unsigned long myTimeout = 60000; // YOUR LIMIT IN MILLISECONDS
unsigned long timeConnect = millis();

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);

  Serial.println("Starting Arduino web client.");
  // connection state
  boolean notConnected = true;

  // After starting the modem with GSM.begin()
  // attach the shield to the GPRS network with the APN, login and password
  while(notConnected)
  {
    while((millis() - timeConnect) < myTimeout){
      Serial.println("connection attempt");
      if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY)){
        notConnected = false;
        Serial.println("connecting...");
        break;
      }      
      else
      {
        Serial.println("Not connected");
        delay(1000);
      }
    }

    //if GSM is not connected, restart the GSM and connect again, update the timeConnect variable
    if (notConnected){
      gsmAccess.shutdown();
      Serial.println("gsm shutdown");
      timeConnect = millis();
    }
  }

Refer to this: http://forum.arduino.cc/index.php?topic=233137.0

Have you added the jumper as per the Arduino Mega 2560 manual?

hi, please some one solved thise problem ??? , i have the same problem but with arduino uno , i want to send a sms via shield gsm arduino M10 but the programme bug in gsmaccess.begin() and the light statue is turn off please answer me think you :)

What does M10 mean? Could you use some punctuation in your posts so they make sense? And post the code you have already developed?