give example to use GPRS Shield library
Fork of GPRS_Shield_Test by
main.cpp
00001 /* 00002 main.cpp 00003 2013 Copyright (c) Seeed Technology Inc. All right reserved. 00004 00005 Author:lawliet zou(lawliet.zou@gmail.com) 00006 2014-02-08 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 #include "mbed.h" 00023 #include "gprs.h" 00024 00025 #if defined(TARGET_LPC11U24) //SEEEDUINO_ARCH 00026 #define GPRS_TX_PIN P0_19 00027 #define GPRS_RX_PIN P0_18 00028 #elif defined(TARGET_LPC1768) //SEEEDUINO_ARCH_PRO 00029 #define GPRS_TX_PIN P4_28 00030 #define GPRS_RX_PIN P4_29 00031 #else //please redefine the following pins 00032 #define GPRS_TX_PIN 00033 #define GPRS_RX_PIN 00034 #endif 00035 00036 #define SEND_SMS_TEST 0 00037 #define CALL_UP_TEST 0 00038 #define ANSWER_TEST 0 00039 #define READ_SMS_TEST 0 00040 00041 #define BAUD_RATE 19200 // Baud rate of GPRS Shield 00042 #define PHONE_NUMBER "159****4951" 00043 00044 GPRS gprsTest(GPRS_TX_PIN, GPRS_RX_PIN, BAUD_RATE, PHONE_NUMBER); 00045 00046 void messageHandle(void) 00047 { 00048 __disable_irq(); 00049 int messageType = gprsTest.loopHandle(); 00050 if(MESSAGE_RING == messageType) { 00051 gprsTest.answer(); 00052 } else if(MESSAGE_SMS == messageType) { 00053 char smsMessage[SMS_MAX_LENGTH]; 00054 gprsTest.getSMS(smsMessage); 00055 } 00056 __enable_irq(); 00057 } 00058 00059 int main(void) 00060 { 00061 while(0 != gprsTest.init()) { 00062 wait(2); 00063 } 00064 00065 #if SEND_SMS_TEST 00066 gprsTest.sendSMS(PHONE_NUMBER,"hello world"); //define phone number and text 00067 #endif 00068 00069 #if CALL_UP_TEST 00070 gprsTest.callUp(PHONE_NUMBER); 00071 #endif 00072 00073 #if ANSWER_TEST || READ_SMS_TEST 00074 gprsTest.gprsSerial.attach(&messageHandle); 00075 #endif 00076 while(1){wait(1);} 00077 return 0; 00078 } 00079 00080 00081
Generated on Tue Jul 12 2022 21:44:16 by 1.7.2