wei zou / Mbed 2 deprecated GPRS_Shield_Test

Dependencies:   GPRS mbed

You are viewing an older revision! See the latest version

Homepage

Table of Contents

  1. GPRS Shield

GPRS Shield

Import programGPRS_Shield_Test

give example to use GPRS Shield library

main.cpp

#include "mbed.h"
#include "string.h"
#include "gprs.h"

#define SERIAL_DEBUG            0
#define SEND_SMS_TEST           0
#define CALL_UP_TEST            0
#define ANSWER_TEST             0
#define READ_SMS_TEST           0
#define TCP_TEST                0

#define IP_ADDRSS               "42.96.164.52"
#define PORT                    "80"

GPRS  gprsTest(P0_19, P0_18, 115200, "10086");

int main(void)
{
    if(0 != gprsTest.init()) {
        return -1;
    }

#if SEND_SMS_TEST
    gprsTest.sendSMS("10086","hello,lawliet"); //define phone number and text
#endif

#if CALL_UP_TEST
    gprsTest.callUp("10086");
#endif

#if ANSWER_TEST || READ_SMS_TEST
    gprsTest.loop(0);
#endif

#if TCP_TEST
    gprsTest.connectTCP(IP_ADDRSS,PORT);
    gprsTest.sendTCPData("hello,lawliet test");
#endif

#if SERIAL_DEBUG
    gprsTest.serialDebug(USBTX,USBRX);
#endif

    return 0;
}

APIS

Import library

Public Member Functions

GPRS (PinName tx, PinName rx, int baudRate, char *number)
Create GPRS instance.
int init (void)
init GPRS module including SIM card check & signal strength & network check
int readBuffer (char *buffer, int count)
read from GPRS module and save to buffer array
void sendCmd (char *cmd)
send AT command to GPRS module
int waitForResp (char *resp, int timeout)
check GPRS module response before timeout
int sendCmdAndWaitForResp (char *cmd, char *resp, int timeout)
send AT command to GPRS module and wait for correct response
int checkSIMStatus (void)
check SIM card' Status
int checkSignalStrength (void)
check signal strength
int networkInit (void)
check network is ok or not
int sendSMS (char *number, char *data)
send text SMS
int readSMS (char *buffer, char *message, bool check)
read SMS if get a SMS
int deleteSMS (int index)
delete SMS message on SIM card
int callUp (char *number)
call someone
int answer (void)
auto answer if coming a call
int loop (bool check)
a loop to wait for some event.
int connectTCP (char *ip, char *port)
build TCP connect
int sendTCPData (char *data)
send data to TCP server
int closeTCP (void)
close TCP connection
int shutTCP (void)
close TCP service
void serialDebug (PinName tx, PinName rx)
used for serial debug, you can specify tx and rx pin and then communicate with GPRS module with common AT commands

All wikipages