Adafruit FONA Arduino Library
Public Member Functions | Protected Member Functions | List of all members
Adafruit_FONA_3G Class Reference

#include <Adafruit_FONA.h>

Inheritance diagram for Adafruit_FONA_3G:
Adafruit_FONA

Public Member Functions

 Adafruit_FONA_3G (int8_t reset_pin)
 Construct a new Adafruit_FONA_3G object. More...
 
bool getBattVoltage (uint16_t *v)
 Get the current batery voltage. More...
 
bool playToolkitTone (uint8_t t, uint16_t len)
 Play a toolkit tone. More...
 
bool hangUp (void)
 End the current call. More...
 
bool pickUp (void)
 Answer an incoming call. More...
 
bool enableGPRS (bool onoff)
 Enable GPRS. More...
 
bool enableGPS (bool onoff)
 Enable GPS. More...
 
- Public Member Functions inherited from Adafruit_FONA
 Adafruit_FONA (int8_t r)
 Construct a new Adafruit_FONA object. More...
 
bool begin (FONAStreamType &port)
 Connect to the cell module. More...
 
uint8_t type ()
 Get the module type. More...
 
int available (void)
 Serial data available. More...
 
size_t write (uint8_t x)
 Serial write. More...
 
int read (void)
 Serial read. More...
 
int peek (void)
 Serial peek. More...
 
void flush ()
 Flush the serial data.
 
bool setBaudrate (uint16_t baud)
 Set the baud rate that the module will use. More...
 
bool enableRTC (uint8_t mode)
 Enable the Real Time Clock. More...
 
bool readRTC (uint8_t *year, uint8_t *month, uint8_t *day, uint8_t *hr, uint8_t *min, uint8_t *sec)
 Read the Real Time Clock. More...
 
bool getADCVoltage (uint16_t *v)
 Get the current ADC voltage. More...
 
bool getBattPercent (uint16_t *p)
 Get the percentage charge of battery as reported by sim800. More...
 
bool getBattVoltage (uint16_t *v)
 Get the current batery voltage. More...
 
uint8_t unlockSIM (char *pin)
 Unlock the sim with a provided PIN. More...
 
uint8_t getSIMCCID (char *ccid)
 Get the SIM CCID. More...
 
uint8_t getNetworkStatus (void)
 Gets the current network status. More...
 
uint8_t getRSSI (void)
 get the current Received Signal Strength Indication More...
 
uint8_t getIMEI (char *imei)
 Get the IMEI. More...
 
bool setAudio (uint8_t audio_output)
 Set the audio ouput. More...
 
bool setVolume (uint8_t volume_level)
 Set the volume. More...
 
uint8_t getVolume (void)
 Get the current volume level. More...
 
bool playToolkitTone (uint8_t t, uint16_t len)
 Play a toolkit tone. More...
 
bool setMicVolume (uint8_t a, uint8_t level)
 Set the microphone gain. More...
 
bool playDTMF (char tone)
 Play a DTMF/Key tone. More...
 
bool tuneFMradio (uint16_t station)
 Set the FM Radio station. More...
 
bool FMradio (bool onoff, uint8_t a=FONA_HEADSETAUDIO)
 Turn the FM Radio on or off. More...
 
bool setFMVolume (uint8_t i)
 Set the FM Radio Volume. More...
 
int8_t getFMVolume (void)
 Get the current volume level. More...
 
int8_t getFMSignalLevel (uint16_t station)
 Gets the current FM signal level. More...
 
bool setSMSInterrupt (uint8_t i)
 Attach an interrupt for SMS notifications. More...
 
uint8_t getSMSInterrupt (void)
 Get the current SMS Iterrupt. More...
 
int8_t getNumSMS (void)
 Get the number of SMS. More...
 
bool readSMS (uint8_t message_index, char *smsbuff, uint16_t max, uint16_t *readsize)
 Read an SMS message into a provided buffer. More...
 
bool sendSMS (char *smsaddr, char *smsmsg)
 Send an SMS Message from a buffer provided. More...
 
