a library to use GPRS like ethernet or wifi, which makes it possible to connect to the internet with your GPRS module
Dependencies: BufferedSerial
Dependents: ThinkSpeak_Test roam_v1 roam_v2 finalv3
Fork of GPRSInterface by
GPRSInterface.h@0:8ccbd963e74d, 2014-02-25 (annotated)
- Committer:
- lawliet
- Date:
- Tue Feb 25 02:52:48 2014 +0000
- Revision:
- 0:8ccbd963e74d
- Child:
- 5:c4db857fb1be
Initial version of GPRS Interface
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lawliet | 0:8ccbd963e74d | 1 | /* |
lawliet | 0:8ccbd963e74d | 2 | GPRSInterface.h |
lawliet | 0:8ccbd963e74d | 3 | 2014 Copyright (c) Seeed Technology Inc. All right reserved. |
lawliet | 0:8ccbd963e74d | 4 | |
lawliet | 0:8ccbd963e74d | 5 | Author:lawliet zou(lawliet.zou@gmail.com) |
lawliet | 0:8ccbd963e74d | 6 | 2014-2-24 |
lawliet | 0:8ccbd963e74d | 7 | |
lawliet | 0:8ccbd963e74d | 8 | This library is free software; you can redistribute it and/or |
lawliet | 0:8ccbd963e74d | 9 | modify it under the terms of the GNU Lesser General Public |
lawliet | 0:8ccbd963e74d | 10 | License as published by the Free Software Foundation; either |
lawliet | 0:8ccbd963e74d | 11 | version 2.1 of the License, or (at your option) any later version. |
lawliet | 0:8ccbd963e74d | 12 | |
lawliet | 0:8ccbd963e74d | 13 | This library is distributed in the hope that it will be useful, |
lawliet | 0:8ccbd963e74d | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
lawliet | 0:8ccbd963e74d | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
lawliet | 0:8ccbd963e74d | 16 | Lesser General Public License for more details. |
lawliet | 0:8ccbd963e74d | 17 | |
lawliet | 0:8ccbd963e74d | 18 | You should have received a copy of the GNU Lesser General Public |
lawliet | 0:8ccbd963e74d | 19 | License along with this library; if not, write to the Free Software |
lawliet | 0:8ccbd963e74d | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
lawliet | 0:8ccbd963e74d | 21 | */ |
lawliet | 0:8ccbd963e74d | 22 | #ifndef __GPRSINTERFACE_H__ |
lawliet | 0:8ccbd963e74d | 23 | |
lawliet | 0:8ccbd963e74d | 24 | #include "GPRS.h" |
lawliet | 0:8ccbd963e74d | 25 | #include "TCPSocketConnection.h" |
lawliet | 0:8ccbd963e74d | 26 | #include "TCPSocketServer.h" |
lawliet | 0:8ccbd963e74d | 27 | |
lawliet | 0:8ccbd963e74d | 28 | /** Interface using GPRS to connect to an IP-based network |
lawliet | 0:8ccbd963e74d | 29 | * |
lawliet | 0:8ccbd963e74d | 30 | */ |
lawliet | 0:8ccbd963e74d | 31 | class GPRSInterface: public GPRS |
lawliet | 0:8ccbd963e74d | 32 | { |
lawliet | 0:8ccbd963e74d | 33 | |
lawliet | 0:8ccbd963e74d | 34 | public: |
lawliet | 0:8ccbd963e74d | 35 | |
lawliet | 0:8ccbd963e74d | 36 | /** Constructor |
lawliet | 0:8ccbd963e74d | 37 | * @param tx mbed pin to use for tx line of Serial interface |
lawliet | 0:8ccbd963e74d | 38 | * @param rx mbed pin to use for rx line of Serial interface |
lawliet | 0:8ccbd963e74d | 39 | * @param baudRate serial communicate baud rate |
lawliet | 0:8ccbd963e74d | 40 | * @param apn name of the gateway for GPRS to connect to the network |
lawliet | 0:8ccbd963e74d | 41 | * @param userName apn's username, usually is NULL |
lawliet | 0:8ccbd963e74d | 42 | * @param passWord apn's password, usually is NULL |
lawliet | 0:8ccbd963e74d | 43 | */ |
lawliet | 0:8ccbd963e74d | 44 | GPRSInterface(PinName tx, PinName rx, int baudRate, const char* apn, const char* userName = NULL, const char *passWord = NULL); |
lawliet | 0:8ccbd963e74d | 45 | |
lawliet | 0:8ccbd963e74d | 46 | /** Initialize the interface(no connection at this point). |
lawliet | 0:8ccbd963e74d | 47 | * @return 0 on success, a negative number on failure |
lawliet | 0:8ccbd963e74d | 48 | */ |
lawliet | 0:8ccbd963e74d | 49 | int init(); |
lawliet | 0:8ccbd963e74d | 50 | |
lawliet | 0:8ccbd963e74d | 51 | /** Connect to the network and get IP address |
lawliet | 0:8ccbd963e74d | 52 | * @returns 0 on success, a negative number on failure |
lawliet | 0:8ccbd963e74d | 53 | */ |
lawliet | 0:8ccbd963e74d | 54 | int connect(); |
lawliet | 0:8ccbd963e74d | 55 | |
lawliet | 0:8ccbd963e74d | 56 | /** Disconnect with the network |
lawliet | 0:8ccbd963e74d | 57 | * @returns 0 on success, a negative number on failure |
lawliet | 0:8ccbd963e74d | 58 | */ |
lawliet | 0:8ccbd963e74d | 59 | int disconnect(); |
lawliet | 0:8ccbd963e74d | 60 | |
lawliet | 0:8ccbd963e74d | 61 | /** Get IP address |
lawliet | 0:8ccbd963e74d | 62 | * @returns ip address |
lawliet | 0:8ccbd963e74d | 63 | */ |
lawliet | 0:8ccbd963e74d | 64 | char* getIPAddress(); |
lawliet | 0:8ccbd963e74d | 65 | |
lawliet | 0:8ccbd963e74d | 66 | private: |
lawliet | 0:8ccbd963e74d | 67 | |
lawliet | 0:8ccbd963e74d | 68 | char ip_string[20]; |
lawliet | 0:8ccbd963e74d | 69 | bool ip_set; |
lawliet | 0:8ccbd963e74d | 70 | }; |
lawliet | 0:8ccbd963e74d | 71 | |
lawliet | 0:8ccbd963e74d | 72 | #endif |