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 wei zou

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GPRSInterface.cpp Source File

GPRSInterface.cpp

00001 /*
00002   GPRSInterface.cpp
00003   2014 Copyright (c) Seeed Technology Inc.  All right reserved.
00004 
00005   Author:lawliet zou(lawliet.zou@gmail.com)
00006   2014-2-24
00007 
00008   This library is free software; you can redistribute it and/or
00009   modify it under the terms of the GNU Lesser General Public
00010   License as published by the Free Software Foundation; either
00011   version 2.1 of the License, or (at your option) any later version.
00012 
00013   This library is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016   Lesser General Public License for more details.
00017 
00018   You should have received a copy of the GNU Lesser General Public
00019   License along with this library; if not, write to the Free Software
00020   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00021 */
00022 
00023 #include "GPRSInterface.h"
00024 
00025 GPRSInterface::GPRSInterface(PinName tx, PinName rx, const char* apn, const char* userName, const char *passWord) : GPRS(tx, rx, apn, userName, passWord)
00026 {
00027     ip_set = false;
00028 }
00029 
00030 int GPRSInterface::init()
00031 {
00032     return 0;
00033 }
00034 
00035 int GPRSInterface::connect()
00036 {
00037     return GPRS::join();
00038 }
00039 
00040 int GPRSInterface::disconnect()
00041 {
00042     return GPRS::disconnect();
00043 }
00044 
00045 char* GPRSInterface::getIPAddress()
00046 {
00047     snprintf(ip_string, sizeof(ip_string), "%d.%d.%d.%d", (_ip>>24)&0xff,(_ip>>16)&0xff,(_ip>>8)&0xff,_ip&0xff); 
00048     ip_set = true;
00049     return ip_string;
00050 }