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 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 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like