Adafruit FONA Arduino Library
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Adafruit_FONA Class Reference

#include <Adafruit_FONA.h>

Inheritance diagram for Adafruit_FONA:
Adafruit_FONA_3G

Public Member Functions

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

Static Protected Member Functions

static void onIncomingCall ()
 On incoming call callback.
 

Protected Attributes

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

static bool _incomingCall = false
 Incoming call state var.
 

Detailed Description

Object that controls and keeps state for the FONA module.

Constructor & Destructor Documentation

◆ Adafruit_FONA()

Adafruit_FONA::Adafruit_FONA ( int8_t  rst)

Construct a new Adafruit_FONA object.

Parameters
rstThe reset pin

Member Function Documentation

◆ begin()

bool Adafruit_FONA::begin ( FONAStreamType &  port)

Connect to the cell module.

Parameters
portthe serial connection to use to connect
Returns
bool true on success, false if a connection cannot be made

◆ type()

uint8_t Adafruit_FONA::type ( void  )

Get the module type.

Returns
uint8_t The module type

◆ available()

int Adafruit_FONA::available ( void  )
inline

Serial data available.

Returns
int

◆ write()

size_t Adafruit_FONA::write ( uint8_t  x)
inline

Serial write.

Parameters
x
Returns
size_t

◆ read()

int Adafruit_FONA::read ( void  )
inline

Serial read.

Returns
int

◆ peek()

int Adafruit_FONA::peek ( void  )
inline

Serial peek.

Returns
int

◆ setBaudrate()

bool Adafruit_FONA::setBaudrate ( uint16_t  baud)

Set the baud rate that the module will use.

Parameters
baudThe new baud rate to set
Returns
true: success, false: failure

◆ enableRTC()

bool Adafruit_FONA::enableRTC ( uint8_t  mode)

Enable the Real Time Clock.

Parameters
mode1: Enable 0: Disable
Returns
true: Success , false: failure

◆ readRTC()

bool Adafruit_FONA::readRTC ( uint8_t *  year,
uint8_t *  month,
uint8_t *  day,
uint8_t *  hr,
uint8_t *  min,
uint8_t *  sec 
)

Read the Real Time Clock.

NOTE Currently this function will only fill the 'year' variable

Parameters
yearPointer to a uint8_t to be set with year data
monthPointer to a uint8_t to be set with month data NOT WORKING
dayPointer to a uint8_t to be set with day data NOT WORKING
hrPointer to a uint8_t to be set with hour data NOT WORKING
minPointer to a uint8_t to be set with minute data NOT WORKING
secPointer to a uint8_t to be set with year data NOT WORKING
Returns
true: success, false: failure

◆ getADCVoltage()

bool Adafruit_FONA::getADCVoltage ( uint16_t *  v)

Get the current ADC voltage.

Parameters
vPonter to a uint16_t to set with the ADC voltage
Returns
true: success, false: failure

◆ getBattPercent()

bool Adafruit_FONA::getBattPercent ( uint16_t *  p)

Get the percentage charge of battery as reported by sim800.

Parameters
pPonter to a uint16_t to set with the battery change as a percentage
Returns
true: success, false: failure

◆ getBattVoltage()

bool Adafruit_FONA::getBattVoltage ( uint16_t *  v)

Get the current batery voltage.

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

◆ unlockSIM()

uint8_t Adafruit_FONA::unlockSIM ( char *  pin)

Unlock the sim with a provided PIN.

Parameters
pinPointer to a buffer with the PIN to use to unlock the SIM
Returns
uint8_t

◆ getSIMCCID()

uint8_t Adafruit_FONA::getSIMCCID ( char *  ccid)

Get the SIM CCID.

Parameters
ccidPointer to a buffer to be filled with the CCID
Returns
uint8_t

◆ getNetworkStatus()

uint8_t Adafruit_FONA::getNetworkStatus ( void  )

Gets the current network status.

