Library for Adafruit FONA breakout board
Adafruit_FONA Class Reference
Adafruit FONA 800H Class Modified by George Tzintzarov & Jesse Baker 03/14/2016 for use in mbed LPC1768. More...
#include <Adafruit_FONA.h>
Data Structures | |
class | EventListener |
Listener for FONA events. More... | |
Public Member Functions | |
Adafruit_FONA (PinName tx, PinName rx, PinName rst, PinName ringIndicator) | |
Create instance of the Adafruit_FONA. | |
bool | begin (int baudrate) |
Built-in Test to see if FONA is connected. | |
void | setEventListener (EventListener *eventListener) |
Set the event listener for incoming calls. | |
int | readable (void) |
Check if FONA has anything in its output buffer. | |
bool | getADCVoltage (uint16_t *v) |
Get ADC voltage from external pin. | |
bool | getBattPercent (uint16_t *p) |
Get battery percentage level. | |
bool | getBattVoltage (uint16_t *v) |
Get battery voltage level. | |
bool | unlockSIM (char *pin) |
Unlock SIM if needed. | |
uint8_t | getSIMCCID (char *ccid) |
Get the SIM chip card interface device (CCID) | |
uint8_t | getNetworkStatus (void) |
Get the Network Status of FONA. | |
uint8_t | getRSSI (void) |
Get the RSSI of the network signal. | |
uint8_t | getIMEI (char *imei) |
Get the International Mobile Station Equipment Identity (IMEI) | |
bool | setAudio (uint8_t a) |
Set the Audio Output interface. | |
bool | setVolume (uint8_t i) |
Set the Audio Volume. | |
uint8_t | getVolume (void) |
Get the Audio Volume. | |
bool | tuneFMradio (uint16_t station) |
Tune the FM radio. | |
bool | FMradio (bool onoff, uint8_t a=FONA_HEADSETAUDIO) |
FM radio set output. | |
bool | setFMVolume (uint8_t i) |
Set the FM Radio Volume. | |
int8_t | getFMVolume () |
Get the FM Volume. | |
int8_t | getFMSignalLevel (uint16_t station) |
Get the FM signal strength. | |
bool | setSMSInterrupt (uint8_t i) |
Set the SMS Interrupt. | |
uint8_t | getSMSInterrupt (void) |
Get SMS Interrupt Setting. | |
int8_t | getNumSMS (void) |
Set the SMS Interrupt. | |
bool | readSMS (uint8_t i, char *smsbuff, uint16_t max, uint16_t *readsize) |
Read SMS. | |
bool | sendSMS (char *smsaddr, char *smsmsg) |
Send SMS. | |
bool | deleteSMS (uint8_t i) |
Delete SMS. | |
bool | getSMSSender (uint8_t i, char *sender, int senderlen) |
Send SMS. | |
bool | enableNetworkTimeSync (bool onoff) |
Enable FONA to sync time with the cellular network. | |
bool | enableNTPTimeSync (bool onoff, const char *ntpserver=0) |
Enable FONA to sync time with the time server. | |
bool | getTime (char *buff, uint16_t maxlen) |
Retrieve the current time from the enabled server. | |
bool | setPWM (uint16_t period, uint8_t duty=50) |
Control the buzzer capability of the PWM out on the FONA. | |
bool | callPhone (char *phonenum) |
Call a phone. | |
bool | hangUp (void) |
Hang up a phone call. | |
bool | pickUp (void) |
Answer a phone call. | |
bool | callerIdNotification (bool enable) |
Enable/disable caller ID. | |
bool | incomingCallNumber (char *phonenum) |
Retrieve the incoming call number. |
Detailed Description
Adafruit FONA 800H Class Modified by George Tzintzarov & Jesse Baker 03/14/2016 for use in mbed LPC1768.
Definition at line 58 of file Adafruit_FONA.h.
Constructor & Destructor Documentation
Adafruit_FONA | ( | PinName | tx, |
PinName | rx, | ||
PinName | rst, | ||
PinName | ringIndicator | ||
) |
Create instance of the Adafruit_FONA.
- Parameters:
-
tx Set mbed TX rx Set mbed RX rst Set reset pin ringIndicator Set ring indicator pin. This is to let mbed know if there is an incoming call
Definition at line 105 of file Adafruit_FONA.h.
Member Function Documentation
bool begin | ( | int | baudrate ) |
Built-in Test to see if FONA is connected.
- Parameters:
-
baudrate test and set at baudrate
- Returns:
- true upon success
- false upon failure. Most likely something is not hooked up.
EXAMPLE CODE:
// See if the FONA is responding // fona is an instance of Adafruit_FONA if (! fona.begin(9600)) { printf("Couldn't find FONA\r\n"); while (1); }
Definition at line 34 of file Adafruit_FONA.cpp.
bool callerIdNotification | ( | bool | enable ) |
Enable/disable caller ID.
- Parameters:
-
enable true to enable, false to disable
- Returns:
- TRUE if successful
Definition at line 361 of file Adafruit_FONA.cpp.
bool callPhone | ( | char * | phonenum ) |
Call a phone.
- Parameters:
-
phonenum a character array of the phone number
- Returns:
- TRUE if successful
Definition at line 336 of file Adafruit_FONA.cpp.
bool deleteSMS | ( | uint8_t | i ) |
Delete SMS.
- Parameters:
-
i number of SMS in memory
- Returns:
- TRUE if successful
Definition at line 507 of file Adafruit_FONA.cpp.
bool enableNetworkTimeSync | ( | bool | onoff ) |
Enable FONA to sync time with the cellular network.
- Parameters:
-
onoff on = true, off = false
- Returns:
- TRUE if successful
Definition at line 522 of file Adafruit_FONA.cpp.
bool enableNTPTimeSync | ( | bool | onoff, |
const char * | ntpserver = 0 |
||
) |
Enable FONA to sync time with the time server.
- Parameters:
-
onoff true = on, false = off
- Returns:
- TRUE if successful
Definition at line 536 of file Adafruit_FONA.cpp.
bool FMradio | ( | bool | onoff, |
uint8_t | a = FONA_HEADSETAUDIO |
||
) |
FM radio set output.
- Parameters:
-
onoff bool to turn on if TRUE a 0 (default) is headset, 1 is external audio
- Returns:
- TRUE if successful
Definition at line 267 of file Adafruit_FONA.cpp.
bool getADCVoltage | ( | uint16_t * | v ) |
Get ADC voltage from external pin.
- Parameters:
-
v uint16_t pointer to insert ADC voltage data
- Returns:
- TRUE if successful
EXAMPLE CODE:
// read the ADC // fona is an instance of Adafruit_FONA uint16_t adc; if (! fona.getADCVoltage(&adc)) { printf("Failed to read ADC\r\n"); } else { printf("ADC = %d mV\r\n", adc); }
Definition at line 160 of file Adafruit_FONA.cpp.
bool getBattPercent | ( | uint16_t * | p ) |
Get battery percentage level.
- Parameters:
-
p uint16_t pointer to insert battery percent data
- Returns:
- TRUE if successful
EXAMPLE CODE:
// read the battery percent level // fona is an instance of Adafruit_FONA uint16_t vbatPer; if (! fona.getBattPercent(&vbatPer)) { printf("Failed to read Batt\r\n"); } else { printf("VPct = %d%%\r\n", vbatPer); }
Definition at line 156 of file Adafruit_FONA.cpp.
bool getBattVoltage | ( | uint16_t * | v ) |
Get battery voltage level.
- Parameters:
-
v uint16_t pointer to insert battery voltage data
- Returns:
- TRUE if successful
EXAMPLE CODE:
// read the battery voltage // fona is an instance of Adafruit_FONA uint16_t vbat; if (! fona.getBattPercent(&vbat)) { printf("Failed to read Batt\r\n"); } else { printf("Vbat = %d%%\r\n", vbat); }
Definition at line 151 of file Adafruit_FONA.cpp.
int8_t getFMSignalLevel | ( | uint16_t | station ) |
Get the FM signal strength.
- Parameters:
-
station a unit8_t volume number
- Returns:
- TRUE if successful
Definition at line 303 of file Adafruit_FONA.cpp.
int8_t getFMVolume | ( | ) |
uint8_t getIMEI | ( | char * | imei ) |
Get the International Mobile Station Equipment Identity (IMEI)
- Parameters:
-
imei A char array with minimum length 16
- Returns:
- The IMEI of the device
EXAMPLE CODE:
// Print SIM card IMEI number. char imei[15] = {0}; // MUST use a 16 character buffer for IMEI! uint8_t imeiLen = fona.getIMEI(imei); //fona is an instance of Adafruit_FONA if (imeiLen > 0) { pcSerial.printf("SIM card IMEI: %s\r\n", imei); }
Definition at line 191 of file Adafruit_FONA.cpp.
uint8_t getNetworkStatus | ( | void | ) |
int8_t getNumSMS | ( | void | ) |
Set the SMS Interrupt.
- Returns:
- number of SMS messages in inbox
Definition at line 408 of file Adafruit_FONA.cpp.
uint8_t getRSSI | ( | void | ) |
Get the RSSI of the network signal.
- Returns:
- RSSI value in dBm per below reference
EXAMPLE
// read the RSSI uint8_t n = fona.getRSSI(); int8_t r = 0; pcSerial.printf("RSSI = %d: ", n); if (n == 0) r = -115; if (n == 1) r = -111; if (n == 31) r = -52; if ((n >= 2) && (n <= 30)) { r = map(n, 2, 30, -110, -54); } printf("%d dBm\r\n", r); // helper function MAP to do calculations long MAP(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }
Definition at line 214 of file Adafruit_FONA.cpp.
uint8_t getSIMCCID | ( | char * | ccid ) |
Get the SIM chip card interface device (CCID)
- Parameters:
-
ccid make sure it is at least 21 bytes long
- Returns:
- length of CCID
Definition at line 178 of file Adafruit_FONA.cpp.
uint8_t getSMSInterrupt | ( | void | ) |
bool getSMSSender | ( | uint8_t | i, |
char * | sender, | ||
int | senderlen | ||
) |
Send SMS.
- Parameters:
-
i Number of SMS in memory sender Char array to store the sender number senderlen length of sender
- Returns:
- TRUE if successful
Definition at line 461 of file Adafruit_FONA.cpp.
bool getTime | ( | char * | buff, |
uint16_t | maxlen | ||
) |
Retrieve the current time from the enabled server.
- Parameters:
-
buff char array to store time value. Given as "yy/MM/dd,hh:mm:ss+zz" maxlen Maximum length of the char array
- Returns:
- TRUE if successful
Definition at line 567 of file Adafruit_FONA.cpp.
uint8_t getVolume | ( | void | ) |
bool hangUp | ( | void | ) |
Hang up a phone call.
Definition at line 346 of file Adafruit_FONA.cpp.
bool incomingCallNumber | ( | char * | phonenum ) |
Retrieve the incoming call number.
- Parameters:
-
phonenum a character array of the phone number calling
- Returns:
- TRUE if successful
Definition at line 371 of file Adafruit_FONA.cpp.
bool pickUp | ( | void | ) |
Answer a phone call.
Definition at line 350 of file Adafruit_FONA.cpp.
int readable | ( | void | ) |
Check if FONA has anything in its output buffer.
- Returns:
- 0 if nothing
Definition at line 101 of file Adafruit_FONA.cpp.
bool readSMS | ( | uint8_t | i, |
char * | smsbuff, | ||
uint16_t | max, | ||
uint16_t * | readsize | ||
) |
Read SMS.
- Parameters:
-
i sms number in memory smsbuff char pointer to char array max Maximum length of smsbuff readsize the size in bytes of the SMS
- Returns:
- TRUE if successful
Definition at line 421 of file Adafruit_FONA.cpp.
bool sendSMS | ( | char * | smsaddr, |
char * | smsmsg | ||
) |
Send SMS.
- Parameters:
-
smsaddr Phone number to send out smsmsg Char array containing message
- Returns:
- TRUE if successful
Definition at line 475 of file Adafruit_FONA.cpp.
bool setAudio | ( | uint8_t | a ) |
Set the Audio Output interface.
- Parameters:
-
a 0 is headset, 1 is external audio
- Returns:
- TRUE if successful
Definition at line 224 of file Adafruit_FONA.cpp.
void setEventListener | ( | EventListener * | eventListener ) |
Set the event listener for incoming calls.
- Parameters:
-
eventListener A pointer to the event listener
- See also:
- Adafruit_FONA::EventListener for specific example
Definition at line 71 of file Adafruit_FONA.cpp.
bool setFMVolume | ( | uint8_t | i ) |
Set the FM Radio Volume.
- Parameters:
-
i a unit8_t volume number
- Returns:
- TRUE if successful
Definition at line 286 of file Adafruit_FONA.cpp.
bool setPWM | ( | uint16_t | period, |
uint8_t | duty = 50 |
||
) |
Control the buzzer capability of the PWM out on the FONA.
- Parameters:
-
period of the buzzing cycle (max 2000) duty the duty cycle of the buzzer (0 to 100)
- Returns:
- TRUE if successful
Definition at line 328 of file Adafruit_FONA.cpp.
bool setSMSInterrupt | ( | uint8_t | i ) |
Set the SMS Interrupt.
- Parameters:
-
i 0 = OFF, 1 = ON with TCPIP, FTP, and URC control Ring Indicator Pin, 2 = ON with only TCPIP control
- Returns:
- TRUE if successful
Definition at line 404 of file Adafruit_FONA.cpp.
bool setVolume | ( | uint8_t | i ) |
Set the Audio Volume.
- Parameters:
-
i a unit8_t volume number
- Returns:
- TRUE if successful
Definition at line 239 of file Adafruit_FONA.cpp.
bool tuneFMradio | ( | uint16_t | station ) |
Tune the FM radio.
- Parameters:
-
station frequency, for example 107.9 MHz -> 1079
- Returns:
- TRUE if successful
Definition at line 278 of file Adafruit_FONA.cpp.
bool unlockSIM | ( | char * | pin ) |
Unlock SIM if needed.
- Parameters:
-
pin 4 digit char arrary
- Returns:
- TRUE if successful
Definition at line 166 of file Adafruit_FONA.cpp.
Generated on Tue Jul 12 2022 12:50:15 by
![doxygen](doxygen.png)