Library for the Adafruit FONA. This is a port of the original Arduino library available at: https://github.com/adafruit/Adafruit_FONA_Library . - Modified by Marc PLOUHINEC 27/06/2015 for use in mbed - Modified by lionel VOIRIN 05/08/2018 for use Adafruit FONA 3
Dependents: Adafruit_FONA_3G_Library_Test
Adafruit_FONA.h@10:7951d9691cb2, 2019-02-25 (annotated)
- Committer:
- Nels885
- Date:
- Mon Feb 25 20:27:24 2019 +0000
- Revision:
- 10:7951d9691cb2
- Parent:
- 9:b18cfba4283a
Various fona 3G patch
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nels885 | 0:bf67af6b3913 | 1 | /*************************************************** |
Nels885 | 0:bf67af6b3913 | 2 | This is a library for our Adafruit FONA Cellular Module |
Nels885 | 0:bf67af6b3913 | 3 | |
Nels885 | 0:bf67af6b3913 | 4 | Designed specifically to work with the Adafruit FONA |
Nels885 | 0:bf67af6b3913 | 5 | ----> http://www.adafruit.com/products/1946 |
Nels885 | 0:bf67af6b3913 | 6 | ----> http://www.adafruit.com/products/1963 |
Nels885 | 0:bf67af6b3913 | 7 | |
Nels885 | 0:bf67af6b3913 | 8 | These displays use TTL Serial to communicate, 2 pins are required to |
Nels885 | 0:bf67af6b3913 | 9 | interface |
Nels885 | 0:bf67af6b3913 | 10 | Adafruit invests time and resources providing this open source code, |
Nels885 | 0:bf67af6b3913 | 11 | please support Adafruit and open-source hardware by purchasing |
Nels885 | 0:bf67af6b3913 | 12 | products from Adafruit! |
Nels885 | 0:bf67af6b3913 | 13 | |
Nels885 | 0:bf67af6b3913 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. |
Nels885 | 0:bf67af6b3913 | 15 | BSD license, all text above must be included in any redistribution |
Nels885 | 0:bf67af6b3913 | 16 | ****************************************************/ |
Nels885 | 0:bf67af6b3913 | 17 | |
Nels885 | 0:bf67af6b3913 | 18 | /* |
Nels885 | 0:bf67af6b3913 | 19 | * Modified by Marc PLOUHINEC 27/06/2015 for use in mbed |
Nels885 | 0:bf67af6b3913 | 20 | * Modified by lionel VOIRIN 05/08/2018 for use Adafruit FONA 3G |
Nels885 | 0:bf67af6b3913 | 21 | */ |
Nels885 | 0:bf67af6b3913 | 22 | |
Nels885 | 0:bf67af6b3913 | 23 | #ifndef ADAFRUIT_FONA_H |
Nels885 | 0:bf67af6b3913 | 24 | #define ADAFRUIT_FONA_H |
Nels885 | 0:bf67af6b3913 | 25 | |
Nels885 | 0:bf67af6b3913 | 26 | #include "mbed.h" |
Nels885 | 0:bf67af6b3913 | 27 | |
Nels885 | 0:bf67af6b3913 | 28 | //#define ADAFRUIT_FONA_DEBUG |
Nels885 | 0:bf67af6b3913 | 29 | |
Nels885 | 0:bf67af6b3913 | 30 | #define FONA800L 1 |
Nels885 | 0:bf67af6b3913 | 31 | #define FONA800H 6 |
Nels885 | 0:bf67af6b3913 | 32 | |
Nels885 | 0:bf67af6b3913 | 33 | #define FONA808_V1 2 |
Nels885 | 0:bf67af6b3913 | 34 | #define FONA808_V2 3 |
Nels885 | 0:bf67af6b3913 | 35 | |
Nels885 | 0:bf67af6b3913 | 36 | #define FONA3G_A 4 |
Nels885 | 0:bf67af6b3913 | 37 | #define FONA3G_E 5 |
Nels885 | 0:bf67af6b3913 | 38 | |
Nels885 | 0:bf67af6b3913 | 39 | // Set the preferred SMS storage. |
Nels885 | 0:bf67af6b3913 | 40 | // Use "SM" for storage on the SIM. |
Nels885 | 0:bf67af6b3913 | 41 | // Use "ME" for internal storage on the FONA chip |
Nels885 | 0:bf67af6b3913 | 42 | #define FONA_PREF_SMS_STORAGE "\"SM\"" |
Nels885 | 0:bf67af6b3913 | 43 | //#define FONA_PREF_SMS_STORAGE "\"ME\"" |
Nels885 | 0:bf67af6b3913 | 44 | |
Nels885 | 0:bf67af6b3913 | 45 | #define FONA_HEADSETAUDIO 0 |
Nels885 | 0:bf67af6b3913 | 46 | #define FONA_EXTAUDIO 1 |
Nels885 | 0:bf67af6b3913 | 47 | |
Nels885 | 0:bf67af6b3913 | 48 | #define FONA_STTONE_DIALTONE 1 |
Nels885 | 0:bf67af6b3913 | 49 | #define FONA_STTONE_BUSY 2 |
Nels885 | 0:bf67af6b3913 | 50 | #define FONA_STTONE_CONGESTION 3 |
Nels885 | 0:bf67af6b3913 | 51 | #define FONA_STTONE_PATHACK 4 |
Nels885 | 0:bf67af6b3913 | 52 | #define FONA_STTONE_DROPPED 5 |
Nels885 | 0:bf67af6b3913 | 53 | #define FONA_STTONE_ERROR 6 |
Nels885 | 0:bf67af6b3913 | 54 | #define FONA_STTONE_CALLWAIT 7 |
Nels885 | 0:bf67af6b3913 | 55 | #define FONA_STTONE_RINGING 8 |
Nels885 | 0:bf67af6b3913 | 56 | #define FONA_STTONE_BEEP 16 |
Nels885 | 0:bf67af6b3913 | 57 | #define FONA_STTONE_POSTONE 17 |
Nels885 | 0:bf67af6b3913 | 58 | #define FONA_STTONE_ERRTONE 18 |
Nels885 | 0:bf67af6b3913 | 59 | #define FONA_STTONE_INDIANDIALTONE 19 |
Nels885 | 0:bf67af6b3913 | 60 | #define FONA_STTONE_USADIALTONE 20 |
Nels885 | 0:bf67af6b3913 | 61 | |
Nels885 | 0:bf67af6b3913 | 62 | #define FONA_DEFAULT_TIMEOUT_MS 500 |
Nels885 | 0:bf67af6b3913 | 63 | |
Nels885 | 0:bf67af6b3913 | 64 | #define FONA_HTTP_GET 0 |
Nels885 | 0:bf67af6b3913 | 65 | #define FONA_HTTP_POST 1 |
Nels885 | 0:bf67af6b3913 | 66 | #define FONA_HTTP_HEAD 2 |
Nels885 | 0:bf67af6b3913 | 67 | |
Nels885 | 0:bf67af6b3913 | 68 | #define FONA_CALL_READY 0 |
Nels885 | 0:bf67af6b3913 | 69 | #define FONA_CALL_FAILED 1 |
Nels885 | 0:bf67af6b3913 | 70 | #define FONA_CALL_UNKNOWN 2 |
Nels885 | 0:bf67af6b3913 | 71 | #define FONA_CALL_RINGING 3 |
Nels885 | 0:bf67af6b3913 | 72 | #define FONA_CALL_INPROGRESS 4 |
Nels885 | 0:bf67af6b3913 | 73 | |
Nels885 | 0:bf67af6b3913 | 74 | #define RX_BUFFER_SIZE 255 |
Nels885 | 0:bf67af6b3913 | 75 | |
Nels885 | 0:bf67af6b3913 | 76 | class Adafruit_FONA : public Stream |
Nels885 | 0:bf67af6b3913 | 77 | { |
Nels885 | 0:bf67af6b3913 | 78 | public: |
Nels885 | 0:bf67af6b3913 | 79 | /** |
Nels885 | 0:bf67af6b3913 | 80 | * Listener for FONA events. |
Nels885 | 0:bf67af6b3913 | 81 | */ |
Nels885 | 0:bf67af6b3913 | 82 | class EventListener |
Nels885 | 0:bf67af6b3913 | 83 | { |
Nels885 | 0:bf67af6b3913 | 84 | public: |
Nels885 | 0:bf67af6b3913 | 85 | /** |
Nels885 | 0:bf67af6b3913 | 86 | * Method called when somebody call the FONA. |
Nels885 | 0:bf67af6b3913 | 87 | */ |
Nels885 | 0:bf67af6b3913 | 88 | virtual void onRing() = 0; |
Nels885 | 0:bf67af6b3913 | 89 | |
Nels885 | 0:bf67af6b3913 | 90 | /** |
Nels885 | 0:bf67af6b3913 | 91 | * Method called when the calling person stop his call. |
Nels885 | 0:bf67af6b3913 | 92 | */ |
Nels885 | 0:bf67af6b3913 | 93 | virtual void onNoCarrier() = 0; |
Nels885 | 0:bf67af6b3913 | 94 | }; |
Nels885 | 0:bf67af6b3913 | 95 | |
Nels885 | 0:bf67af6b3913 | 96 | public: |
Nels885 | 5:79e4c91f2b73 | 97 | Adafruit_FONA(PinName tx, PinName rx, PinName rst, PinName key); |
Nels885 | 0:bf67af6b3913 | 98 | bool begin(int baudrate); |
Nels885 | 0:bf67af6b3913 | 99 | uint8_t type(); |
Nels885 | 5:79e4c91f2b73 | 100 | void powerOn(); |
Nels885 | 5:79e4c91f2b73 | 101 | void powerOff(); |
Nels885 | 0:bf67af6b3913 | 102 | void setEventListener(EventListener *eventListener); |
Nels885 | 0:bf67af6b3913 | 103 | |
Nels885 | 0:bf67af6b3913 | 104 | // Stream |
Nels885 | 0:bf67af6b3913 | 105 | virtual int _putc(int value); |
Nels885 | 0:bf67af6b3913 | 106 | virtual int _getc(); |
Nels885 | 0:bf67af6b3913 | 107 | int readable(); |
Nels885 | 0:bf67af6b3913 | 108 | |
Nels885 | 0:bf67af6b3913 | 109 | // FONA 3G requirements |
Nels885 | 10:7951d9691cb2 | 110 | bool getBaudrate(uint32_t *baud); |
Nels885 | 10:7951d9691cb2 | 111 | bool setBaudrate(uint32_t baud); |
Nels885 | 0:bf67af6b3913 | 112 | |
Nels885 | 0:bf67af6b3913 | 113 | // RTC |
Nels885 | 0:bf67af6b3913 | 114 | bool enableRTC(uint8_t i); // i = 0 <=> disable, i = 1 <=> enable |
Nels885 | 0:bf67af6b3913 | 115 | |
Nels885 | 0:bf67af6b3913 | 116 | // Battery and ADC |
Nels885 | 0:bf67af6b3913 | 117 | bool getADCVoltage(uint16_t *v); |
Nels885 | 0:bf67af6b3913 | 118 | bool getBattPercent(uint16_t *p); |
Nels885 | 0:bf67af6b3913 | 119 | bool getBattVoltage(uint16_t *v); |
Nels885 | 0:bf67af6b3913 | 120 | |
Nels885 | 0:bf67af6b3913 | 121 | // SIM query |
Nels885 | 0:bf67af6b3913 | 122 | uint8_t unlockSIM(char *pin); |
Nels885 | 0:bf67af6b3913 | 123 | uint8_t getSIMCCID(char *ccid); |
Nels885 | 0:bf67af6b3913 | 124 | uint8_t getNetworkStatus(void); |
Nels885 | 0:bf67af6b3913 | 125 | uint8_t getRSSI(void); |
Nels885 | 0:bf67af6b3913 | 126 | |
Nels885 | 0:bf67af6b3913 | 127 | // IMEI |
Nels885 | 0:bf67af6b3913 | 128 | uint8_t getIMEI(char *imei); |
Nels885 | 0:bf67af6b3913 | 129 | |
Nels885 | 0:bf67af6b3913 | 130 | // set Audio output |
Nels885 | 0:bf67af6b3913 | 131 | bool setAudio(uint8_t a); |
Nels885 | 0:bf67af6b3913 | 132 | bool setVolume(uint8_t i); |
Nels885 | 0:bf67af6b3913 | 133 | uint8_t getVolume(void); |
Nels885 | 0:bf67af6b3913 | 134 | bool playToolkitTone(uint8_t t, uint16_t len); |
Nels885 | 0:bf67af6b3913 | 135 | bool setMicVolume(uint8_t a, uint8_t level); |
Nels885 | 0:bf67af6b3913 | 136 | bool playDTMF(char tone); |
Nels885 | 0:bf67af6b3913 | 137 | |
Nels885 | 0:bf67af6b3913 | 138 | // FM radio functions |
Nels885 | 0:bf67af6b3913 | 139 | bool tuneFMradio(uint16_t station); |
Nels885 | 0:bf67af6b3913 | 140 | bool FMradio(bool onoff, uint8_t a = FONA_HEADSETAUDIO); |
Nels885 | 0:bf67af6b3913 | 141 | bool setFMVolume(uint8_t i); |
Nels885 | 0:bf67af6b3913 | 142 | int8_t getFMVolume(); |
Nels885 | 0:bf67af6b3913 | 143 | int8_t getFMSignalLevel(uint16_t station); |
Nels885 | 0:bf67af6b3913 | 144 | |
Nels885 | 0:bf67af6b3913 | 145 | // SMS handling |
Nels885 | 0:bf67af6b3913 | 146 | bool setSMSInterrupt(uint8_t i); |
Nels885 | 0:bf67af6b3913 | 147 | uint8_t getSMSInterrupt(void); |
Nels885 | 0:bf67af6b3913 | 148 | int8_t getNumSMS(void); |
Nels885 | 0:bf67af6b3913 | 149 | bool readSMS(uint8_t i, char *smsbuff, uint16_t max, uint16_t *readsize); |
Nels885 | 0:bf67af6b3913 | 150 | bool sendSMS(char *smsaddr, char *smsmsg); |
Nels885 | 0:bf67af6b3913 | 151 | bool deleteSMS(uint8_t i); |
Nels885 | 0:bf67af6b3913 | 152 | bool getSMSSender(uint8_t i, char *sender, int senderlen); |
Nels885 | 0:bf67af6b3913 | 153 | |
Nels885 | 0:bf67af6b3913 | 154 | // Time |
Nels885 | 0:bf67af6b3913 | 155 | bool enableNetworkTimeSync(bool onoff); |
Nels885 | 0:bf67af6b3913 | 156 | bool enableNTPTimeSync(bool onoff, const char* ntpserver=0); |
Nels885 | 0:bf67af6b3913 | 157 | bool getTime(char* buff, uint16_t maxlen); |
Nels885 | 0:bf67af6b3913 | 158 | |
Nels885 | 0:bf67af6b3913 | 159 | // GPRS handling |
Nels885 | 0:bf67af6b3913 | 160 | bool enableGPRS(bool onoff); |
Nels885 | 9:b18cfba4283a | 161 | int GPRSstate(void); |
Nels885 | 0:bf67af6b3913 | 162 | bool getGSMLoc(uint16_t *replycode, char *buff, uint16_t maxlen); |
Nels885 | 0:bf67af6b3913 | 163 | bool getGSMLoc(float *lat, float *lon); |
Nels885 | 0:bf67af6b3913 | 164 | void setGPRSNetworkSettings(const char* apn, const char* username=0, const char* password=0); |
Nels885 | 0:bf67af6b3913 | 165 | |
Nels885 | 0:bf67af6b3913 | 166 | // GPS handling |
Nels885 | 0:bf67af6b3913 | 167 | bool enableGPS(bool onoff); |
Nels885 | 0:bf67af6b3913 | 168 | int8_t GPSstatus(void); |
Nels885 | 0:bf67af6b3913 | 169 | uint8_t getGPS(uint8_t arg, char *buffer, uint8_t maxbuff); |
Nels885 | 0:bf67af6b3913 | 170 | bool getGPS(float *lat, float *lon, float *speed_kph=0, float *heading=0, float *altitude=0); |
Nels885 | 0:bf67af6b3913 | 171 | bool enableGPSNMEA(uint8_t nmea); |
Nels885 | 0:bf67af6b3913 | 172 | |
Nels885 | 0:bf67af6b3913 | 173 | // TCP raw connections |
Nels885 | 0:bf67af6b3913 | 174 | bool TCPconnect(char *server, uint16_t port); |
Nels885 | 4:05c32425d2da | 175 | uint8_t getIPADDR(char *ipaddr); |
Nels885 | 0:bf67af6b3913 | 176 | bool TCPclose(void); |
Nels885 | 0:bf67af6b3913 | 177 | bool TCPconnected(void); |
Nels885 | 0:bf67af6b3913 | 178 | bool TCPsend(char *packet, uint8_t len); |
Nels885 | 0:bf67af6b3913 | 179 | uint16_t TCPavailable(void); |
Nels885 | 0:bf67af6b3913 | 180 | uint16_t TCPread(uint8_t *buff, uint8_t len); |
Nels885 | 0:bf67af6b3913 | 181 | |
Nels885 | 0:bf67af6b3913 | 182 | // HTTP low level interface (maps directly to SIM800 commands). |
Nels885 | 0:bf67af6b3913 | 183 | bool HTTP_init(); |
Nels885 | 0:bf67af6b3913 | 184 | bool HTTP_term(); |
Nels885 | 0:bf67af6b3913 | 185 | void HTTP_para_start(const char* parameter, bool quoted = true); |
Nels885 | 0:bf67af6b3913 | 186 | bool HTTP_para_end(bool quoted = true); |
Nels885 | 0:bf67af6b3913 | 187 | bool HTTP_para(const char* parameter, const char *value); |
Nels885 | 0:bf67af6b3913 | 188 | bool HTTP_para(const char* parameter, int32_t value); |
Nels885 | 0:bf67af6b3913 | 189 | bool HTTP_data(uint32_t size, uint32_t maxTime=10000); |
Nels885 | 0:bf67af6b3913 | 190 | bool HTTP_action(uint8_t method, uint16_t *status, uint16_t *datalen, int32_t timeout = 10000); |
Nels885 | 0:bf67af6b3913 | 191 | bool HTTP_readall(uint16_t *datalen); |
Nels885 | 0:bf67af6b3913 | 192 | bool HTTP_ssl(bool onoff); |
Nels885 | 0:bf67af6b3913 | 193 | |
Nels885 | 0:bf67af6b3913 | 194 | // HTTP high level interface (easier to use, less flexible). |
Nels885 | 0:bf67af6b3913 | 195 | bool HTTP_GET_start(char *url, uint16_t *status, uint16_t *datalen); |
Nels885 | 0:bf67af6b3913 | 196 | void HTTP_GET_end(void); |
Nels885 | 0:bf67af6b3913 | 197 | bool HTTP_POST_start(char *url, const char* contenttype, const uint8_t *postdata, uint16_t postdatalen, uint16_t *status, uint16_t *datalen); |
Nels885 | 0:bf67af6b3913 | 198 | void HTTP_POST_end(void); |
Nels885 | 0:bf67af6b3913 | 199 | void setUserAgent(const char* useragent); |
Nels885 | 0:bf67af6b3913 | 200 | |
Nels885 | 0:bf67af6b3913 | 201 | // HTTPS |
Nels885 | 0:bf67af6b3913 | 202 | void setHTTPSRedirect(bool onoff); |
Nels885 | 0:bf67af6b3913 | 203 | |
Nels885 | 0:bf67af6b3913 | 204 | // PWM (buzzer) |
Nels885 | 0:bf67af6b3913 | 205 | bool setPWM(uint16_t period, uint8_t duty = 50); |
Nels885 | 0:bf67af6b3913 | 206 | |
Nels885 | 0:bf67af6b3913 | 207 | // Phone calls |
Nels885 | 0:bf67af6b3913 | 208 | bool callPhone(char *phonenum); |
Nels885 | 0:bf67af6b3913 | 209 | bool hangUp(void); |
Nels885 | 0:bf67af6b3913 | 210 | bool pickUp(void); |
Nels885 | 0:bf67af6b3913 | 211 | bool callerIdNotification(bool enable); |
Nels885 | 0:bf67af6b3913 | 212 | bool incomingCallNumber(char* phonenum); |
Nels885 | 0:bf67af6b3913 | 213 | |
Nels885 | 0:bf67af6b3913 | 214 | // Helper functions to verify responses. |
Nels885 | 0:bf67af6b3913 | 215 | bool expectReply(const char* reply, uint16_t timeout = 10000); |
Nels885 | 0:bf67af6b3913 | 216 | |
Nels885 | 0:bf67af6b3913 | 217 | protected: |
Nels885 | 5:79e4c91f2b73 | 218 | DigitalOut _keypin; |
Nels885 | 0:bf67af6b3913 | 219 | DigitalOut _rstpin; |
Nels885 | 0:bf67af6b3913 | 220 | uint8_t _type; |
Nels885 | 0:bf67af6b3913 | 221 | |
Nels885 | 0:bf67af6b3913 | 222 | char replybuffer[255]; |
Nels885 | 0:bf67af6b3913 | 223 | char* apn; |
Nels885 | 0:bf67af6b3913 | 224 | char* apnusername; |
Nels885 | 0:bf67af6b3913 | 225 | char* apnpassword; |
Nels885 | 0:bf67af6b3913 | 226 | bool httpsredirect; |
Nels885 | 0:bf67af6b3913 | 227 | char* useragent; |
Nels885 | 0:bf67af6b3913 | 228 | char* ok_reply; |
Nels885 | 0:bf67af6b3913 | 229 | |
Nels885 | 0:bf67af6b3913 | 230 | volatile bool _incomingCall; |
Nels885 | 0:bf67af6b3913 | 231 | EventListener *eventListener; |
Nels885 | 0:bf67af6b3913 | 232 | Serial mySerial; |
Nels885 | 0:bf67af6b3913 | 233 | |
Nels885 | 0:bf67af6b3913 | 234 | // Circular buffer used to receive serial data from an interruption |
Nels885 | 0:bf67af6b3913 | 235 | int rxBuffer[RX_BUFFER_SIZE + 1]; |
Nels885 | 0:bf67af6b3913 | 236 | volatile int rxBufferInIndex; // Index where new data is added to the buffer |
Nels885 | 0:bf67af6b3913 | 237 | volatile int rxBufferOutIndex; // Index where data is removed from the buffer |
Nels885 | 0:bf67af6b3913 | 238 | char currentReceivedLine[RX_BUFFER_SIZE]; // Array containing the current received line |
Nels885 | 0:bf67af6b3913 | 239 | int currentReceivedLineSize; |
Nels885 | 0:bf67af6b3913 | 240 | |
Nels885 | 0:bf67af6b3913 | 241 | inline bool isRxBufferFull() { |
Nels885 | 0:bf67af6b3913 | 242 | return ((rxBufferInIndex + 1) % RX_BUFFER_SIZE) == rxBufferOutIndex; |
Nels885 | 0:bf67af6b3913 | 243 | } |
Nels885 | 0:bf67af6b3913 | 244 | |
Nels885 | 0:bf67af6b3913 | 245 | inline bool isRxBufferEmpty() { |
Nels885 | 0:bf67af6b3913 | 246 | return rxBufferInIndex == rxBufferOutIndex; |
Nels885 | 0:bf67af6b3913 | 247 | } |
Nels885 | 0:bf67af6b3913 | 248 | |
Nels885 | 0:bf67af6b3913 | 249 | inline void incrementRxBufferInIndex() { |
Nels885 | 0:bf67af6b3913 | 250 | rxBufferInIndex = (rxBufferInIndex + 1) % RX_BUFFER_SIZE; |
Nels885 | 0:bf67af6b3913 | 251 | } |
Nels885 | 0:bf67af6b3913 | 252 | |
Nels885 | 0:bf67af6b3913 | 253 | inline void incrementRxBufferOutIndex() { |
Nels885 | 0:bf67af6b3913 | 254 | rxBufferOutIndex = (rxBufferOutIndex + 1) % RX_BUFFER_SIZE; |
Nels885 | 0:bf67af6b3913 | 255 | } |
Nels885 | 0:bf67af6b3913 | 256 | |
Nels885 | 0:bf67af6b3913 | 257 | /** |
Nels885 | 0:bf67af6b3913 | 258 | * Method called when Serial data is received (interrupt routine). |
Nels885 | 0:bf67af6b3913 | 259 | */ |
Nels885 | 0:bf67af6b3913 | 260 | void onSerialDataReceived(); |
Nels885 | 0:bf67af6b3913 | 261 | |
Nels885 | 0:bf67af6b3913 | 262 | // HTTP helpers |
Nels885 | 0:bf67af6b3913 | 263 | bool HTTP_setup(char *url); |
Nels885 | 0:bf67af6b3913 | 264 | |
Nels885 | 0:bf67af6b3913 | 265 | void flushInput(); |
Nels885 | 0:bf67af6b3913 | 266 | uint16_t readRaw(uint16_t b); |
Nels885 | 0:bf67af6b3913 | 267 | uint8_t readline(uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS, bool multiline = false); |
Nels885 | 0:bf67af6b3913 | 268 | uint8_t getReply(const char* send, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
Nels885 | 0:bf67af6b3913 | 269 | uint8_t getReply(const char* prefix, char *suffix, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
Nels885 | 0:bf67af6b3913 | 270 | uint8_t getReply(const char* prefix, int32_t suffix, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
Nels885 | 0:bf67af6b3913 | 271 | 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. |
Nels885 | 0:bf67af6b3913 | 272 | uint8_t getReplyQuoted(const char* prefix, const char* suffix, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
Nels885 | 0:bf67af6b3913 | 273 | |
Nels885 | 0:bf67af6b3913 | 274 | bool sendCheckReply(const char* send, const char* reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
Nels885 | 0:bf67af6b3913 | 275 | bool sendCheckReply(const char* prefix, char *suffix, const char* reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
Nels885 | 0:bf67af6b3913 | 276 | bool sendCheckReply(const char* prefix, int32_t suffix, const char* reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
Nels885 | 0:bf67af6b3913 | 277 | bool sendCheckReply(const char* prefix, int32_t suffix, int32_t suffix2, const char* reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
Nels885 | 0:bf67af6b3913 | 278 | bool sendCheckReplyQuoted(const char* prefix, const char* suffix, const char* reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS); |
Nels885 | 0:bf67af6b3913 | 279 | |
Nels885 | 10:7951d9691cb2 | 280 | bool parseReply(const char* toreply, uint32_t *v, char divider = ',', uint8_t index=0); |
Nels885 | 10:7951d9691cb2 | 281 | bool parseReply(const char* toreply, uint16_t *v, char divider = ',', uint8_t index=0); |
Nels885 | 10:7951d9691cb2 | 282 | bool parseReply(const char* toreply, char *v, char divider = ',', uint8_t index=0); |
Nels885 | 0:bf67af6b3913 | 283 | bool parseReplyQuoted(const char* toreply, char* v, int maxlen, char divider, uint8_t index); |
Nels885 | 0:bf67af6b3913 | 284 | |
Nels885 | 10:7951d9691cb2 | 285 | bool sendParseReply(const char* tosend, const char* toreply, uint32_t *v, char divider = ',', uint8_t index = 0); |
Nels885 | 0:bf67af6b3913 | 286 | bool sendParseReply(const char* tosend, const char* toreply, uint16_t *v, char divider = ',', uint8_t index = 0); |
Nels885 | 0:bf67af6b3913 | 287 | |
Nels885 | 0:bf67af6b3913 | 288 | void onIncomingCall(); |
Nels885 | 0:bf67af6b3913 | 289 | }; |
Nels885 | 0:bf67af6b3913 | 290 | |
Nels885 | 0:bf67af6b3913 | 291 | class Adafruit_FONA_3G : public Adafruit_FONA |
Nels885 | 0:bf67af6b3913 | 292 | { |
Nels885 | 0:bf67af6b3913 | 293 | public: |
Nels885 | 5:79e4c91f2b73 | 294 | Adafruit_FONA_3G(PinName tx, PinName rx, PinName rst, PinName key) : Adafruit_FONA(tx, rx, rst, key) { |
Nels885 | 0:bf67af6b3913 | 295 | _type = FONA3G_A; |
Nels885 | 0:bf67af6b3913 | 296 | } |
Nels885 | 0:bf67af6b3913 | 297 | |
Nels885 | 0:bf67af6b3913 | 298 | bool getBattVoltage(uint16_t *v); |
Nels885 | 0:bf67af6b3913 | 299 | bool hangUp(void); |
Nels885 | 0:bf67af6b3913 | 300 | bool pickUp(void); |
Nels885 | 0:bf67af6b3913 | 301 | bool enableGPS(bool onoff); |
Nels885 | 2:3fc229f5ec3f | 302 | |
Nels885 | 9:b18cfba4283a | 303 | // SIM query |
Nels885 | 9:b18cfba4283a | 304 | uint8_t unlockSIM(char *pin); |
Nels885 | 9:b18cfba4283a | 305 | |
Nels885 | 2:3fc229f5ec3f | 306 | // TCP raw connections |
Nels885 | 2:3fc229f5ec3f | 307 | uint8_t TCPinitialize(void); |
Nels885 | 9:b18cfba4283a | 308 | uint8_t sslTCPinitialize(void); |
Nels885 | 4:05c32425d2da | 309 | uint8_t getTCPtimeout(char *tcptimeout); |
Nels885 | 2:3fc229f5ec3f | 310 | bool TCPconnect(char *server, uint16_t port); |
Nels885 | 6:8fdb30dc3108 | 311 | bool sslTCPconnect(char *server, uint16_t port); |
Nels885 | 2:3fc229f5ec3f | 312 | bool TCPclose(void); |
Nels885 | 6:8fdb30dc3108 | 313 | bool sslTCPclose(void); |
Nels885 | 4:05c32425d2da | 314 | bool TCPsend(char *packet); |
Nels885 | 9:b18cfba4283a | 315 | bool sslTCPsend(char *packet); |
Nels885 | 10:7951d9691cb2 | 316 | uint16_t sslTCPread(char *buff); |
Nels885 | 0:bf67af6b3913 | 317 | |
Nels885 | 0:bf67af6b3913 | 318 | protected: |
Nels885 | 0:bf67af6b3913 | 319 | bool sendParseReply(const char* tosend, const char* toreply, float *f, char divider, uint8_t index); |
Nels885 | 10:7951d9691cb2 | 320 | bool parseReply(const char* toreply, uint16_t *v, char divider = ',', uint8_t index=0); |
Nels885 | 9:b18cfba4283a | 321 | bool parseReply(const char* toreply, float *f, char divider, uint8_t index=0); |
Nels885 | 0:bf67af6b3913 | 322 | }; |
Nels885 | 0:bf67af6b3913 | 323 | |
Nels885 | 0:bf67af6b3913 | 324 | #endif |