Returns
uint8_t The nework status:
  • 0: Not registered, MT is not currently searching a new operator to register to
  • 1: Registered, home network
  • 2: Not registered, but MT is currently searching a newoperator to register to
  • 3: Registration denied
  • 4: Unknown
  • 5: Registered, roaming

◆ getRSSI()

uint8_t Adafruit_FONA::getRSSI ( void  )

get the current Received Signal Strength Indication

Returns
uint8_t The current RSSI

◆ getIMEI()

uint8_t Adafruit_FONA::getIMEI ( char *  imei)

Get the IMEI.

Parameters
imeiPointer to a buffer to be filled with the IMEI
Returns
uint8_t

◆ setAudio()

bool Adafruit_FONA::setAudio ( uint8_t  audio_output)

Set the audio ouput.

Parameters
audio_outputThe output to set.
  • 0: headset
  • 1: external audio
Returns
true: success, false: failure

◆ setVolume()

bool Adafruit_FONA::setVolume ( uint8_t  volume_level)

Set the volume.

Parameters
volume_levelThe new volume to set
Returns
true: success, false: failure

◆ getVolume()

uint8_t Adafruit_FONA::getVolume ( void  )

Get the current volume level.

Returns
uint8_t The current volume level

◆ playToolkitTone()

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

Play a toolkit tone.

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

◆ setMicVolume()

bool Adafruit_FONA::setMicVolume ( uint8_t  a,
uint8_t  level 
)

Set the microphone gain.

Parameters
aWhich microphone gain to set.
  • 0: headset
  • 1: external audio
levelThe new gain level
Returns
true: success, false: failure

◆ playDTMF()

bool Adafruit_FONA::playDTMF ( char  dtmf)

Play a DTMF/Key tone.

Parameters
dtmfThe tone to play
Returns
true: success, false: failure

◆ tuneFMradio()

bool Adafruit_FONA::tuneFMradio ( uint16_t  station)

Set the FM Radio station.

Parameters
stationThe station to set the radio to
Returns
true: success, false: failure

◆ FMradio()

bool Adafruit_FONA::FMradio ( bool  onoff,
uint8_t  a = FONA_HEADSETAUDIO 
)

Turn the FM Radio on or off.

Parameters
onofftrue; on false: off
aThe audio source to use:
  • 0: headset
  • 1: external audio
Returns
true: success, false: failure

◆ setFMVolume()

bool Adafruit_FONA::setFMVolume ( uint8_t  i)

Set the FM Radio Volume.

Parameters
iThe volume to set
Returns
true: success, false: failure

◆ getFMVolume()

int8_t Adafruit_FONA::getFMVolume ( void  )

Get the current volume level.

Returns
uint8_t The current volume level

◆ getFMSignalLevel()

int8_t Adafruit_FONA::getFMSignalLevel ( uint16_t  station)

Gets the current FM signal level.

Parameters
stationThe station to chek the signal level of
Returns
int8_t The signal level of the given stations. -1 if FM station is outside allowed range.

◆ setSMSInterrupt()

bool Adafruit_FONA::setSMSInterrupt ( uint8_t  i)

Attach an interrupt for SMS notifications.

Parameters
iThe interrupt to set
Returns
true: success, false: failure

◆ getSMSInterrupt()

uint8_t Adafruit_FONA::getSMSInterrupt ( void  )

Get the current SMS Iterrupt.

Returns
uint8_t The SMS interrupt or 0 on failure

◆ getNumSMS()

int8_t Adafruit_FONA::getNumSMS ( void  )

Get the number of SMS.

Returns
int8_t The SMS count. -1 on error

◆ readSMS()

bool Adafruit_FONA::readSMS ( uint8_t  message_index,
char *  smsbuff,
uint16_t  maxlen,
uint16_t *  readlen 
)

Read an SMS message into a provided buffer.

Parameters
message_indexThe SMS message index to retrieve
smsbuffSMS message buffer
maxlenThe maximum read length
readlenThe length read
Returns
true: success, false: failure

◆ sendSMS()