bool deleteSMS (uint8_t message_index)
 Delete an SMS Message. More...
 
bool getSMSSender (uint8_t message_index, char *sender, int senderlen)
 Retrieve the sender of the specified SMS message and copy it as a string to the sender buffer. Up to senderlen characters of the sender will be copied and a null terminator will be added if less than senderlen characters are copied to the result. More...
 
bool sendUSSD (char *ussdmsg, char *ussdbuff, uint16_t maxlen, uint16_t *readlen)
 Send USSD. More...
 
bool enableNetworkTimeSync (bool onoff)
 Enable network time sync. More...
 
bool enableNTPTimeSync (bool onoff, FONAFlashStringPtr ntpserver=0)
 Enable NTP time sync. More...
 
bool getTime (char *time_buffer, uint16_t maxlen)
 Get the current time. More...
 
bool enableGPRS (bool onoff)
 Enable GPRS. More...
 
uint8_t GPRSstate (void)
 Get the GPRS state. More...
 
bool getGSMLoc (uint16_t *replycode, char *buff, uint16_t maxlen)
 Get GSM location. More...
 
bool getGSMLoc (float *lat, float *lon)
 Get GSM Location. More...
 
void setGPRSNetworkSettings (FONAFlashStringPtr apn, FONAFlashStringPtr username=0, FONAFlashStringPtr password=0)
 Set the GPRS network settings. More...
 
bool enableGPS (bool onoff)
 Enable GPS. More...
 
int8_t GPSstatus (void)
 Get teh GPS status. More...
 
uint8_t getGPS (uint8_t arg, char *buffer, uint8_t maxbuff)
 Fill a buffer with the current GPS reading. More...
 
bool getGPS (float *lat, float *lon, float *speed_kph=0, float *heading=0, float *altitude=0)
 Get a GPS reading. More...
 
bool enableGPSNMEA (uint8_t enable_value)
 Enable GPS NMEA output. More...
 
bool TCPconnect (char *server, uint16_t port)
 Start a TCP connection. More...
 
bool TCPclose (void)
 Close the TCP connection. More...
 
bool TCPconnected (void)
 Check the TCP connection status. More...
 
bool TCPsend (char *data, uint8_t len)
 Send data via TCP. More...
 
uint16_t TCPavailable (void)
 Check if TCP bytes are available. More...
 
uint16_t TCPread (uint8_t *buff, uint8_t len)
 Read from a TCP socket. More...
 
bool HTTP_init ()
 Initialize HTTP. More...
 
bool HTTP_term ()
 Terminate HTTP. More...
 
void HTTP_para_start (FONAFlashStringPtr parameter, bool quoted=true)
 Start sending an HTTP parameter. More...
 
bool HTTP_para_end (bool quoted=true)
 Finish sending an HTTP parameter. More...
 
bool HTTP_para (FONAFlashStringPtr parameter, const char *value)
 Send HTTP parameter. More...
 
bool HTTP_para (FONAFlashStringPtr parameter, FONAFlashStringPtr value)
 Send HTTP parameter. More...
 
bool HTTP_para (FONAFlashStringPtr parameter, int32_t value)
 Send HTTP parameter. More...
 
bool HTTP_data (uint32_t size, uint32_t maxTime=10000)
 Begin sending data via HTTP. More...
 
bool HTTP_action (uint8_t method, uint16_t *status, uint16_t *datalen, int32_t timeout=10000)
 Make an HTTP Request. More...
 
bool HTTP_readall (uint16_t *datalen)
 Read all available HTTP data. More...
 
bool HTTP_ssl (bool onoff)
 Enable or disable SSL. More...
 
bool HTTP_GET_start (char *url, uint16_t *status, uint16_t *datalen)
 Start a HTTP GET request. More...
 
void HTTP_GET_end (void)
 End an HTTP GET.
 
bool HTTP_POST_start (char *url, FONAFlashStringPtr contenttype, const uint8_t *postdata, uint16_t postdatalen, uint16_t *status, uint16_t *datalen)
 Start an HTTP POST request. More...
 
