give example to use GPRS Shield library

Dependencies:   GPRS mbed

Fork of GPRS_Shield_Test by wei zou

main.cpp

Committer:
lawliet
Date:
2014-02-10
Revision:
3:e07b56b8b637
Parent:
2:3b735ebe88b0
Child:
4:f7f516572a4a

File content as of revision 3:e07b56b8b637:

/*
  main.cpp
  2013 Copyright (c) Seeed Technology Inc.  All right reserved.

  Author:lawliet zou(lawliet.zou@gmail.com)
  2014-02-08

  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
*/
#include "mbed.h"
#include "gprs.h"


//#define SEEEDUINO_ARCH
#define SEEEDUINO_ARCH_PRO

#if defined(SEEEDUINO_ARCH)
#define GPRS_TX_PIN             P0_19
#define GPRS_RX_PIN             P0_18
#elif defined(SEEEDUINO_ARCH_PRO)
#define GPRS_TX_PIN             P4_28
#define GPRS_RX_PIN             P4_29
#else
#define GPRS_TX_PIN             P0_19
#define GPRS_RX_PIN             P0_18
#endif

#define SEND_SMS_TEST           1
#define CALL_UP_TEST            0
#define ANSWER_TEST             0
#define READ_SMS_TEST           0

#define BAUD_RATE               19200 // Baud rate of GPRS Shield 
#define PHONE_NUMBER            "159****4951"

GPRS  gprsTest(GPRS_TX_PIN, GPRS_RX_PIN, BAUD_RATE, PHONE_NUMBER);

int main(void)
{
    while(0 != gprsTest.init()) {
        wait(2);
    }

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

#if CALL_UP_TEST
    gprsTest.callUp(PHONE_NUMBER);
#endif

#if ANSWER_TEST || READ_SMS_TEST
    while(1) {
        int messageType = gprsTest.loopHandle();
        if(MESSAGE_RING == messageType) {
            gprsTest.answer();
        } else if(MESSAGE_SMS == messageType) {
            char smsMessage[SMS_MAX_LENGTH];
            gprsTest.getSMS(smsMessage);
        }
    }
#endif

    return 0;
}