bool Adafruit_FONA::sendSMS ( char *  smsaddr,
char *  smsmsg 
)

Send an SMS Message from a buffer provided.

Parameters
smsaddrThe SMS address buffer
smsmsgThe SMS message buffer
Returns
true: success, false: failure

◆ deleteSMS()

bool Adafruit_FONA::deleteSMS ( uint8_t  message_index)

Delete an SMS Message.

Parameters
message_indexThe message to delete
Returns
true: success, false: failure

◆ getSMSSender()

bool Adafruit_FONA::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.

Parameters
message_indexThe SMS message index to retrieve the sender for
senderPointer to a buffer to fill with the sender
senderlenThe maximum length to read
Returns
true: a result was successfully retrieved, false: failure

◆ sendUSSD()

bool Adafruit_FONA::sendUSSD ( char *  ussdmsg,
char *  ussdbuff,
uint16_t  maxlen,
uint16_t *  readlen 
)

Send USSD.

Parameters
ussdmsgThe USSD message buffer
ussdbuffThe USSD bufer
maxlenThe maximum read length
readlenThe length actually read
Returns
true: success, false: failure

◆ enableNetworkTimeSync()

bool Adafruit_FONA::enableNetworkTimeSync ( bool  onoff)

Enable network time sync.

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

◆ enableNTPTimeSync()

bool Adafruit_FONA::enableNTPTimeSync ( bool  onoff,
FONAFlashStringPtr  ntpserver = 0 
)

Enable NTP time sync.

Parameters
onofftrue: enable false: disable
ntpserverThe NTP server buffer
Returns
true: success, false: failure

◆ getTime()

bool Adafruit_FONA::getTime ( char *  time_buffer,
uint16_t  maxlen 
)

Get the current time.

Parameters
time_bufferPointer to a buffer to hold the time
maxlenmaximum read length
Returns
true: success, false: failure

◆ enableGPRS()

bool Adafruit_FONA::enableGPRS ( bool  onoff)

Enable GPRS.

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

◆ GPRSstate()

uint8_t Adafruit_FONA::GPRSstate ( void  )

Get the GPRS state.

Returns
uint8_t The GPRS state:
  • 0: Attached
  • 1: Detached

◆ getGSMLoc() [1/2]

bool Adafruit_FONA::getGSMLoc ( uint16_t *  errorcode,
char *  buff,
uint16_t  maxlen 
)

Get GSM location.

Parameters
errorcodePointer to a uint16_t to hold any resulting error code
buffPointer to a buffer to hold the location
maxlenmaximum read length
Returns
true: success, false: failure

◆ getGSMLoc() [2/2]

bool Adafruit_FONA::getGSMLoc ( float *  lat,
float *  lon 
)

Get GSM Location.

Parameters
latPointer to a buffer to hold the latitude
lonPointer to a buffer to hold the longitude
Returns
true: success, false: failure

◆ setGPRSNetworkSettings()

void Adafruit_FONA::setGPRSNetworkSettings ( FONAFlashStringPtr  apn,
FONAFlashStringPtr  username = 0,
FONAFlashStringPtr  password = 0 
)

Set the GPRS network settings.

Parameters
apnPointer to the Access point name buffer
usernamePointer to the Username buffer
passwordPointer to the Password buffer

◆ enableGPS()

bool Adafruit_FONA::enableGPS ( bool  onoff)

Enable GPS.

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

◆ GPSstatus()

int8_t Adafruit_FONA::GPSstatus ( void  )

Get teh GPS status.

Returns
int8_t The GPS status:
  • 0: GPS off 1: No fix 2: 2D fix 3: 3D fix

◆ getGPS() [1/2]

uint8_t Adafruit_FONA::getGPS ( uint8_t  arg,
char *  buffer,
uint8_t  maxbuff 
)

Fill a buffer with the current GPS reading.

Parameters
argThe mode to use, where applicable
bufferThe buffer to be filled with the reading
maxbuffthe maximum amound to write into the buffer
Returns
uint8_t The number of bytes read

