ok

gprs.h

Committer:
lawliet
Date:
2013-11-15
Revision:
1:642a8dbe076c
Parent:
0:a5ae94727346
Child:
2:16985da3a446

File content as of revision 1:642a8dbe076c:

/*
  IOT_Mbed.h
  2013 Copyright (c) Seeed Technology Inc.  All right reserved.

  Author:lawliet.zou@gmail.com
  2013-11-14

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef __GPRS_H__
#define __GPRS_H__

#include "mbed.h"

class gprs
{

public:
    gprs(PinName tx, PinName rx, int baudrate,char *Number) : gprsSerial(tx, rx) {
        gprsSerial.baud(baudrate);
        phoneNumber = Number;
    };
    int init(void);
    int readBuffer(char *buffer,int count);
    void sendCmd(char *cmd);
    int waitForResp(char *resp, int timeout);
    int sendCmdAndWaitForResp(char *cmd, char *resp, int timeout);
    int checkSIMStatus(void);
    int checkSignalStrength(void);
    int networkInit(void);
    int sendSMS(char *number, char *data);
    int readSMS(char *buffer, char *message, bool check);
    int deleteSMS(int index);
    int callUp(char *number);
    int answer(void);
    int loop(bool check);
    int connectTCP(char *ip, char *port);
    int sendTCPData(char *data);
    int closeTCP(void);
    int shutTCP(void);
    void serialDebug(PinName tx, PinName rx);
private:
    Serial gprsSerial;
    Timer timeCnt;
    char *phoneNumber;
};

//extern gprs GPRS;
#endif