program to test exporting mbed-dev
Fork of FONA_CellPhone by
Adafruit_FONA.h@16:18750ad91289, 2016-03-29 (annotated)
- Committer:
- George windoge T
- Date:
- Tue Mar 29 22:51:02 2016 -0400
- Revision:
- 16:18750ad91289
- Parent:
- 15:19a02a88836a
- Child:
- 18:d52017f1d087
GT added more documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gtzintzarov3 | 0:851248a56628 | 1 | /*************************************************** |
gtzintzarov3 | 0:851248a56628 | 2 | This is a library for our Adafruit FONA Cellular Module |
gtzintzarov3 | 0:851248a56628 | 3 | |
gtzintzarov3 | 0:851248a56628 | 4 | Designed specifically to work with the Adafruit FONA |
gtzintzarov3 | 0:851248a56628 | 5 | ----> http://www.adafruit.com/products/1946 |
gtzintzarov3 | 0:851248a56628 | 6 | ----> http://www.adafruit.com/products/1963 |
gtzintzarov3 | 0:851248a56628 | 7 | |
gtzintzarov3 | 0:851248a56628 | 8 | These displays use TTL Serial to communicate, 2 pins are required to |
gtzintzarov3 | 0:851248a56628 | 9 | interface |
gtzintzarov3 | 0:851248a56628 | 10 | Adafruit invests time and resources providing this open source code, |
gtzintzarov3 | 0:851248a56628 | 11 | please support Adafruit and open-source hardware by purchasing |
gtzintzarov3 | 0:851248a56628 | 12 | products from Adafruit! |
gtzintzarov3 | 0:851248a56628 | 13 | |
gtzintzarov3 | 0:851248a56628 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. |
gtzintzarov3 | 0:851248a56628 | 15 | BSD license, all text above must be included in any redistribution |
gtzintzarov3 | 0:851248a56628 | 16 | ****************************************************/ |
gtzintzarov3 | 0:851248a56628 | 17 | |
gtzintzarov3 | 0:851248a56628 | 18 | /* |
gtzintzarov3 | 9:06eca688f2a3 | 19 | * Modified by George Tzintzarov & Jesse Baker 03/14/2016 for use in mbed LPC1768 |
gtzintzarov3 | 0:851248a56628 | 20 | */ |
gtzintzarov3 | 0:851248a56628 | 21 | |
gtzintzarov3 | 0:851248a56628 | 22 | #ifndef ADAFRUIT_FONA_H |
gtzintzarov3 | 0:851248a56628 | 23 | #define ADAFRUIT_FONA_H |
gtzintzarov3 | 0:851248a56628 | 24 | |
gtzintzarov3 | 0:851248a56628 | 25 | #include "mbed.h" |
gtzintzarov3 | 0:851248a56628 | 26 | |
gtzintzarov3 | 0:851248a56628 | 27 | //#define ADAFRUIT_FONA_DEBUG |
gtzintzarov3 | 0:851248a56628 | 28 | |
gtzintzarov3 | 0:851248a56628 | 29 | #define FONA_HEADSETAUDIO 0 |
gtzintzarov3 | 0:851248a56628 | 30 | #define FONA_EXTAUDIO 1 |
gtzintzarov3 | 0:851248a56628 | 31 | |
gtzintzarov3 | 0:851248a56628 | 32 | #define FONA_STTONE_DIALTONE 1 |
gtzintzarov3 | 0:851248a56628 | 33 | #define FONA_STTONE_BUSY 2 |
gtzintzarov3 | 0:851248a56628 | 34 | #define FONA_STTONE_CONGESTION 3 |
gtzintzarov3 | 0:851248a56628 | 35 | #define FONA_STTONE_PATHACK 4 |
gtzintzarov3 | 0:851248a56628 | 36 | #define FONA_STTONE_DROPPED 5 |
gtzintzarov3 | 0:851248a56628 | 37 | #define FONA_STTONE_ERROR 6 |
gtzintzarov3 | 0:851248a56628 | 38 | #define FONA_STTONE_CALLWAIT 7 |
gtzintzarov3 | 0:851248a56628 | 39 | #define FONA_STTONE_RINGING 8 |
gtzintzarov3 | 0:851248a56628 | 40 | #define FONA_STTONE_BEEP 16 |
gtzintzarov3 | 0:851248a56628 | 41 | #define FONA_STTONE_POSTONE 17 |
gtzintzarov3 | 0:851248a56628 | 42 | #define FONA_STTONE_ERRTONE 18 |
gtzintzarov3 | 0:851248a56628 | 43 | #define FONA_STTONE_INDIANDIALTONE 19 |
gtzintzarov3 | 0:851248a56628 | 44 | #define FONA_STTONE_USADIALTONE 20 |
gtzintzarov3 | 0:851248a56628 | 45 | |
George windoge T |
2:aaef20ac9044 | 46 | #define FONA_DEFAULT_TIMEOUT_MS 500 //timeout between send AT and reply from FONA |
gtzintzarov3 | 0:851248a56628 | 47 | |
gtzintzarov3 | 0:851248a56628 | 48 | #define FONA_HTTP_GET 0 |
gtzintzarov3 | 0:851248a56628 | 49 | #define FONA_HTTP_POST 1 |
gtzintzarov3 | 0:851248a56628 | 50 | #define FONA_HTTP_HEAD 2 |
gtzintzarov3 | 0:851248a56628 | 51 | |
gtzintzarov3 | 0:851248a56628 | 52 | #define RX_BUFFER_SIZE 255 |
gtzintzarov3 | 0:851248a56628 | 53 | |
gtzintzarov3 | 9:06eca688f2a3 | 54 | /** Adafruit FONA 800H Class |
gtzintzarov3 | 9:06eca688f2a3 | 55 | * Modified by George Tzintzarov & Jesse Baker 03/14/2016 for use in mbed LPC1768 |
gtzintzarov3 | 9:06eca688f2a3 | 56 | */ |
gtzintzarov3 | 9:06eca688f2a3 | 57 | |
gtzintzarov3 | 0:851248a56628 | 58 | class Adafruit_FONA : public Stream { |
gtzintzarov3 | 0:851248a56628 | 59 | public: |
gtzintzarov3 | 9:06eca688f2a3 | 60 | /** |
gtzintzarov3 | 9:06eca688f2a3 | 61 | Listener for FONA events. Inherit this class to customize. |
gtzintzarov3 | 9:06eca688f2a3 | 62 | @code |
gtzintzarov3 | 9:06eca688f2a3 | 63 | #define FONA_RST p12 |
gtzintzarov3 | 9:06eca688f2a3 | 64 | #define FONA_TX p13 |
gtzintzarov3 | 9:06eca688f2a3 | 65 | #define FONA_RX p14 |
gtzintzarov3 | 9:06eca688f2a3 | 66 | #define FONA_RI p11 |
gtzintzarov3 | 9:06eca688f2a3 | 67 | |
gtzintzarov3 | 9:06eca688f2a3 | 68 | Adafruit_FONA my_fona(FONA_TX, FONA_RX, FONA_RST, FONA_RI); |
gtzintzarov3 | 9:06eca688f2a3 | 69 | DigitalOut led1(LED1); |
gtzintzarov3 | 9:06eca688f2a3 | 70 | class FonaEventListener : public Adafruit_FONA::EventListener { |
gtzintzarov3 | 9:06eca688f2a3 | 71 | virtual void onRing() { |
gtzintzarov3 | 9:06eca688f2a3 | 72 | led1 = 1; |
gtzintzarov3 | 9:06eca688f2a3 | 73 | } |
gtzintzarov3 | 9:06eca688f2a3 | 74 | |
gtzintzarov3 | 9:06eca688f2a3 | 75 | virtual void onNoCarrier() { |
gtzintzarov3 | 9:06eca688f2a3 | 76 | led1 = 0; |
gtzintzarov3 | 9:06eca688f2a3 | 77 | } |
gtzintzarov3 | 9:06eca688f2a3 | 78 | }; |
gtzintzarov3 | 9:06eca688f2a3 | 79 | FonaEventListener fonaEventListener; |
gtzintzarov3 | 9:06eca688f2a3 | 80 | my_fona.setEventListener(&fonaEventListener); |
gtzintzarov3 | 9:06eca688f2a3 | 81 | @endcode |
gtzintzarov3 | 9:06eca688f2a3 | 82 | */ |
gtzintzarov3 | 9:06eca688f2a3 | 83 | |
gtzintzarov3 | 0:851248a56628 | 84 | class EventListener { |
gtzintzarov3 | 0:851248a56628 | 85 | public: |
gtzintzarov3 | 0:851248a56628 | 86 | /** |
gtzintzarov3 | 0:851248a56628 | 87 | * Method called when somebody call the FONA. |
gtzintzarov3 | 0:851248a56628 | 88 | */ |
gtzintzarov3 | 0:851248a56628 | 89 | virtual void onRing() = 0; |
gtzintzarov3 | 0:851248a56628 | 90 | |
gtzintzarov3 | 0:851248a56628 | 91 | /** |
gtzintzarov3 | 0:851248a56628 | 92 | * Method called when the calling person stop his call. |
gtzintzarov3 | 0:851248a56628 | 93 | */ |
gtzintzarov3 | 0:851248a56628 | 94 | virtual void onNoCarrier() = 0; |
gtzintzarov3 | 0:851248a56628 | 95 | }; |
gtzintzarov3 | 0:851248a56628 | 96 | |
gtzintzarov3 | 0:851248a56628 | 97 | public: |
gtzintzarov3 | 9:06eca688f2a3 | 98 | /** Create instance of the Adafruit_FONA |
gtzintzarov3 | 9:06eca688f2a3 | 99 | @param tx Set mbed TX |
gtzintzarov3 | 9:06eca688f2a3 | 100 | @param rx Set mbed RX |
gtzintzarov3 | 9:06eca688f2a3 | 101 | @param rst Set reset pin |
gtzintzarov3 | 9:06eca688f2a3 | 102 | @param ringIndicator Set ring indicator pin. This is to let mbed know if there is an incoming call |
gtzintzarov3 | 9:06eca688f2a3 | 103 | */ |
gtzintzarov3 | 9:06eca688f2a3 | 104 | |
gtzintzarov3 | 0:851248a56628 | 105 | Adafruit_FONA(PinName tx, PinName rx, PinName rst, PinName ringIndicator) : |
gtzintzarov3 | 0:851248a56628 | 106 | _rstpin(rst, false), _ringIndicatorInterruptIn(ringIndicator), |
gtzintzarov3 | 0:851248a56628 | 107 | apn("FONAnet"), apnusername(NULL), apnpassword(NULL), httpsredirect(false), useragent("FONA"), |
gtzintzarov3 | 0:851248a56628 | 108 | _incomingCall(false), eventListener(NULL), mySerial(tx, rx), rxBufferInIndex(0), rxBufferOutIndex(0), |
gtzintzarov3 | 0:851248a56628 | 109 | currentReceivedLineSize(0) {} |
gtzintzarov3 | 9:06eca688f2a3 | 110 | |
gtzintzarov3 | 9:06eca688f2a3 | 111 | /** Built-in Test to see if FONA is connected |
gtzintzarov3 | 9:06eca688f2a3 | 112 | @param baudrate test and set at baudrate |
gtzintzarov3 | 9:06eca688f2a3 | 113 | @return true upon success |
gtzintzarov3 | 9:06eca688f2a3 | 114 | @return false upon failure. Most likely something is not hooked up. |
gtzintzarov3 | 9:06eca688f2a3 | 115 | |
gtzintzarov3 | 9:06eca688f2a3 | 116 | EXAMPLE CODE: |
gtzintzarov3 | 9:06eca688f2a3 | 117 | @code |
gtzintzarov3 | 9:06eca688f2a3 | 118 | // See if the FONA is responding |
gtzintzarov3 | 9:06eca688f2a3 | 119 | // fona is an instance of Adafruit_FONA |
gtzintzarov3 | 9:06eca688f2a3 | 120 | if (! fona.begin(9600)) { |
gtzintzarov3 | 9:06eca688f2a3 | 121 | printf("Couldn't find FONA\r\n"); |
gtzintzarov3 | 9:06eca688f2a3 | 122 | while (1); |
gtzintzarov3 | 9:06eca688f2a3 | 123 | } |
gtzintzarov3 | 9:06eca688f2a3 | 124 | @endcode |
gtzintzarov3 | 9:06eca688f2a3 | 125 | */ |
gtzintzarov3 | 0:851248a56628 | 126 | bool begin(int baudrate); |
gtzintzarov3 | 9:06eca688f2a3 | 127 | |
gtzintzarov3 | 9:06eca688f2a3 | 128 | /** Set the event listener for incoming calls |
gtzintzarov3 | 9:06eca688f2a3 | 129 | @param eventListener A pointer to the event listener |
gtzintzarov3 | 9:06eca688f2a3 | 130 | @see Adafruit_FONA::EventListener for specific example |
gtzintzarov3 | 9:06eca688f2a3 | 131 | */ |
gtzintzarov3 | 9:06eca688f2a3 | 132 | |
gtzintzarov3 | 0:851248a56628 | 133 | void setEventListener(EventListener *eventListener); |
gtzintzarov3 | 0:851248a56628 | 134 | |
gtzintzarov3 | 9:06eca688f2a3 | 135 | // Stream---------------------------------------------------------------------- |
gtzintzarov3 | 0:851248a56628 | 136 | virtual int _putc(int value); |
gtzintzarov3 | 0:851248a56628 | 137 | virtual int _getc(); |
gtzintzarov3 | 0:851248a56628 | 138 | |
gtzintzarov3 | 9:06eca688f2a3 | 139 | /** Check if FONA has anything in its output buffer |
gtzintzarov3 | 9:06eca688f2a3 | 140 | @return 0 if nothing |
gtzintzarov3 | 9:06eca688f2a3 | 141 | */ |
gtzintzarov3 | 9:06eca688f2a3 | 142 | int readable(void); |
gtzintzarov3 | 9:06eca688f2a3 | 143 | |
gtzintzarov3 | 9:06eca688f2a3 | 144 | // RTC---------------------------------------------------------------------- |
gtzintzarov3 | 0:851248a56628 | 145 | bool enableRTC(uint8_t i); // i = 0 <=> disable, i = 1 <=> enable |
gtzintzarov3 | 0:851248a56628 | 146 | |
gtzintzarov3 | 9:06eca688f2a3 | 147 | // Battery and ADC---------------------------------------------------------------------- |
gtzintzarov3 | 9:06eca688f2a3 | 148 | /** Get ADC voltage from external pin |
gtzintzarov3 | 9:06eca688f2a3 | 149 | @param v uint16_t pointer to insert ADC voltage data |
gtzintzarov3 | 9:06eca688f2a3 | 150 | @return TRUE if successful |
gtzintzarov3 | 9:06eca688f2a3 | 151 | |
gtzintzarov3 | 9:06eca688f2a3 | 152 | EXAMPLE CODE: |
gtzintzarov3 | 9:06eca688f2a3 | 153 | @code |
gtzintzarov3 | 9:06eca688f2a3 | 154 | // read the ADC |
gtzintzarov3 | 9:06eca688f2a3 | 155 | // fona is an instance of Adafruit_FONA |
gtzintzarov3 | 9:06eca688f2a3 | 156 | uint16_t adc; |
gtzintzarov3 | 9:06eca688f2a3 | 157 | if (! fona.getADCVoltage(&adc)) { |
gtzintzarov3 | 9:06eca688f2a3 | 158 | printf("Failed to read ADC\r\n"); |
gtzintzarov3 | 9:06eca688f2a3 | 159 | } |
gtzintzarov3 | 9:06eca688f2a3 | 160 | else { |
gtzintzarov3 | 9:06eca688f2a3 | 161 | printf("ADC = %d mV\r\n", adc); |
gtzintzarov3 | 9:06eca688f2a3 | 162 | } |
gtzintzarov3 | 9:06eca688f2a3 | 163 | @endcode |
gtzintzarov3 | 9:06eca688f2a3 | 164 | */ |
gtzintzarov3 | 0:851248a56628 | 165 | bool getADCVoltage(uint16_t *v); |
gtzintzarov3 | 9:06eca688f2a3 | 166 | |
gtzintzarov3 | 9:06eca688f2a3 | 167 | /** Get battery percentage level |
gtzintzarov3 | 9:06eca688f2a3 | 168 | @param p uint16_t pointer to insert battery percent data |
gtzintzarov3 | 9:06eca688f2a3 | 169 | @return TRUE if successful |
gtzintzarov3 | 9:06eca688f2a3 | 170 | |
gtzintzarov3 | 9:06eca688f2a3 | 171 | EXAMPLE CODE: |
gtzintzarov3 | 9:06eca688f2a3 | 172 | @code |
gtzintzarov3 | 9:06eca688f2a3 | 173 | // read the battery percent level |
gtzintzarov3 | 9:06eca688f2a3 | 174 | // fona is an instance of Adafruit_FONA |
gtzintzarov3 | 9:06eca688f2a3 | 175 | uint16_t vbatPer; |
gtzintzarov3 | 9:06eca688f2a3 | 176 | if (! fona.getBattPercent(&vbatPer)) { |
gtzintzarov3 | 9:06eca688f2a3 | 177 | printf("Failed to read Batt\r\n"); |
gtzintzarov3 | 9:06eca688f2a3 | 178 | } |
gtzintzarov3 | 9:06eca688f2a3 | 179 | else { |
gtzintzarov3 | 9:06eca688f2a3 | 180 | printf("VPct = %d%%\r\n", vbatPer); |
gtzintzarov3 | 9:06eca688f2a3 | 181 | } |
gtzintzarov3 | 9:06eca688f2a3 | 182 | @endcode |
gtzintzarov3 | 9:06eca688f2a3 | 183 | */ |
gtzintzarov3 | 9:06eca688f2a3 | 184 | |
gtzintzarov3 | 0:851248a56628 | 185 | bool getBattPercent(uint16_t *p); |
gtzintzarov3 | 9:06eca688f2a3 | 186 | |
gtzintzarov3 | 9:06eca688f2a3 | 187 | /** Get battery voltage level |
gtzintzarov3 | 9:06eca688f2a3 | 188 | @param v uint16_t pointer to insert battery voltage data |
gtzintzarov3 | 9:06eca688f2a3 | 189 | @return TRUE if successful |
gtzintzarov3 | 9:06eca688f2a3 | 190 | |
gtzintzarov3 | 9:06eca688f2a3 | 191 | EXAMPLE CODE: |
gtzintzarov3 | 9:06eca688f2a3 | 192 | @code |
gtzintzarov3 | 9:06eca688f2a3 | 193 | // read the battery voltage |
gtzintzarov3 | 9:06eca688f2a3 | 194 | // fona is an instance of Adafruit_FONA |
gtzintzarov3 | 9:06eca688f2a3 | 195 | uint16_t vbat; |
gtzintzarov3 | 9:06eca688f2a3 | 196 | if (! fona.getBattPercent(&vbat)) { |
gtzintzarov3 | 9:06eca688f2a3 | 197 | printf("Failed to read Batt\r\n"); |
gtzintzarov3 | 9:06eca688f2a3 | 198 | } |
gtzintzarov3 | 9:06eca688f2a3 | 199 | else { |
gtzintzarov3 | 9:06eca688f2a3 | 200 | printf("Vbat = %d%%\r\n", vbat); |
gtzintzarov3 | 9:06eca688f2a3 | 201 | } |
gtzintzarov3 | 9:06eca688f2a3 | 202 | @endcode |
gtzintzarov3 | 9:06eca688f2a3 | 203 | */ |
gtzintzarov3 | 0:851248a56628 | 204 | bool getBattVoltage(uint16_t *v); |
gtzintzarov3 | 0:851248a56628 | 205 | |
gtzintzarov3 | 9:06eca688f2a3 | 206 | // SIM query---------------------------------------------------------------------- |
gtzintzarov3 | 9:06eca688f2a3 | 207 | /** Unlock SIM if needed |
gtzintzarov3 | 9:06eca688f2a3 | 208 | @param pin 4 digit char arrary |
gtzintzarov3 | 9:06eca688f2a3 | 209 | @return TRUE if successful |
gtzintzarov3 | 9:06eca688f2a3 | 210 | */ |
gtzintzarov3 | 0:851248a56628 | 211 | bool unlockSIM(char *pin); |
gtzintzarov3 | 9:06eca688f2a3 | 212 | /** Get the SIM chip card interface device (CCID) |
gtzintzarov3 | 9:06eca688f2a3 | 213 | @param ccid make sure it is at least 21 bytes long |
gtzintzarov3 | 9:06eca688f2a3 | 214 | @return length of CCID |
gtzintzarov3 | 9:06eca688f2a3 | 215 | */ |
gtzintzarov3 | 10:9dd3e49dec97 | 216 | |
gtzintzarov3 | 0:851248a56628 | 217 | uint8_t getSIMCCID(char *ccid); |
gtzintzarov3 | 9:06eca688f2a3 | 218 | /** Get the Network Status of FONA |
gtzintzarov3 | 9:06eca688f2a3 | 219 | @return Code 0-5 |
gtzintzarov3 | 10:9dd3e49dec97 | 220 | @see https://www.adafruit.com/datasheets/sim800_series_at_command_manual_v1.01.pdf page 80 |
gtzintzarov3 | 9:06eca688f2a3 | 221 | */ |
gtzintzarov3 | 0:851248a56628 | 222 | uint8_t getNetworkStatus(void); |
gtzintzarov3 | 10:9dd3e49dec97 | 223 | |
gtzintzarov3 | 10:9dd3e49dec97 | 224 | /** Get the RSSI of the network signal |
gtzintzarov3 | 10:9dd3e49dec97 | 225 | @return RSSI value in dBm per below reference |
gtzintzarov3 | 10:9dd3e49dec97 | 226 | |
gtzintzarov3 | 10:9dd3e49dec97 | 227 | EXAMPLE |
gtzintzarov3 | 10:9dd3e49dec97 | 228 | @code |
gtzintzarov3 | 10:9dd3e49dec97 | 229 | // read the RSSI |
gtzintzarov3 | 10:9dd3e49dec97 | 230 | uint8_t n = fona.getRSSI(); |
gtzintzarov3 | 10:9dd3e49dec97 | 231 | int8_t r = 0; |
gtzintzarov3 | 10:9dd3e49dec97 | 232 | |
gtzintzarov3 | 10:9dd3e49dec97 | 233 | pcSerial.printf("RSSI = %d: ", n); |
gtzintzarov3 | 10:9dd3e49dec97 | 234 | if (n == 0) r = -115; |
gtzintzarov3 | 10:9dd3e49dec97 | 235 | if (n == 1) r = -111; |
gtzintzarov3 | 10:9dd3e49dec97 | 236 | if (n == 31) r = -52; |
gtzintzarov3 | 10:9dd3e49dec97 | 237 | if ((n >= 2) && (n <= 30)) { |
gtzintzarov3 | 10:9dd3e49dec97 | 238 | r = map(n, 2, 30, -110, -54); |
gtzintzarov3 | 10:9dd3e49dec97 | 239 | } |
gtzintzarov3 | 10:9dd3e49dec97 | 240 | printf("%d dBm\r\n", r); |
gtzintzarov3 | 10:9dd3e49dec97 | 241 | |
gtzintzarov3 | 10:9dd3e49dec97 | 242 | // helper function MAP to do calculations |
gtzintzarov3 | 10:9dd3e49dec97 | 243 | long MAP(long x, long in_min, long in_max, long out_min, long out_max) |
gtzintzarov3 | 10:9dd3e49dec97 | 244 | { |
gtzintzarov3 | 10:9dd3e49dec97 | 245 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; |
gtzintzarov3 | 10:9dd3e49dec97 | 246 | } |
gtzintzarov3 | 10:9dd3e49dec97 | 247 | @endcode |
gtzintzarov3 | 10:9dd3e49dec97 | 248 | @see https://www.adafruit.com/datasheets/sim800_series_at_command_manual_v1.01.pdf page 82 |
gtzintzarov3 | 10:9dd3e49dec97 | 249 | */ |
gtzintzarov3 | 0:851248a56628 | 250 | uint8_t getRSSI(void); |
gtzintzarov3 | 0:851248a56628 | 251 | |
gtzintzarov3 | 9:06eca688f2a3 | 252 | // IMEI---------------------------------------------------------------------- |
gtzintzarov3 | 9:06eca688f2a3 | 253 | /** Get the International Mobile Station Equipment Identity (IMEI) |
gtzintzarov3 | 9:06eca688f2a3 | 254 | @param imei A char array with minimum length 16 |
gtzintzarov3 | 9:06eca688f2a3 | 255 | @return The IMEI of the device |
gtzintzarov3 | 10:9dd3e49dec97 | 256 | |
gtzintzarov3 | 9:06eca688f2a3 | 257 | EXAMPLE CODE: |
gtzintzarov3 | 9:06eca688f2a3 | 258 | @code |
gtzintzarov3 | 9:06eca688f2a3 | 259 | // Print SIM card IMEI number. |
gtzintzarov3 | 9:06eca688f2a3 | 260 | char imei[15] = {0}; // MUST use a 16 character buffer for IMEI! |
gtzintzarov3 | 9:06eca688f2a3 | 261 | uint8_t imeiLen = fona.getIMEI(imei); //fona is an instance of Adafruit_FONA |
gtzintzarov3 | 9:06eca688f2a3 | 262 | if (imeiLen > 0) { |
gtzintzarov3 | 9:06eca688f2a3 | 263 | pcSerial.printf("SIM card IMEI: %s\r\n", imei); |
gtzintzarov3 | 9:06eca688f2a3 | 264 | } |
gtzintzarov3 | 9:06eca688f2a3 | 265 | @endcode |
gtzintzarov3 | 9:06eca688f2a3 | 266 | */ |
gtzintzarov3 | 0:851248a56628 | 267 | uint8_t getIMEI(char *imei); |
gtzintzarov3 | 0:851248a56628 | 268 | |
gtzintzarov3 | 10:9dd3e49dec97 | 269 | // set Audio output---------------------------------------------------------------------- |
George windoge T |
16:18750ad91289 | 270 | /** Set the Audio Output interface |
George windoge T |
16:18750ad91289 | 271 | @param a 0 is headset, 1 is external audio |
George windoge T |
16:18750ad91289 | 272 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 273 | */ |
gtzintzarov3 | 0:851248a56628 | 274 | bool setAudio(uint8_t a); |
George windoge T |
16:18750ad91289 | 275 | |
George windoge T |
16:18750ad91289 | 276 | /** Set the Audio Volume |
George windoge T |
16:18750ad91289 | 277 | @param i a unit8_t volume number |
George windoge T |
16:18750ad91289 | 278 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 279 | */ |
gtzintzarov3 | 0:851248a56628 | 280 | bool setVolume(uint8_t i); |
George windoge T |
16:18750ad91289 | 281 | |
George windoge T |
16:18750ad91289 | 282 | /** Get the Audio Volume |
George windoge T |
16:18750ad91289 | 283 | @return the current volume |
George windoge T |
16:18750ad91289 | 284 | */ |
gtzintzarov3 | 0:851248a56628 | 285 | uint8_t getVolume(void); |
gtzintzarov3 | 0:851248a56628 | 286 | bool playToolkitTone(uint8_t t, uint16_t len); |
gtzintzarov3 | 0:851248a56628 | 287 | bool setMicVolume(uint8_t a, uint8_t level); |
gtzintzarov3 | 0:851248a56628 | 288 | bool playDTMF(char tone); |
gtzintzarov3 | 0:851248a56628 | 289 | |
gtzintzarov3 | 10:9dd3e49dec97 | 290 | // FM radio functions---------------------------------------------------------------------- |
George windoge T |
16:18750ad91289 | 291 | /** Tune the FM radio |
George windoge T |
16:18750ad91289 | 292 | @param station frequency, for example 107.9 MHz -> 1079 |
George windoge T |
16:18750ad91289 | 293 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 294 | */ |
gtzintzarov3 | 0:851248a56628 | 295 | bool tuneFMradio(uint16_t station); |
George windoge T |
16:18750ad91289 | 296 | |
George windoge T |
16:18750ad91289 | 297 | /** FM radio set output |
George windoge T |
16:18750ad91289 | 298 | @param onoff bool to turn on if TRUE |
George windoge T |
16:18750ad91289 | 299 | @param a 0 (default) is headset, 1 is external audio |
George windoge T |
16:18750ad91289 | 300 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 301 | */ |
gtzintzarov3 | 0:851248a56628 | 302 | bool FMradio(bool onoff, uint8_t a = FONA_HEADSETAUDIO); |
George windoge T |
16:18750ad91289 | 303 | |
George windoge T |
16:18750ad91289 | 304 | /** Set the FM Radio Volume |
George windoge T |
16:18750ad91289 | 305 | @param i a unit8_t volume number |
George windoge T |
16:18750ad91289 | 306 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 307 | */ |
gtzintzarov3 | 0:851248a56628 | 308 | bool setFMVolume(uint8_t i); |
George windoge T |
16:18750ad91289 | 309 | |
George windoge T |
16:18750ad91289 | 310 | /** Get the FM Volume |
George windoge T |
16:18750ad91289 | 311 | @return the current FM volume |
George windoge T |
16:18750ad91289 | 312 | */ |
gtzintzarov3 | 0:851248a56628 | 313 | int8_t getFMVolume(); |
George windoge T |
16:18750ad91289 | 314 | |
George windoge T |
16:18750ad91289 | 315 | /** Get the FM signal strength |
George windoge T |
16:18750ad91289 | 316 | @param station a unit8_t volume number |
George windoge T |
16:18750ad91289 | 317 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 318 | */ |
gtzintzarov3 | 0:851248a56628 | 319 | int8_t getFMSignalLevel(uint16_t station); |
gtzintzarov3 | 0:851248a56628 | 320 | |
gtzintzarov3 | 10:9dd3e49dec97 | 321 | // SMS handling---------------------------------------------------------------------- |
George windoge T |
16:18750ad91289 | 322 | /** Set the SMS Interrupt |
George windoge T |
16:18750ad91289 | 323 | @param i 0 = OFF, 1 = ON with TCPIP, FTP, and URC control Ring Indicator Pin, 2 = ON with only TCPIP control |
George windoge T |
16:18750ad91289 | 324 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 325 | @see https://www.adafruit.com/datasheets/sim800_series_at_command_manual_v1.01.pdf page 152 |
George windoge T |
16:18750ad91289 | 326 | */ |
gtzintzarov3 | 0:851248a56628 | 327 | bool setSMSInterrupt(uint8_t i); |
George windoge T |
16:18750ad91289 | 328 | |
George windoge T |
16:18750ad91289 | 329 | /** Get SMS Interrupt Setting |
George windoge T |
16:18750ad91289 | 330 | @return setting |
George windoge T |
16:18750ad91289 | 331 | @see https://www.adafruit.com/datasheets/sim800_series_at_command_manual_v1.01.pdf page 152 |
George windoge T |
16:18750ad91289 | 332 | */ |
gtzintzarov3 | 0:851248a56628 | 333 | uint8_t getSMSInterrupt(void); |
George windoge T |
16:18750ad91289 | 334 | |
George windoge T |
16:18750ad91289 | 335 | /** Set the SMS Interrupt |
George windoge T |
16:18750ad91289 | 336 | @return number of SMS messages in inbox |
George windoge T |
16:18750ad91289 | 337 | */ |
gtzintzarov3 | 0:851248a56628 | 338 | int8_t getNumSMS(void); |
George windoge T |
16:18750ad91289 | 339 | |
George windoge T |
16:18750ad91289 | 340 | /** Read SMS |
George windoge T |
16:18750ad91289 | 341 | @param i sms number in memory |
George windoge T |
16:18750ad91289 | 342 | @param smsbuff char pointer to char array |
George windoge T |
16:18750ad91289 | 343 | @param max Maximum length of smsbuff |
George windoge T |
16:18750ad91289 | 344 | @param readsize the size in bytes of the SMS |
George windoge T |
16:18750ad91289 | 345 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 346 | */ |
gtzintzarov3 | 0:851248a56628 | 347 | bool readSMS(uint8_t i, char *smsbuff, uint16_t max, uint16_t *readsize); |
George windoge T |
16:18750ad91289 | 348 | |
George windoge T |
16:18750ad91289 | 349 | /** Send SMS |
George windoge T |
16:18750ad91289 | 350 | @param smsaddr Phone number to send out |
George windoge T |
16:18750ad91289 | 351 | @param smsmsg Char array containing message |
George windoge T |
16:18750ad91289 | 352 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 353 | */ |
gtzintzarov3 | 0:851248a56628 | 354 | bool sendSMS(char *smsaddr, char *smsmsg); |
George windoge T |
16:18750ad91289 | 355 | |
George windoge T |
16:18750ad91289 | 356 | /** Delete SMS |
George windoge T |
16:18750ad91289 | 357 | @param i number of SMS in memory |
George windoge T |
16:18750ad91289 | 358 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 359 | */ |
gtzintzarov3 | 0:851248a56628 | 360 | bool deleteSMS(uint8_t i); |
George windoge T |
16:18750ad91289 | 361 | |
George windoge T |
16:18750ad91289 | 362 | /** Send SMS |
George windoge T |
16:18750ad91289 | 363 | @param i Number of SMS in memory |
George windoge T |
16:18750ad91289 | 364 | @param sender Char array to store the sender number |
George windoge T |
16:18750ad91289 | 365 | @param senderlen length of sender |
George windoge T |
16:18750ad91289 | 366 | @return TRUE if successful |
George windoge T |
16:18750ad91289 | 367 | */ |
gtzintzarov3 | 0:851248a56628 | 368 | bool getSMSSender(uint8_t i, char *sender, int senderlen); |
gtzintzarov3 | 0:851248a56628 | 369 | |
gtzintzarov3 | 10:9dd3e49dec97 | 370 | // Time---------------------------------------------------------------------- |
jbaker66 | 15:19a02a88836a | 371 | /** Enable FONA to sync time with the cellular network |
jbaker66 | 15:19a02a88836a | 372 | @param onoff on = true, off = false |
jbaker66 | 15:19a02a88836a | 373 | @return TRUE if successful |
jbaker66 | 15:19a02a88836a | 374 | */ |
gtzintzarov3 | 0:851248a56628 | 375 | bool enableNetworkTimeSync(bool onoff); |
jbaker66 | 15:19a02a88836a | 376 | |
jbaker66 | 15:19a02a88836a | 377 | /** Enable FONA to sync time with the time server |
jbaker66 | 15:19a02a88836a | 378 | @param onoff true = on, false = off |
jbaker66 | 15:19a02a88836a | 379 | @return TRUE if successful |
jbaker66 | 15:19a02a88836a | 380 | */ |
gtzintzarov3 | 0:851248a56628 | 381 | bool enableNTPTimeSync(bool onoff, const char* ntpserver=0); |
jbaker66 | 15:19a02a88836a | 382 | |
jbaker66 | 15:19a02a88836a | 383 | /** Retrieve the current time from the enabled server |
jbaker66 | 15:19a02a88836a | 384 | @param buff char array to store time value. Given as "yy/MM/dd,hh:mm:ss+zz" |
jbaker66 | 15:19a02a88836a | 385 | @param maxlen Maximum length of the char array |
jbaker66 | 15:19a02a88836a | 386 | @return TRUE if successful |
jbaker66 | 15:19a02a88836a | 387 | */ |
gtzintzarov3 | 0:851248a56628 | 388 | bool getTime(char* buff, uint16_t maxlen); |
jbaker66 | 15:19a02a88836a | 389 | |
gtzintzarov3 | 10:9dd3e49dec97 | 390 | // GPRS handling---------------------------------------------------------------------- |
gtzintzarov3 | 0:851248a56628 | 391 | bool enableGPRS(bool onoff); |
gtzintzarov3 | 0:851248a56628 | 392 | uint8_t GPRSstate(void); |
gtzintzarov3 | 0:851248a56628 | 393 | bool getGSMLoc(uint16_t *replycode, char *buff, uint16_t maxlen); |
gtzintzarov3 | 0:851248a56628 | 394 | bool getGSMLoc(float *lat, float *lon); |
gtzintzarov3 | 0:851248a56628 | 395 | void setGPRSNetworkSettings(const char* apn, const char* username=0, const char* password=0); |
gtzintzarov3 | 0:851248a56628 | 396 | |
gtzintzarov3 | 10:9dd3e49dec97 | 397 | // GPS handling---------------------------------------------------------------------- |
gtzintzarov3 | 0:851248a56628 | 398 | bool enableGPS(bool onoff); |
gtzintzarov3 | 0:851248a56628 | 399 | int8_t GPSstatus(void); |
gtzintzarov3 | 0:851248a56628 | 400 | uint8_t getGPS(uint8_t arg, char *buffer, uint8_t maxbuff); |
gtzintzarov3 | 0:851248a56628 | 401 | bool getGPS(float *lat, float *lon, float *speed_kph=0, float *heading=0, float *altitude=0); |
gtzintzarov3 | 0:851248a56628 | 402 | bool enableGPSNMEA(uint8_t nmea); |
jbaker66 | 15:19a02a88836a | 403 | |
gtzintzarov3 | 10:9dd3e49dec97 | 404 | // TCP raw connections---------------------------------------------------------------------- |
gtzintzarov3 | 0:851248a56628 | 405 | bool TCPconnect(char *server, uint16_t port); |
gtzintzarov3 | 0:851248a56628 | 406 | bool TCPclose(void); |
gtzintzarov3 | 0:851248a56628 | 407 | bool TCPconnected(void); |
gtzintzarov3 | 0:851248a56628 | 408 | bool TCPsend(char *packet, uint8_t len); |
gtzintzarov3 | 0:851248a56628 | 409 | uint16_t TCPavailable(void); |
gtzintzarov3 | 0:851248a56628 | 410 | uint16_t TCPread(uint8_t *buff, uint8_t len); |
jbaker66 | 15:19a02a88836a | 411 | |
gtzintzarov3 | 10:9dd3e49dec97 | 412 | // HTTP low level interface (maps directly to SIM800 commands).---------------------------------------------------------------------- |
gtzintzarov3 | 0:851248a56628 | 413 | bool HTTP_init(); |
gtzintzarov3 | 0:851248a56628 | 414 | bool HTTP_term(); |
gtzintzarov3 | 0:851248a56628 | 415 | void HTTP_para_start(const char* parameter, bool quoted = true); |
gtzintzarov3 | 0:851248a56628 | 416 | bool HTTP_para_end(bool quoted = true); |
gtzintzarov3 | 0:851248a56628 | 417 | bool HTTP_para(const char* parameter, const char *value); |
gtzintzarov3 | 0:851248a56628 | 418 | bool HTTP_para(const char* parameter, int32_t value); |
gtzintzarov3 | 0:851248a56628 | 419 | bool HTTP_data(uint32_t size, uint32_t maxTime=10000); |
gtzintzarov3 | 0:851248a56628 | 420 | bool HTTP_action(uint8_t method, uint16_t *status, uint16_t *datalen, int32_t timeout = 10000); |
gtzintzarov3 | 0:851248a56628 | 421 | bool HTTP_readall(uint16_t *datalen); |
gtzintzarov3 | 0:851248a56628 | 422 | bool HTTP_ssl(bool onoff); |
jbaker66 | 15:19a02a88836a | 423 | |
gtzintzarov3 | 10:9dd3e49dec97 | 424 | // HTTP high level interface (easier to use, less flexible).---------------------------------------------------------------------- |
gtzintzarov3 | 0:851248a56628 | 425 | bool HTTP_GET_start(char *url, uint16_t *status, uint16_t *datalen); |
gtzintzarov3 | 0:851248a56628 | 426 | void HTTP_GET_end(void); |
gtzintzarov3 | 0:851248a56628 | 427 | bool HTTP_POST_start(char *url, const char* contenttype, const uint8_t *postdata, uint16_t postdatalen, uint16_t *status, uint16_t *datalen); |
gtzintzarov3 | 0:851248a56628 | 428 | void HTTP_POST_end(void); |
gtzintzarov3 | 0:851248a56628 | 429 | void setUserAgent(const char* useragent); |
jbaker66 | 15:19a02a88836a | 430 | |
gtzintzarov3 | 10:9dd3e49dec97 | 431 | // HTTPS---------------------------------------------------------------------- |
gtzintzarov3 | 0:851248a56628 | 432 | void setHTTPSRedirect(bool onoff); |
jbaker66 | 15:19a02a88836a | 433 | |
gtzintzarov3 | 10:9dd3e49dec97 | 434 | // PWM (buzzer)---------------------------------------------------------------------- |
jbaker66 | 15:19a02a88836a | 435 | /** Control the buzzer capability of the PWM out on the FONA |
jbaker66 | 15:19a02a88836a | 436 | @param period of the buzzing cycle (max 2000) |
jbaker66 | 15:19a02a88836a | 437 | @param duty the duty cycle of the buzzer (0 to 100) |
jbaker66 | 15:19a02a88836a | 438 | @return TRUE if successful |
jbaker66 | 15:19a02a88836a | 439 | */ |
gtzintzarov3 | 0:851248a56628 | 440 | bool setPWM(uint16_t period, uint8_t duty = 50); |
jbaker66 | 15:19a02a88836a | 441 | |
gtzintzarov3 | 10:9dd3e49dec97 | 442 | // Phone calls---------------------------------------------------------------------- |
jbaker66 | 15:19a02a88836a | 443 | /** Call a phone |
jbaker66 | 15:19a02a88836a | 444 | @param phonenum a character array of the phone number |
jbaker66 | 15:19a02a88836a | 445 | @return TRUE if successful |
jbaker66 | 15:19a02a88836a | 446 | */ |
gtzintzarov3 | 0:851248a56628 | 447 | bool callPhone(char *phonenum); |
jbaker66 | 15:19a02a88836a | 448 | |
jbaker66 | 15:19a02a88836a | 449 | /** Hang up a phone call |
jbaker66 | 15:19a02a88836a | 450 | */ |
gtzintzarov3 | 0:851248a56628 | 451 | bool hangUp(void); |
jbaker66 | 15:19a02a88836a | 452 | |
jbaker66 | 15:19a02a88836a | 453 | /** Answer a phone call |
jbaker66 | 15:19a02a88836a | 454 | */ |
gtzintzarov3 | 0:851248a56628 | 455 | bool pickUp(void); |
jbaker66 | 15:19a02a88836a | 456 | |
jbaker66 | 15:19a02a88836a | 457 | /** Enable/disable caller ID |
jbaker66 | 15:19a02a88836a | 458 | @param enable true to enable, false to disable |
jbaker66 | 15:19a02a88836a | 459 | @return TRUE if successful |
jbaker66 | 15:19a02a88836a | 460 | */ |
gtzintzarov3 | 0:851248a56628 | 461 | bool callerIdNotification(bool enable); |
jbaker66 | 15:19a02a88836a | 462 | |
jbaker66 | 15:19a02a88836a | 463 | /** Retrieve the incoming call number |
jbaker66 | 15:19a02a88836a | 464 | @param phonenum a character array of the phone number calling |
jbaker66 | 15:19a02a88836a | 465 | @return TRUE if successful |
jbaker66 | 15:19a02a88836a | 466 | */ |
gtzintzarov3 | 0:851248a56628 | 467 | bool incomingCallNumber(char* phonenum); |
jbaker66 | 15:19a02a88836a | 468 | |
gtzintzarov3 | 0:851248a56628 | 469 | // Helper functions to verify responses. |
gtzintzarov3 | 0:851248a56628 | 470 | bool expectReply(const char* reply, uint16_t timeout = 10000); |
jbaker66 | 15:19a02a88836a | 471 | |
gtzintzarov3 | 0:851248a56628 | 472 | private: |
gtzintzarov3 | 0:851248a56628 | 473 | DigitalOut _rstpin; |
gtzintzarov3 | 0:851248a56628 | 474 | InterruptIn _ringIndicatorInterruptIn; |
jbaker66 | 15:19a02a88836a | 475 | |
George windoge T |
2:aaef20ac9044 | 476 | char replybuffer[255]; // the output of getreply(), readline() is the function that changes the replybuffer |
gtzintzarov3 | 0:851248a56628 | 477 | char* apn; |
gtzintzarov3 | 0:851248a56628 | 478 | char* apnusername; |
gtzintzarov3 | 0:851248a56628 | 479 | char* apnpassword; |
gtzintzarov3 | 0:851248a56628 | 480 | bool httpsredirect; |
gtzintzarov3 | 0:851248a56628 | 481 | char* useragent; |
jbaker66 | 15:19a02a88836a | 482 | |
gtzintzarov3 | 0:851248a56628 | 483 | volatile bool _incomingCall; |
gtzintzarov3 | 0:851248a56628 | 484 | EventListener *eventListener; |
gtzintzarov3 | 0:851248a56628 | 485 | Serial mySerial; |
jbaker66 | 15:19a02a88836a | 486 | |
gtzintzarov3 | 0:851248a56628 | 487 | // Circular buffer used to receive serial data from an interruption |
gtzintzarov3 | 0:851248a56628 | 488 | int rxBuffer[RX_BUFFER_SIZE + 1]; |
gtzintzarov3 | 0:851248a56628 | 489 | volatile int rxBufferInIndex; // Index where new data is added to the buffer |
gtzintzarov3 | 0:851248a56628 | 490 | volatile int rxBufferOutIndex; // Index where data is removed from the buffer |
gtzintzarov3 | 0:851248a56628 | 491 | char currentReceivedLine[RX_BUFFER_SIZE]; // Array containing the current received line |
gtzintzarov3 | 0:851248a56628 | 492 | int currentReceivedLineSize; |
jbaker66 | 15:19a02a88836a | 493 | |
gtzintzarov3 | 0:851248a56628 | 494 | inline bool isRxBufferFull() { |
gtzintzarov3 | 0:851248a56628 | 495 | return ((rxBufferInIndex + 1) % RX_BUFFER_SIZE) == rxBufferOutIndex; |
gtzintzarov3 | 0:851248a56628 | 496 | } |
jbaker66 | 15:19a02a88836a | 497 | |
gtzintzarov3 | 0:851248a56628 | 498 | inline bool isRxBufferEmpty() { |
gtzintzarov3 | 0:851248a56628 | 499 | return rxBufferInIndex == rxBufferOutIndex; |
gtzintzarov3 | 0:851248a56628 | 500 | } |
jbaker66 | 15:19a02a88836a | 501 | |
gtzintzarov3 | 0:851248a56628 | 502 | inline void incrementRxBufferInIndex() { |
gtzintzarov3 | 0:851248a56628 | 503 | rxBufferInIndex = (rxBufferInIndex + 1) % RX_BUFFER_SIZE; |
gtzintzarov3 | 0:851248a56628 | 504 | } |
jbaker66 | 15:19a02a88836a | 505 | |
gtzintzarov3 | 0:851248a56628 | 506 | inline void incrementRxBufferOutIndex() { |
gtzintzarov3 | 0:851248a56628 | 507 | rxBufferOutIndex = (rxBufferOutIndex + 1) % RX_BUFFER_SIZE; |
gtzintzarov3 | 0:851248a56628 | 508 | } |
jbaker66 | 15:19a02a88836a | 509 | |
gtzintzarov3 | 0:851248a56628 | 510 | /** |
gtzintzarov3 | 0:851248a56628 | 511 | * Method called when Serial data is received (interrupt routine). |
gtzintzarov3 | 0:851248a56628 | 512 | */ |
gtzintzarov3 | 0:851248a56628 | 513 | void onSerialDataReceived(); |
jbaker66 | 15:19a02a88836a | 514 | |
gtzintzarov3 | 0:851248a56628 | 515 | // HTTP helpers |
gtzintzarov3 | 0:851248a56628 | 516 | bool HTTP_setup(char *url); |
jbaker66 | 15:19a02a88836a | 517 | |
gtzintzarov3 | 0:851248a56628 | 518 | void flushInput(); |
gtzintzarov3 | 0:851248a56628 | 519 | uint16_t readRaw(uint16_t b); |
gtzintzarov3 | 0:851248a56628 | 520 | uint8_t readline(uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS, bool multiline = false); |
gtzintzarov3 | 0:851248a56628 | 521 | uint8_t getReply(const char* send, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
gtzintzarov3 | 0:851248a56628 | 522 | uint8_t getReply(const char* prefix, char *suffix, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
gtzintzarov3 | 0:851248a56628 | 523 | uint8_t getReply(const char* prefix, int32_t suffix, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
gtzintzarov3 | 0:851248a56628 | 524 | uint8_t getReply(const char* prefix, int32_t suffix1, int32_t suffix2, uint16_t timeout); // Don't set default value or else function call is ambiguous. |
gtzintzarov3 | 0:851248a56628 | 525 | uint8_t getReplyQuoted(const char* prefix, const char* suffix, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
jbaker66 | 15:19a02a88836a | 526 | |
gtzintzarov3 | 0:851248a56628 | 527 | bool sendCheckReply(const char* send, const char* reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
gtzintzarov3 | 0:851248a56628 | 528 | bool sendCheckReply(const char* prefix, char *suffix, const char* reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
gtzintzarov3 | 0:851248a56628 | 529 | bool sendCheckReply(const char* prefix, int32_t suffix, const char* reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
gtzintzarov3 | 0:851248a56628 | 530 | bool sendCheckReply(const char* prefix, int32_t suffix, int32_t suffix2, const char* reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
gtzintzarov3 | 0:851248a56628 | 531 | bool sendCheckReplyQuoted(const char* prefix, const char* suffix, const char* reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
jbaker66 | 15:19a02a88836a | 532 | |
gtzintzarov3 | 0:851248a56628 | 533 | bool parseReply(const char* toreply, uint16_t *v, char divider = ',', uint8_t index=0); |
gtzintzarov3 | 0:851248a56628 | 534 | bool parseReply(const char* toreply, char *v, char divider = ',', uint8_t index=0); |
gtzintzarov3 | 0:851248a56628 | 535 | bool parseReplyQuoted(const char* toreply, char* v, int maxlen, char divider, uint8_t index); |
jbaker66 | 15:19a02a88836a | 536 | |
gtzintzarov3 | 0:851248a56628 | 537 | bool sendParseReply(const char* tosend, const char* toreply, uint16_t *v, char divider = ',', uint8_t index = 0); |
jbaker66 | 15:19a02a88836a | 538 | |
gtzintzarov3 | 0:851248a56628 | 539 | void onIncomingCall(); |
gtzintzarov3 | 0:851248a56628 | 540 | }; |
gtzintzarov3 | 0:851248a56628 | 541 | |
gtzintzarov3 | 0:851248a56628 | 542 | #endif |