◆ getGPS() [2/2]

bool Adafruit_FONA::getGPS ( float *  lat,
float *  lon,
float *  speed_kph = 0,
float *  heading = 0,
float *  altitude = 0 
)

Get a GPS reading.

Parameters
latPointer to a buffer to be filled with thelatitude
lonPointer to a buffer to be filled with the longitude
speed_kphPointer to a buffer to be filled with the speed in kilometers per hour
headingPointer to a buffer to be filled with the heading
altitudePointer to a buffer to be filled with the altitude
Returns
true: success, false: failure

◆ enableGPSNMEA()

bool Adafruit_FONA::enableGPSNMEA ( uint8_t  enable_value)

Enable GPS NMEA output.

Parameters
enable_value
Returns
true: success, false: failure

◆ TCPconnect()

bool Adafruit_FONA::TCPconnect ( char *  server,
uint16_t  port 
)

Start a TCP connection.

Parameters
serverPointer to a buffer with the server to connect to
portPointer to a buffer witht the port to connect to
Returns
true: success, false: failure

◆ TCPclose()

bool Adafruit_FONA::TCPclose ( void  )

Close the TCP connection.

Returns
true: success, false: failure

◆ TCPconnected()

bool Adafruit_FONA::TCPconnected ( void  )

Check the TCP connection status.

Returns
true: success, false: failure

◆ TCPsend()

bool Adafruit_FONA::TCPsend ( char *  data,
uint8_t  len 
)

Send data via TCP.

Parameters
dataPointer to a buffer with the data to send
lenlength of the data to send
Returns
true: success, false: failure

◆ TCPavailable()

uint16_t Adafruit_FONA::TCPavailable ( void  )

Check if TCP bytes are available.

Returns
uint16_t The number of available bytes

◆ TCPread()

uint16_t Adafruit_FONA::TCPread ( uint8_t *  buff,
uint8_t  len 
)

Read from a TCP socket.

Parameters
buffPointer to a buffer to read into
lenThe number of bytes to read
Returns
uint16_t The number of bytes read

◆ HTTP_init()

bool Adafruit_FONA::HTTP_init ( )

Initialize HTTP.

Returns
true: success, false: failure

◆ HTTP_term()

bool Adafruit_FONA::HTTP_term ( )

Terminate HTTP.

Returns
true: success, false: failure

◆ HTTP_para_start()

void Adafruit_FONA::HTTP_para_start ( FONAFlashStringPtr  parameter,
bool  quoted = true 
)

Start sending an HTTP parameter.

Parameters
parameterPointer to a buffer with the parameter to send
quotedtrue if the parameter should be quoted

◆ HTTP_para_end()

bool Adafruit_FONA::HTTP_para_end ( bool  quoted = true)

Finish sending an HTTP parameter.

Parameters
quotedtrue if the parameter should be quoted
Returns
true: success, false: failure

◆ HTTP_para() [1/3]

bool Adafruit_FONA::HTTP_para ( FONAFlashStringPtr  parameter,
const char *  value 
)

Send HTTP parameter.

Parameters
parameterPointer to a buffer with the parameter to send
valuePointer to a buffer with the parameter value
Returns
true: success, false: failure

◆ HTTP_para() [2/3]

bool Adafruit_FONA::HTTP_para ( FONAFlashStringPtr  parameter,
FONAFlashStringPtr  value 
)

Send HTTP parameter.

Parameters
parameterPointer to a buffer with the parameter to send
valuePointer to a buffer with the parameter value
Returns
true: success, false: failure

◆ HTTP_para() [3/3]

bool Adafruit_FONA::HTTP_para ( FONAFlashStringPtr  parameter,
int32_t  value 
)

Send HTTP parameter.

Parameters
parameterPointer to a buffer with the parameter to send
valueThe parameter value
Returns
true: success, false: failure

◆ HTTP_data()

bool Adafruit_FONA::HTTP_data ( uint32_t  size,
uint32_t  maxTime = 10000 
)

