What Does gsmAccess() Function Do (Gsm. H and Arduino)
I Have a Module Which Connects and Sends Ussd Through Arduino+Gsm Shield. I Am Kind of Fuzzy on the Following Two Commands Which Are Commented with? ?. (Line 4...
I have a module which connects and sends ussd through arduino+GSM shield. I am kind of fuzzy on the following two commands which are commented with ??. (line 4 and line 7).
Can someone explain what these two do?
And plus gsmAccess.getStatus() == 3; what are the other values that this function can return apart from 3?
#include <GSM.h>
#include <GSM3ShieldV1DirectModemProvider.h>
GSM3ShieldV1DirectModemProvider modemAccess;
GSM gsmAccess(true); // ??
void sendCommand(String com){ // com is "AT+CUSD=1,\"#366#\",\0"
if(gsmAccess.getStatus() == 3) // ??
Serial.println(modemAccess.writeModemCommand(com,comDelay));
else{
connectModule();
sendCommand(com);
}
}
1 Answer
The line:
GSM gsmAccess(true);
initializes the GSM library to enable an Arduino to act as though it were a mobile (cell) phone. The true parameter puts the library into debug mode which will print out all the AT commands from the modem (reference).
The line:
if (gsmAccess.getStatus() == 3)
is checking that the GSM library is ready to send commands. The 3 is the code for GSM_READY as defined in the source code
For clarity it would be better to write this line as:
if (gsmAccess.getStatus() == GSM_READY)
The other statuses (defined in the same source file) are:
0: ERROR
1: IDLE
2: CONNECTING
3: GSM_READY
4: GPRS_READY
5: TRANSPARENT_CONNECTED
6: OFF