00001 /*! \file WaspGPRS.h 00002 \brief Library for managing the GPRS module 00003 00004 Copyright (C) 2009 Libelium Comunicaciones Distribuidas S.L. 00005 http://www.libelium.com 00006 00007 This program is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU Lesser General Public License as published by 00009 the Free Software Foundation, either version 2.1 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 00020 Version: 0.6 00021 00022 Design: David Gascón 00023 00024 Implementation: Alberto Bielsa, David Cuartielles 00025 00026 */ 00027 00028 /*! \def WaspGPRS_h 00029 \brief The library flag 00030 00031 */ 00032 #ifndef WaspGPRS_h 00033 #define WaspGPRS_h 00034 00035 /****************************************************************************** 00036 * Includes 00037 ******************************************************************************/ 00038 00039 #include <inttypes.h> 00040 00041 /****************************************************************************** 00042 * Definitions & Declarations 00043 ******************************************************************************/ 00044 00045 /*! \def GPRS_ON 00046 \brief Working mode. ON in this case 00047 */ 00048 #define GPRS_ON 0 00049 00050 /*! \def GPRS_SLEEP 00051 \brief Working mode. SLEEP in this case 00052 */ 00053 #define GPRS_SLEEP 1 00054 00055 /*! \def GPRS_HIBERNATE 00056 \brief Working mode. HIBERNATE in this case 00057 */ 00058 #define GPRS_HIBERNATE 2 00059 00060 /*! \def GPRS_ERROR_POWER 00061 \brief Flag Value. Error while powering in this case 00062 */ 00063 #define GPRS_ERROR_POWER 1 00064 00065 /*! \def GPRS_ERROR_CALL 00066 \brief Flag Value. Error while calling in this case 00067 */ 00068 #define GPRS_ERROR_CALL 2 00069 00070 /*! \def GPRS_ERROR_HANG 00071 \brief Flag Value. Error while hanging up in this case 00072 */ 00073 #define GPRS_ERROR_HANG 4 00074 00075 /*! \def GPRS_ERROR_SMS 00076 \brief Flag Value. Error while sending a SMS in this case 00077 */ 00078 #define GPRS_ERROR_SMS 8 00079 00080 /*! \def GPRS_ERROR_PIN 00081 \brief Flag Value. Error while setting PIN in this case 00082 */ 00083 #define GPRS_ERROR_PIN 16 00084 00085 /*! \def GPRS_ERROR_CALLINFO 00086 \brief Flag Value. Error while setting call info in this case 00087 */ 00088 #define GPRS_ERROR_CALLINFO 32 00089 00090 /*! \def GPRS_ERROR_SMSINFO 00091 \brief Flag Value. Error while setting SMS info in this case 00092 */ 00093 #define GPRS_ERROR_SMSINFO 64 00094 00095 /*! \def GPRS_ERROR_CONF 00096 \brief Flag Value. Error while configuring GPRS connection in this case 00097 */ 00098 #define GPRS_ERROR_CONF 128 00099 00100 /*! \def GPRS_ERROR_PATTERN 00101 \brief Flag Value. Error while setting pattern in this case 00102 */ 00103 #define GPRS_ERROR_PATTERN 256 00104 00105 /*! \def GPRS_ERROR_TIMER 00106 \brief Flag Value. Error while setting timer in this case 00107 */ 00108 #define GPRS_ERROR_TIMER 512 00109 00110 /*! \def GPRS_ERROR_PROFILE 00111 \brief Flag Value. Error while setting profile in this case 00112 */ 00113 #define GPRS_ERROR_PROFILE 1024 00114 00115 /*! \def GPRS_ERROR_SOCKET 00116 \brief Flag Value. Error while opening a socket in this case 00117 */ 00118 #define GPRS_ERROR_SOCKET 2048 00119 00120 /*! \def GPRS_ERROR_CHECK 00121 \brief Flag Value. Error while checking connection in this case 00122 */ 00123 #define GPRS_ERROR_CHECK 4096 00124 00125 /*! \def GPRS_ERROR_CLOSE 00126 \brief Flag Value. Error while closing a socket in this case 00127 */ 00128 #define GPRS_ERROR_CLOSE 8192 00129 00130 /*! \def GPRS_ERROR_SMTP 00131 \brief Flag Value. Error while using SMTP 00132 */ 00133 #define GPRS_ERROR_SMTP 16384 00134 00135 /*! \def GPRS_RATE 00136 \brief GPRS Baud Rate 00137 */ 00138 #define GPRS_RATE 38400 00139 00140 /*! \def DELAY_ON_SEND 00141 \brief Constants for AT commands. Delay after every sending attempt in this case 00142 */ 00143 #define DELAY_ON_SEND 1500 00144 00145 /*! \def DEFAULT_TIMEOUT 00146 \brief Constants for AT commands. Default attempts to try in this case 00147 */ 00148 #define DEFAULT_TIMEOUT 10 00149 00150 /*! \def SEND_ONCE 00151 \brief Constants for AT commands. Sending only once in this case 00152 */ 00153 #define SEND_ONCE 1 00154 00155 /*! \def PORT_USED 00156 \brief Constants for AT commands. Port used in AT commands functions in this case 00157 */ 00158 #define PORT_USED 1 00159 00160 /*! \def GPRS_CLIENT 00161 \brief When opening a socket, it can be opened as client or server. Client in this case 00162 */ 00163 #define GPRS_CLIENT 0 00164 00165 /*! \def GPRS_SERVER 00166 \brief When opening a socket, it can be opened as client or server. Server in this case 00167 */ 00168 #define GPRS_SERVER 1 00169 00170 /*! \def GPRS_DATA_LENGTH 00171 \brief Maximum data length expressed as a string 00172 */ 00173 #define GPRS_DATA_LENGTH "100" 00174 00175 /*! \def GPRS_DATA_LENGTH_U 00176 \brief Maximum data length expressed as an integer 00177 */ 00178 #define GPRS_DATA_LENGTH_U 100 00179 00180 /*! \def GPRS_MAX_DATA 00181 \brief Maximum data length 00182 */ 00183 #define GPRS_MAX_DATA 100 00184 00185 /****************************************************************************** 00186 * Class 00187 ******************************************************************************/ 00188 00189 //! WaspGPRS Class 00190 /*! 00191 WaspGPRS Class defines all the variables and functions used to manage GPRS module 00192 */ 00193 class WaspGPRS 00194 { 00195 private: 00196 00197 //! It sets the pattern for using in sending and receiving messages 00198 /*! 00199 \param const char* pattern : pattern to set 00200 \return '1' on success, '0' if error 00201 \sa setConnectionTimer(), setConnectionProfile() 00202 */ 00203 uint8_t setPattern(const char* pattern); 00204 00205 //! It sets the GPRS connection time out 00206 /*! 00207 It gets the timer from 'WaspGPRSconstants.h' file 00208 \param void 00209 \return '1' on success, '0' if error 00210 \sa setPattern(const char* pattern), setConnectionProfile() 00211 */ 00212 uint8_t setConnectionTimer(); 00213 00214 //! It sets the GPRS connection profile 00215 /*! 00216 It gets the profile from 'WaspGPRSconstants.h' file 00217 \param void 00218 \return '1' on success, '0' if error 00219 \sa setPattern(const char* pattern), setConnectionTimer() 00220 */ 00221 uint8_t setConnectionProfile(); 00222 00223 //! It sets GPRS flow control 00224 /*! 00225 It gets the flow control from 'WaspGPRSconstants.h' file 00226 \param void 00227 \return '1' on success, '0' if error 00228 \sa setPattern(const char* pattern), setConnectionTimer() 00229 */ 00230 uint8_t setFlowControl(); 00231 00232 //! It checks if GPRS connection is OK 00233 /*! 00234 \param void 00235 \return '1' on success, '0' if error 00236 */ 00237 uint8_t checkGPRS(); 00238 00239 //! It writes data to send via GPRS socket 00240 /*! 00241 \param const char* data : data to send via socket 00242 \return '1' on success, '0' if error 00243 */ 00244 uint8_t writeData(const char* data); 00245 00246 //! It parses GSM string and specifies if it is a call or a SMS 00247 /*! 00248 \param const char* data : string to parse 00249 \return '0' on GSM incoming call, '1' on GSM incoming SMS, '2' if error 00250 */ 00251 uint8_t parse_GSM(char* data); 00252 00253 //! It sets the email parameters 00254 /*! 00255 \param char* smtp_server : smtp server address 00256 \param uint16_t port : smtp server port 00257 \param char* to : origin or user address 00258 \return '1' on success and '0' if error 00259 */ 00260 uint8_t setEmailParams(char* smtp_server, uint16_t port, char* to); 00261 00262 //! It sets the email user and password 00263 /*! 00264 \param char* user : email user 00265 \param char* pwd : email password 00266 \return '1' on success and '0' if error 00267 */ 00268 uint8_t setEmailPwd(char* user, char* pwd); 00269 00270 //! It sets the email destination 00271 /*! 00272 \param char* destination : email destination 00273 \return '1' on success and '0' if error 00274 */ 00275 uint8_t setEmailDestination(char* destination); 00276 00277 //! It sets the email subject 00278 /*! 00279 \param char* subject : email subject 00280 \return '1' on success and '0' if error 00281 */ 00282 uint8_t setEmailSubject(char* subject); 00283 00284 //! It gets if GPRS module is ready or not 00285 /*! 00286 \return nothing. It changes the value of 'not_ready' 00287 */ 00288 void getIfReady(); 00289 00290 //! Variable : stores if the module is ready or not (1:not ready, 0:ready) 00291 /*! 00292 */ 00293 uint8_t not_ready; 00294 00295 //! Variable : array for storing part of the data to send to the module 00296 /*! 00297 */ 00298 char theCommand[100]; 00299 00300 //! Variable : array for storing part of the data to send to the module 00301 /*! 00302 */ 00303 char theEnd[10]; 00304 00305 //! Variable : array for storing the data received from the module 00306 /*! 00307 */ 00308 char received[100]; 00309 00310 //! It sends an AT command to the module 00311 /*! 00312 \param char* ATcommand : string to send to the module 00313 \param char* expectedAnswer : string expected to be answered by the module 00314 \return '1' on success, '0' if error 00315 */ 00316 byte sendATCommand(char* ATcommand, char* expectedAnswer); 00317 00318 //! It sends an AT command to the module 00319 /*! 00320 \param char* ATcommand : string to send to the module 00321 \param char* expectedAnswer : string expected to be answered by the module 00322 \param int sendOnce : specifies if the data is sent once 00323 \return '1' on success, '0' if error 00324 */ 00325 byte sendATCommand(char* ATcommand, char* expectedAnswer, int sendOnce); 00326 00327 //! It sends an AT command to the module 00328 /*! 00329 \param char* theText : string to send to the module 00330 \param int endOfCommand : integer to send to the module 00331 \param char* expectedAnswer : string expected to be answered by the module 00332 \return '1' on success, '0' if error 00333 */ 00334 byte sendCommand(char* theText, int endOfCommand, char* expectedAnswer); 00335 00336 //! It sends an AT command to the module 00337 /*! 00338 \param char* theText : string to send to the module 00339 \param int endOfCommand : integer to send to the module 00340 \param char* expectedAnswer : string expected to be answered by the module 00341 \param int MAX_TIMEOUT : specifies the maximum timeout 00342 \param int sendOnce : specifies if the data is sent once 00343 \return '1' on success, '0' if error 00344 */ 00345 byte sendCommand(char* theText, int endOfCommand, char* expectedAnswer, int MAX_TIMEOUT, int sendOnce); 00346 00347 //! It sends an AT command to the module 00348 /*! 00349 \param char* theText : string to send to the module 00350 \param int endOfCommand : integer to send to the module 00351 \param char* expectedAnswer : string expected to be answered by the module 00352 \param int sendOnce : specifies if the data is sent once 00353 \return '1' on success, '0' if error 00354 */ 00355 byte sendCommand(char* theText, int endOfCommand, char* expectedAnswer, int sendOnce); 00356 00357 //! It sends an AT command to the module 00358 /*! 00359 \param char* theText : string to send to the module 00360 \param char endOfCommand : character to send to the module 00361 \param char* expectedAnswer : string expected to be answered by the module 00362 \return '1' on success, '0' if error 00363 */ 00364 byte sendCommand(char* theText, char endOfCommand, char* expectedAnswer); 00365 00366 //! It sends an AT command to the module 00367 /*! 00368 \param char* theText : string to send to the module 00369 \param char endOfCommand : character to send to the module 00370 \param char* expectedAnswer : string expected to be answered by the module 00371 \param int MAX_TIMEOUT : specifies the maximum timeout 00372 \return '1' on success, '0' if error 00373 */ 00374 byte sendCommand(char* theText, char endOfCommand, char* expectedAnswer, int MAX_TIMEOUT); 00375 00376 //! It sends an AT command to the module 00377 /*! 00378 \param char* theText : string to send to the module 00379 \param char endOfCommand : character to send to the module 00380 \param char* expectedAnswer : string expected to be answered by the module 00381 \param int MAX_TIMEOUT : specifies the maximum timeout 00382 \param int sendOnce : specifies if the data is sent once 00383 \return '1' on success, '0' if error 00384 */ 00385 byte sendCommand(char* theText, char endOfCommand, char* expectedAnswer, int MAX_TIMEOUT, int sendOnce); 00386 00387 //! It sends an AT command to the module 00388 /*! 00389 \param char* theText : string to send to the module 00390 \param char* endOfCommand : string to send to the module 00391 \param char* expectedAnswer : string expected to be answered by the module 00392 \return '1' on success, '0' if error 00393 */ 00394 byte sendCommand(char* theText, char* endOfCommand, char* expectedAnswer); 00395 00396 //! It sends an AT command to the module 00397 /*! 00398 \param char* theText : string to send to the module 00399 \param char* endOfCommand : string to send to the module 00400 \param char* expectedAnswer : string expected to be answered by the module 00401 \param int sendOnce : specifies if the data is sent once 00402 \return '1' on success, '0' if error 00403 */ 00404 byte sendCommand(char* theText, char* endOfCommand, char* expectedAnswer, int sendOnce); 00405 00406 //! It sends an AT command to the module 00407 /*! 00408 \param char* theText : string to send to the module 00409 \param char* endOfCommand : string to send to the module 00410 \param char* expectedAnswer : string expected to be answered by the module 00411 \param int MAX_TIMEOUT : specifies the maximum timeout 00412 \param int sendOnce : specifies if the data is sent once 00413 \return '1' on success, '0' if error 00414 */ 00415 byte sendCommand(char* theText, char* endOfCommand, char* expectedAnswer, int MAX_TIMEOUT, int sendOnce); 00416 00417 //! It waits for data from the module 00418 /*! 00419 \param char* expectedAnswer : string expected to be answered by the module 00420 \param int MAX_TIMEOUT : specifies the maximum timeout 00421 \param int timeout : specifies the timeout 00422 \param int seconds : specifies the number of seconds to wait before listening to the module 00423 \return '1' on success, '0' if error 00424 */ 00425 byte waitForData(char* expectedAnswer, int MAX_TIMEOUT, int timeout, int seconds); 00426 00427 //! It waits for data from the module 00428 /*! 00429 \param char* data : data where the 'expectedAnswer' has to be found 00430 \param char* expectedAnswer : string expected to be answered by the module 00431 \return '1' on success, '0' if error 00432 */ 00433 uint16_t waitForData(char* data, char* expectedAnswer); 00434 00435 //! It sends data via FTP 00436 /*! 00437 \param char* file : file to upload 00438 \param char* path : path within SD card to find the file to upload 00439 \param uint8_t id : ftp session id 00440 \return '1' on success, '0' if error 00441 */ 00442 uint8_t sendDataFTP(char* file, char* path, uint8_t id); 00443 00444 //! It reads data via FTP 00445 /*! 00446 \param char* file : file to download 00447 \param char* path : path within SD card to store the file to download 00448 \param uint8_t id : ftp session id 00449 \return '1' on success, '0' if error 00450 */ 00451 uint8_t readDataFTP(char* file, char* path, uint8_t id); 00452 00453 00454 00455 00456 public: 00457 00458 //! Variable : status flag, used to see if there was an error while communicating with the module 00459 /*! 00460 Possible values are : GPRS_ERROR_POWER, GPRS_ERROR_CALL, GPRS_ERROR_HANG, GPRS_ERROR_SMS, GPRS_ERROR_PIN, GPRS_ERROR_CALLINFO, GPRS_ERROR_SMSINFO, GPRS_ERROR_CONF, GPRS_ERROR_PATTERN, GPRS_ERROR_TIMER, GPRS_ERROR_PROFILE, GPRS_ERROR_SOCKET, GPRS_ERROR_CHECK, GPRS_ERROR_CLOSE 00461 */ 00462 int flag; 00463 00464 //! Variable : last call or SMS received telephone number 00465 /*! 00466 It stores telephone numbers with country code if it appears 00467 */ 00468 char tlfIN[15]; 00469 00470 //! Variable : baud rate used to communicate with the GPRS module 00471 /*! 00472 By default, it is 38400bps 00473 */ 00474 uint16_t _baudRate; 00475 00476 //! Variable : power mode 00477 /*! 00478 Possible values are: GPRS_ON, GPRS_SLEEP, GPRS_HIBERNATE 00479 */ 00480 uint8_t _pwrMode; 00481 00482 //! Variable : UART used by the GPRS module 00483 /*! 00484 GPRS module is connected to the UART1 00485 */ 00486 uint8_t _uart; 00487 00488 //! Variable : last SMS text received 00489 /*! 00490 It stores up to 100bytes from the last SMS received 00491 */ 00492 char sms[100]; 00493 00494 //! Variable : socket ID 00495 /*! 00496 It stores the ID of the last socket opened 00497 */ 00498 uint8_t socket_ID; 00499 00500 //! Variable : data received when reading an URL 00501 /*! 00502 It stores up to 100 bytes from an URL 00503 */ 00504 char data_URL[100]; 00505 00506 //! Variable : amount of data read from an URL or from a socket 00507 /*! 00508 */ 00509 uint16_t data_read; 00510 00511 //! Variable : Cell ID number 00512 /*! 00513 */ 00514 char cellID[4]; 00515 00516 //! Variable : RSSI value 00517 /*! 00518 */ 00519 char RSSI[2]; 00520 00521 //! Variable : Array for storing the answer to the command sent 00522 /*! 00523 */ 00524 char answer_command[50]; 00525 00526 //! Variable : Last sms received index 00527 /*! 00528 */ 00529 char sms_index[4]; 00530 00531 //! Variable : Email address from the last email received 00532 /*! 00533 */ 00534 char emailAddress[31]; 00535 00536 //! Variable : Last email received subject 00537 /*! 00538 */ 00539 char subject[31]; 00540 00541 //! Variable : Last email received subject 00542 /*! 00543 */ 00544 char body[101]; 00545 00546 //! class constructor 00547 /*! 00548 It initializes some variables 00549 \param void 00550 \return void 00551 */ 00552 WaspGPRS(); 00553 00554 00555 //! It opens UART1 and powers the GPRS module 00556 /*! 00557 \param void 00558 \return void 00559 \sa close(), begin() 00560 */ 00561 void ON(); 00562 00563 //! It closes UART1 and powers off the GPRS module 00564 /*! 00565 \param void 00566 \return void 00567 \sa close(), begin() 00568 */ 00569 void OFF(); 00570 00571 //! It opens UART and sets multiplexer properly 00572 /*! 00573 \param void 00574 \return void 00575 */ 00576 void begin(); 00577 00578 //! It closes UART and sets multiplexer properly 00579 /*! 00580 \param void 00581 \return void 00582 */ 00583 void close(); 00584 00585 //! It sets Power Mode 00586 /*! 00587 \param uint8_t pwrMode : the desired power mode (GPRS_ON, GPRS_SLEEP or GPRS_HIBERNATE) 00588 \return '1' on success and '0' if error 00589 */ 00590 uint8_t setMode(uint8_t pwrMode); 00591 00592 //! It gets Power Mode 00593 /*! 00594 \param void 00595 \return the power mode (GPRS_ON, GPRS_SLEEP or GPRS_HIBERNATE) 00596 */ 00597 uint8_t getMode(); 00598 00599 //! It checks if GPRS is connected to the network 00600 /*! 00601 \param void 00602 \return '1' if connected, '0' if not 00603 */ 00604 uint8_t check(); 00605 00606 //! It sets PIN 00607 /*! 00608 \param const char* PIN : the SIM's PIN 00609 \return '1' on success, '0' if error 00610 */ 00611 uint8_t setPIN(const char* pin); 00612 00613 //! It sets the info shown when an incoming call is received 00614 /*! 00615 \param void 00616 \return '1' on success, '0' if error 00617 */ 00618 uint8_t setInfoIncomingCall(); 00619 00620 //! It sets the info shown when an incoming SMS is received 00621 /*! 00622 \param void 00623 \return '1' on success, '0' if error 00624 */ 00625 uint8_t setInfoIncomingSMS(); 00626 00627 //! It sets 'text mode' for sending SMS 00628 /*! 00629 \param void 00630 \return '1' on success, '0' if error 00631 */ 00632 uint8_t setTextModeSMS(); 00633 00634 //! It makes a call to the specified number 00635 /*! 00636 \param const char* tlfNumber : telephone number to call. It must be a telephone number with 9 digits. 00637 \return '1' on success, '0' if error 00638 */ 00639 uint8_t makeCall(const char* tlfNumber); 00640 00641 //! It makes a lost call to the specified number 00642 /*! 00643 \param const char* tlfNumber : telephone number to call. It must be a telephone number with 9 digits. 00644 \param uint8_t timeCall : time the module is calling (in seconds) 00645 \return '1' on success, '0' if error 00646 */ 00647 uint8_t makeLostCall(const char* tlfNumber, uint8_t timeCall); 00648 00649 //! It hangs all the active calls up 00650 /*! 00651 \return '1' on success, '0' if error 00652 */ 00653 uint8_t hangUp(); 00654 00655 //! It sends a SMS to the specified number 00656 /*! 00657 \param const char* smsText : SMS text (up to 80bytes) 00658 \param const char* tlfNumber : telephone number to call. It must be a telephone number with 9 digits. 00659 \return '1' on success, '0' if error 00660 */ 00661 uint8_t sendSMS(const char* smsText, const char* tlfNumber); 00662 00663 //! It stores in 'tlfIN' variable the telephone number of the incoming call 00664 /*! 00665 \param char* data : data returned by the module when a call is being received 00666 \return '1' on success, '0' if error 00667 */ 00668 uint8_t readCall(char* data); 00669 00670 //! It stores in 'tlfIN' and 'sms' variables the telephone number and the text of the incoming SMS. It stores in 'sms_index' variable the last sms received index 00671 /*! 00672 \param char* data : data returned by the module when an SMS is received 00673 \return '1' on success, '0' if error 00674 */ 00675 uint8_t readSMS(char* data); 00676 00677 //! It manages incoming data from serial port, executing proper functions to store received data 00678 /*! 00679 \param void 00680 \return '1' on success, '0' if error 00681 */ 00682 uint8_t manageIncomingGSMData(); 00683 00684 //! It configures GPRS connection with login, password and some other parameters 00685 /*! 00686 It takes the configuration parameters from 'WaspGPRSconstants.h' file 00687 \param void 00688 \return '1' on success, '0' if error 00689 */ 00690 uint8_t configureGPRS(); 00691 00692 //! It creates a TCP/IP connection to the specified IP and PORT 00693 /*! 00694 \param const char* ip : the IP to open a socket to 00695 \param const char* port : the PORT to open a socket to 00696 \param uint8_t mode : GPRS_CLIENT or GPRS_SERVER 00697 \return '1' on success, '0' if error 00698 */ 00699 uint8_t createSocket(const char* ip,const char* port,uint8_t mode); 00700 00701 //! It accesses to the specified URL and stores the info read in 'data_URL' variable 00702 /*! 00703 It stores in 'data_URL' variable up to 100 bytes 00704 \param const char* url : the URL to get the information from 00705 \return '1' on success, '0' if error 00706 */ 00707 uint8_t readURL(const char* url); 00708 00709 //! It sends 'data' to the specified 'socket' 00710 /*! 00711 \param const char* data : the data to send to the socket 00712 \param uint8_t socket: the socket's ID to communicate with 00713 \return '1' on success, '0' if error 00714 */ 00715 uint8_t sendData(const char* data, uint8_t socket); 00716 00717 //! It reads data of 'data_length' size from socket ID 'socket' 00718 /*! 00719 \param uint8_t socket: the socket's ID to communicate with 00720 \param const char* data_length : the data length to read from the socket 00721 \return '1' on success, '0' if error 00722 */ 00723 int8_t readData(uint8_t socket, const char* data_length); 00724 00725 //! It closes 'socket' TCP/IP connection 00726 /*! 00727 \param uint8_t socket: the socket's ID to close 00728 \return '1' on success, '0' if error 00729 */ 00730 uint8_t closeSocket(uint8_t socket); 00731 00732 //! It sends any command to the GPRS module 00733 /*! 00734 \param char* ATcommand : the command to send to the GPRS module 00735 \return '1' on success, '0' if error 00736 */ 00737 uint8_t sendCommand(char* ATcommand); 00738 00739 //! It sends an email to the specified address 00740 /*! 00741 \param char* from : sender address 00742 \param char* to : receiver address 00743 \param char* subject : email subject 00744 \param char* body : text of the email 00745 \param char* user : login to connect to the smtp server 00746 \param char* passw : password to connect to the smtp server 00747 \param char* smtp_server : smtp server 00748 \param uint16_t port : smtp server port 00749 \return '1' on success, '0' if error 00750 */ 00751 uint8_t sendMail(char* from, char* to, char* subject, char* body, char* user, char* passw, char* smtp_server, uint16_t port); 00752 00753 //! It reads an email from the pop3 server 00754 /*! 00755 \param char* user : login to connect to the smtp server 00756 \param char* passw : password to connect to the smtp server 00757 \param char* pop3_server : pop3 server 00758 \param uint16_t port : pop3 server port 00759 \return '1' on success, '0' if error 00760 */ 00761 uint8_t readMail(char* user, char* passw, char* pop3_server, uint16_t port); 00762 00763 //! It uploads a file to a FTP server 00764 /*! 00765 \param char* file : file to upload (the name that will have in the FTP server and the name of the file in the SD card) 00766 \param char* path : path in the SD card where file is stored 00767 \param char* user : login to connect to the ftp server 00768 \param char* passw : password to connect to the ftp server 00769 \param char* ftp_server : ftp server 00770 \param uint8_t ftp_port : ftp server port 00771 \return '1' on success, '0' if error 00772 */ 00773 uint8_t uploadFile(char* file, char* path, char* user, char* passw, char* ftp_server, uint8_t ftp_port); 00774 00775 //! It downloads a file from a FTP server 00776 /*! 00777 \param char* file : file to download (the file name in the FTP server) 00778 \param char* path : path in the SD card where file is going to be stored (it may have a different name from the FTP server file) 00779 \param char* user : login to connect to the ftp server 00780 \param char* passw : password to connect to the ftp server 00781 \param char* ftp_server : ftp server 00782 \param uint8_t ftp_port : ftp server port 00783 \return '1' on success, '0' if error 00784 */ 00785 uint8_t downloadFile(char* file, char* path, char* user, char* passw, char* ftp_server, uint8_t ftp_port); 00786 00787 //! It gets info from the cell where the modules is connected 00788 /*! 00789 It stores in 'RSSI' and 'cellID' variables the RSSI and the Cell ID 00790 \return '1' on success, '0' if error 00791 */ 00792 uint8_t getCellInfo(); 00793 }; 00794 00795 extern WaspGPRS GPRS; 00796 00797 #endif 00798
1.5.6