Begin sending data via HTTP.

Parameters
sizeThe amount of data to be sent in bytes
maxTimeThe maximum amount of time in which to send the data, in milliseconds
Returns
true: success, false: failure

◆ HTTP_action()

bool Adafruit_FONA::HTTP_action ( uint8_t  method,
uint16_t *  status,
uint16_t *  datalen,
int32_t  timeout = 10000 
)

Make an HTTP Request.

Parameters
methodThe request method:
  • 0: GET
  • 1: POST
  • 2: HEAD
statusPointer to a uint16_t to hold the request status as an RFC2616 HTTP response code: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
datalenPointer to the a uint16_t to hold the length of the data read
timeoutTimeout for waiting for response
Returns
true: success, false: failure

◆ HTTP_readall()

bool Adafruit_FONA::HTTP_readall ( uint16_t *  datalen)

Read all available HTTP data.

Parameters
datalenPointer to the a uint16_t to hold the length of the data read
Returns
true: success, false: failure

◆ HTTP_ssl()

bool Adafruit_FONA::HTTP_ssl ( bool  onoff)

Enable or disable SSL.

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

◆ HTTP_GET_start()

bool Adafruit_FONA::HTTP_GET_start ( char *  url,
uint16_t *  status,
uint16_t *  datalen 
)

Start a HTTP GET request.

Parameters
urlPointer to a buffer with the URL to request
statusPointer to a uint16_t to hold the request status as an RFC2616 HTTP response code: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
datalenPointer to the a uint16_t to hold the length of the data read
Returns
true: success, false: failure

◆ HTTP_POST_start()

bool Adafruit_FONA::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.

Parameters
urlPointer to a buffer with the URL to POST
contenttypeThe message content type
postdataPointer to a buffer with the POST data to be sent
postdatalenThe length of the POST data
statusPointer to a uint16_t to hold the request status as an RFC2616 HTTP response code: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
datalen
Returns
true
false

◆ setUserAgent()

void Adafruit_FONA::setUserAgent ( FONAFlashStringPtr  useragent)

Set the User Agent for HTTP requests.

Parameters
useragentPointer to a buffer with the user agent string to set

◆ setHTTPSRedirect()

void Adafruit_FONA::setHTTPSRedirect ( bool  onoff)

Set the HTTPS redirect flag.

Parameters
onoff

◆ setPWM()

bool Adafruit_FONA::setPWM ( uint16_t  period,
uint8_t  duty = 50 
)

Set the PWM Period and Duty Cycle.

Parameters
periodThe PWM period
dutyThe PWM duty cycle
Returns
true: success, false: failure

◆ callPhone()

bool Adafruit_FONA::callPhone ( char *  number)

Call a phone number.

Parameters
numberPointer to a buffer with the phone number to call
Returns
true: success, false: failure

◆ getCallStatus()

uint8_t Adafruit_FONA::getCallStatus ( void  )

Get the current call status.

Returns
uint8_t The call status:
  • 0: Ready
  • 1: Failure
  • 2: Unknown
  • 3: Ringing
  • 4: Call in progress

◆ hangUp()

bool Adafruit_FONA::hangUp ( void  )

End the current call.

Returns
true: success, false: failure

◆ pickUp()

bool Adafruit_FONA::pickUp ( void  )

Answer a call.

Returns
true: success, false: failure

◆ callerIdNotification()

bool Adafruit_FONA::callerIdNotification ( bool  enable,
uint8_t  interrupt = 0 
)

Enable or disable caller ID.

Parameters
enabletrue to enable, false to disable
interruptAn optional interrupt to attach
Returns
true: success, false: failure

◆ incomingCallNumber()

bool Adafruit_FONA::incomingCallNumber ( char *  phonenum)

Get the number of the incoming call.

Parameters
phonenumPointer to a buffer to hold the incoming caller's phone number
Returns
true: success, false: failure

◆ expectReply()

bool Adafruit_FONA::expectReply ( FONAFlashStringPtr  reply,
uint16_t  timeout = 10000 
)