void HTTP_POST_end (void)
 End an HTTP POST request.
 
void setUserAgent (FONAFlashStringPtr useragent)
 Set the User Agent for HTTP requests. More...
 
void setHTTPSRedirect (bool onoff)
 Set the HTTPS redirect flag. More...
 
bool setPWM (uint16_t period, uint8_t duty=50)
 Set the PWM Period and Duty Cycle. More...
 
bool callPhone (char *phonenum)
 Call a phone number. More...
 
uint8_t getCallStatus (void)
 Get the current call status. More...
 
bool hangUp (void)
 End the current call. More...
 
bool pickUp (void)
 Answer a call. More...
 
bool callerIdNotification (bool enable, uint8_t interrupt=0)
 Enable or disable caller ID. More...
 
bool incomingCallNumber (char *phonenum)
 Get the number of the incoming call. More...
 
bool expectReply (FONAFlashStringPtr reply, uint16_t timeout=10000)
 Check if the received reply matches the expectation. More...
 
bool sendCheckReply (char *send, char *reply, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send data and verify the response matches an expected response. More...
 
bool sendCheckReply (FONAFlashStringPtr send, FONAFlashStringPtr reply, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send data and verify the response matches an expected response. More...
 
bool sendCheckReply (char *send, FONAFlashStringPtr reply, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send data and verify the response matches an expected response. More...
 

Protected Member Functions

bool parseReply (FONAFlashStringPtr toreply, float *f, char divider, uint8_t index)
 Parse a reply. More...
 
bool sendParseReply (FONAFlashStringPtr tosend, FONAFlashStringPtr toreply, float *f, char divider=',', uint8_t index=0)
 Send data and parse the reply. More...
 
- Protected Member Functions inherited from Adafruit_FONA
bool HTTP_setup (char *url)
 Configure an HTTP request. More...
 
void flushInput ()
 Read all available serial input to flush pending data.
 
uint16_t readRaw (uint16_t read_length)
 Read directly into the reply buffer. More...
 
uint8_t readline (uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS, bool multiline=false)
 Read a single line or up to 254 bytes. More...
 
uint8_t getReply (char *send, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send a command and return the reply. More...
 
uint8_t getReply (FONAFlashStringPtr send, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send a command and return the reply. More...
 
uint8_t getReply (FONAFlashStringPtr prefix, char *suffix, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send a command as prefix and suffix. More...
 
uint8_t getReply (FONAFlashStringPtr prefix, int32_t suffix, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send a command with. More...
 
uint8_t getReply (FONAFlashStringPtr prefix, int32_t suffix1, int32_t suffix2, uint16_t timeout)
 Send command with prefix and two suffixes. More...
 
uint8_t getReplyQuoted (FONAFlashStringPtr prefix, FONAFlashStringPtr suffix, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send command prefix and suffix, returning the response length. More...
 
bool sendCheckReply (FONAFlashStringPtr prefix, char *suffix, FONAFlashStringPtr reply, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send data and verify the response matches an expected response. More...
 
bool sendCheckReply (FONAFlashStringPtr prefix, int32_t suffix, FONAFlashStringPtr reply, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send data and verify the response matches an expected response. More...
 
bool sendCheckReply (FONAFlashStringPtr prefix, int32_t suffix, int32_t suffix2, FONAFlashStringPtr reply, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send data and verify the response matches an expected response. More...
 
bool sendCheckReplyQuoted (FONAFlashStringPtr prefix, FONAFlashStringPtr suffix, FONAFlashStringPtr reply, uint16_t timeout=FONA_DEFAULT_TIMEOUT_MS)
 Send data and verify the response matches an expected response. More...
 
bool parseReply (FONAFlashStringPtr toreply, uint16_t *v, char divider=',', uint8_t index=0)
 Parse a string in the response fields using a designated separator and copy the value at the specified index in to the supplied buffer. More...
 
bool parseReply (FONAFlashStringPtr toreply, char *v, char divider=',', uint8_t index=0)
 Parse a string in the response fields using a designated separator and copy the string at the specified index in to the supplied char buffer. More...
 
bool parseReplyQuoted (FONAFlashStringPtr toreply, char *v, int maxlen, char divider, uint8_t index)
 Parse a string in the response fields using a designated separator and copy the string (without quotes) at the specified index in to the supplied char buffer. More...
 
bool sendParseReply (FONAFlashStringPtr tosend, FONAFlashStringPtr toreply, uint16_t *v, char divider=',', uint8_t index=0)
 Send data and parse the reply. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from Adafruit_FONA
static void onIncomingCall ()
 On incoming call callback.
 
- Protected Attributes inherited from Adafruit_FONA
int8_t _rstpin
 Reset pin.
 
uint8_t _type
 Module type.
 
char replybuffer [255]
 buffer for holding replies from the module
 
FONAFlashStringPtr apn
 Access point name.
 
FONAFlashStringPtr apnusername
 Access point username.
 
FONAFlashStringPtr apnpassword
 Access point password.
 
bool httpsredirect
 HTTPS redirect state.
 
FONAFlashStringPtr useragent
 User agent used when making requests.
 
FONAFlashStringPtr ok_reply
 OK reply for successful requests.
 
FONAStreamType * mySerial
 Serial connection.
 
- Static Protected Attributes inherited from Adafruit_FONA
static bool _incomingCall = false
 Incoming call state var.
 

Detailed Description

Object that controls and keeps state for a 3G FONA module.

Constructor & Destructor Documentation

◆ Adafruit_FONA_3G()

Adafruit_FONA_3G::Adafruit_FONA_3G ( int8_t  reset_pin)
inline

Construct a new Adafruit_FONA_3G object.

Parameters
reset_pin

Member Function Documentation

◆ getBattVoltage()

bool Adafruit_FONA_3G::getBattVoltage ( uint16_t *  v)

Get the current batery voltage.

Parameters
vbattery voltage pointer to be filled with the current value in mV (uint16_t)
Returns
true: success, false: failure

◆ playToolkitTone()

bool Adafruit_FONA_3G::playToolkitTone ( uint8_t  t,
uint16_t  len 
)

Play a toolkit tone.

Parameters
tThe tone to play
lenThe tone length
Returns
true: success, false: failure

◆ hangUp()

bool Adafruit_FONA_3G::hangUp ( void  )

End the current call.

Returns
true: success, false: failure

◆ pickUp()

bool Adafruit_FONA_3G::pickUp ( void  )

Answer an incoming call.

Returns
true: success, false: failure

◆ enableGPRS()

bool Adafruit_FONA_3G::enableGPRS ( bool  onoff)

Enable GPRS.

Parameters
onofftrue: enable false; disable
Returns
true: success, false: failure

◆ enableGPS()

bool Adafruit_FONA_3G::enableGPS ( bool  onoff)

Enable GPS.

Parameters
onofftrue: enable false: disable
Returns
true: success, false: failure

◆ parseReply()

bool Adafruit_FONA_3G::parseReply ( FONAFlashStringPtr  toreply,
float *  f,
char  divider,
uint8_t  index 
)
protected

Parse a reply.

Parameters
toreplyPointer to a buffer with the expected reply string
fPointer to a float buffer to hold the value of the parsed field
dividerThe divider character
indexThe index of the parsed field to retrieve
Returns
true: success, false: failure

◆ sendParseReply()

bool Adafruit_FONA_3G::sendParseReply ( FONAFlashStringPtr  tosend,
FONAFlashStringPtr  toreply,
float *  f,
char  divider = ',',
uint8_t  index = 0 
)
protected

Send data and parse the reply.

Parameters
tosendPointer to he data buffer to send
toreplyThe expected reply string
fPointer to a float buffer to hold value of the parsed field
dividerThe divider character
indexThe index of the parsed field to retrieve
Returns
true: success, false: failure

The documentation for this class was generated from the following files: