carrascoacd / ArduinoSIM800L

Arduino HTTP & FTP client for SIM800L/SIM800 boards to perform GET and POST requests to a JSON API as well as FTP uploads.
159 stars 58 forks source link

gsm #23

Closed farsajik closed 5 years ago

farsajik commented 5 years ago

hi friend.thank you for your library.i have one problem.if sim800 out of covarage of the gsm network it stucks in the while loop.and it never exits from endles while loop and all my another programs stops.can you help me.is there any method firstly check is the module connected to gsm network? please add cheking registration on the network AT+CREG? this example from seedstudio library

bool GPRS::isNetworkRegistered(void)
{
    char gprsBuffer[32];
    int count = 0;
    sim900_clean_buffer(gprsBuffer,32);
    while(count < 3) {
        sim900_send_cmd(F("AT+CREG?\r\n"));
        sim900_read_buffer(gprsBuffer,32,DEFAULT_TIMEOUT);
        //Check if home network (0,1) ir roaming (0,5) is enabled
        if( (NULL != strstr(gprsBuffer,"+CREG: 0,1")) || (NULL != strstr(gprsBuffer,"+CREG: 0,5")) ) {
            break;
        }
        count++;
        delay(300);
    }
    if(count == 3) {
        return false;
    }
    return true;
}

and how can i send personal AT commands from my sketchs and read response? thanks

carrascoacd commented 5 years ago

You can use this to check if there is connection: sendCmdAndWaitForResp(REGISTRATION_STATUS, CONNECTED, 2000) == TRUE

An this to send custom messages: sendCmdAndWaitForResp

Look into Http.cpp for more examples