Check if the received reply matches the expectation.

Parameters
replyThe expected reply
timeoutRead timeout
Returns
true: success, false: failure

◆ sendCheckReply() [1/6]

bool Adafruit_FONA::sendCheckReply ( char *  send,
char *  reply,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)

Send data and verify the response matches an expected response.

Parameters
sendPointer to the buffer of data to send
replyBuffer with the expected reply
timeoutRead timeout
Returns
true: success, false: failure

◆ sendCheckReply() [2/6]

bool Adafruit_FONA::sendCheckReply ( FONAFlashStringPtr  send,
FONAFlashStringPtr  reply,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)

Send data and verify the response matches an expected response.

Parameters
sendPointer to the buffer of data to send
replyPointer to a buffer with the expected reply
timeoutRead timeout
Returns
true: success, false: failure

◆ sendCheckReply() [3/6]

bool Adafruit_FONA::sendCheckReply ( char *  send,
FONAFlashStringPtr  reply,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)

Send data and verify the response matches an expected response.

Parameters
sendPointer to the buffer of data to send
replyPointer to a buffer with the expected reply
timeoutRead timeout
Returns
true: success, false: failure

◆ HTTP_setup()

bool Adafruit_FONA::HTTP_setup ( char *  url)
protected

Configure an HTTP request.

Parameters
urlPointer to a buffer with the URL to POST
Returns
true: success, false: failure

◆ readRaw()

uint16_t Adafruit_FONA::readRaw ( uint16_t  read_length)
protected

Read directly into the reply buffer.

Parameters
read_lengthThe number of bytes to return
Returns
uint16_t The number of bytes read

◆ readline()

uint8_t Adafruit_FONA::readline ( uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS,
bool  multiline = false 
)
protected

Read a single line or up to 254 bytes.

Parameters
timeoutReply timeout
multilinetrue: read the maximum amount. false: read up to the second newline
Returns
uint8_t the number of bytes read

◆ getReply() [1/5]

uint8_t Adafruit_FONA::getReply ( char *  send,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)
protected

Send a command and return the reply.

Parameters
sendThe char* command to send
timeoutTimeout for reading a response
Returns
uint8_t The response length

◆ getReply() [2/5]

uint8_t Adafruit_FONA::getReply ( FONAFlashStringPtr  send,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)
protected

Send a command and return the reply.

Parameters
sendThe FONAFlashStringPtr command to send
timeoutTimeout for reading a response
Returns
uint8_t The response length

◆ getReply() [3/5]

uint8_t Adafruit_FONA::getReply ( FONAFlashStringPtr  prefix,
char *  suffix,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)
protected

Send a command as prefix and suffix.

Parameters
prefixPointer to a buffer with the command prefix
suffixPointer to a buffer with the command suffix
timeoutTimeout for reading a response
Returns
uint8_t The response length

◆ getReply() [4/5]

uint8_t Adafruit_FONA::getReply ( FONAFlashStringPtr  prefix,
int32_t  suffix,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)
protected

Send a command with.

Parameters
prefixPointer to a buffer with the command prefix
suffixThe command suffix
timeoutTimeout for reading a response
Returns
uint8_t The response length

◆ getReply() [5/5]

uint8_t Adafruit_FONA::getReply ( FONAFlashStringPtr  prefix,
int32_t  suffix1,
int32_t  suffix2,
uint16_t  timeout 
)
protected

Send command with prefix and two suffixes.

Parameters
prefixPointer to a buffer with the command prefix
suffix1The comannd first suffix
suffix2The command second suffix
timeoutTimeout for reading a response
Returns
uint8_t The response length

◆ getReplyQuoted()

uint8_t Adafruit_FONA::getReplyQuoted ( FONAFlashStringPtr  prefix,
FONAFlashStringPtr  suffix,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)
protected

Send command prefix and suffix, returning the response length.

Parameters
prefixPointer to a buffer with the command prefix
suffixPointer to a buffer with the command suffix
timeoutTimeout for reading a response
Returns
uint8_t The response length

◆ sendCheckReply() [4/6]

bool Adafruit_FONA::sendCheckReply ( FONAFlashStringPtr  prefix,
char *  suffix,
FONAFlashStringPtr  reply,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)
protected

Send data and verify the response matches an expected response.

Parameters
prefixPointer to a buffer with the prefix send
suffixPointer to a buffer with the suffix send
replyPointer to a buffer with the expected reply
timeoutRead timeout
Returns
true: success, false: failure

◆ sendCheckReply() [5/6]

bool Adafruit_FONA::sendCheckReply ( FONAFlashStringPtr  prefix,
int32_t  suffix,
FONAFlashStringPtr  reply,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)
protected

Send data and verify the response matches an expected response.

Parameters
prefixPointer to a buffer with the prefix to send
suffixThe suffix to send
replyPointer to a buffer with the expected reply
timeoutRead timeout
Returns
true: success, false: failure

◆ sendCheckReply() [6/6]

bool Adafruit_FONA::sendCheckReply ( FONAFlashStringPtr  prefix,
int32_t  suffix1,
int32_t  suffix2,
FONAFlashStringPtr  reply,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)
protected

Send data and verify the response matches an expected response.

Parameters
prefixPonter to a buffer with the prefix to send
suffix1The first suffix to send
suffix2The second suffix to send
replyPointer to a buffer with the expected reply
timeoutRead timeout
Returns
true: success, false: failure

◆ sendCheckReplyQuoted()

bool Adafruit_FONA::sendCheckReplyQuoted ( FONAFlashStringPtr  prefix,
FONAFlashStringPtr  suffix,
FONAFlashStringPtr  reply,
uint16_t  timeout = FONA_DEFAULT_TIMEOUT_MS 
)
protected

Send data and verify the response matches an expected response.

Parameters
prefixPointer to a buffer with the prefix to send
suffixPointer to a buffer with the suffix to send
replyPointer to a buffer with the expected response
timeoutRead timeout
Returns
true: success, false: failure

◆ parseReply() [1/2]

bool Adafruit_FONA::parseReply ( FONAFlashStringPtr  toreply,
uint16_t *  v,
char  divider = ',',
uint8_t  index = 0 
)
protected

Parse a string in the response fields using a designated separator and copy the value at the specified index in to the supplied buffer.

Parameters
toreplyPointer to a buffer with reply with the field being parsed
vPointer to a buffer to fill with the the value from the parsed field
dividerThe divider character
indexThe index of the parsed field to retrieve
Returns
true: success, false: failure

◆ parseReply() [2/2]

bool Adafruit_FONA::parseReply ( FONAFlashStringPtr  toreply,
char *  v,
char  divider = ',',
uint8_t  index = 0 
)
protected

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.

Parameters
toreplyPointer to a buffer with reply with the field being parsed
vPointer to a buffer to fill with the string
dividerThe divider character
indexThe index of the parsed field to retrieve
Returns
true: success, false: failure

◆ parseReplyQuoted()

bool Adafruit_FONA::parseReplyQuoted ( FONAFlashStringPtr  toreply,
char *  v,
int  maxlen,
char  divider,
uint8_t  index 
)
protected

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.

Parameters
toreplyPointer to a buffer with reply with the field being parsed
vPointer to a buffer to fill with the string. Make sure to supply a buffer large enough to retrieve the expected value
maxlenThe maximum read length
dividerThe divider character
indexThe index of the parsed field to retrieve
Returns
true: success, false: failure

◆ sendParseReply()

bool Adafruit_FONA::sendParseReply ( FONAFlashStringPtr  tosend,
FONAFlashStringPtr  toreply,
uint16_t *  v,
char  divider = ',',
uint8_t  index = 0 
)
protected

Send data and parse the reply.

Parameters
tosendPointer to the data buffer to send
toreplyPointer to a buffer with the expected reply string
vPointer to a uint16_t buffer to hold the value of the parsed response
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: