seeedstudio ARCH GPRS Test for GPRS function

Dependencies:   GPRS mbed

Fork of ARCH_GPRS_Demo by hs loovee

ARCH GPRS Introduction

ARCH GPRS

  • Arch GPRS is a wireless network module based on EG-10, it can achive remote data colletion function to communicate with outside world by GPRS network.
  • Arch GPRS has standard Arduino interface and Grove connectors. It’s convenient to connect existing Shields and Grove products to Arch GPRS.
  • You can use the solar panel to charge for battery, and own to its low-power design, so Arch GPRS can work normally in outdoor.
  • For more information, please visit http://www.seeedstudio.com/depot/arch-gprs-p-1657.html?cPath=6_11

main.cpp

/*
  main.cpp
  2013 Copyright (c) Seeed Technology Inc.  All right reserved.
 
  Author:lawliet zou(lawliet.zou@gmail.com)
  2013-7-21
 
  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 "string.h"
#include "gprs.h"
 
#define SEND_SMS_TEST           0
#define CALL_UP_TEST            0
#define ANSWER_TEST             0
#define READ_SMS_TEST           0
 
#define PHONE_NUMBER            "150****9566"
 
#define PINPWR                  P1_2 // power on EG 10, low enable
#define PINONOFF                P1_7 // switch of EG10, low enable, low for 2s to turn on EG10
 
DigitalOut eg10_pwr(PINPWR);
DigitalOut eg10_on(PINONOFF);
GPRS  gprsTest(P0_19, P0_18, 115200, PHONE_NUMBER);
 
void EG10_PowerUp(void)
{
    eg10_pwr = 1;
    eg10_on  = 1;
    wait(2);
    eg10_pwr = 0;
    eg10_on = 0;
    wait(2);
    eg10_on = 1;
    wait(2);
}
 
int main(void)
{
    EG10_PowerUp();
    while(0 != gprsTest.init()) {
        wait(2);
    }
 
#if CALL_UP_TEST
    gprsTest.callUp(PHONE_NUMBER);
#endif
 
#if SEND_SMS_TEST
    gprsTest.sendSMS(PHONE_NUMBER,"hello,lawliet");
#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;
}
Committer:
lawliet
Date:
Tue Jan 21 06:51:43 2014 +0000
Revision:
3:517631946eb0
Parent:
2:293881d1c5c9
version 2.0 (update with gprs library)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
loovee 0:6d297fe482af 1 /*
lawliet 3:517631946eb0 2 main.cpp
loovee 0:6d297fe482af 3 2013 Copyright (c) Seeed Technology Inc. All right reserved.
loovee 0:6d297fe482af 4
lawliet 3:517631946eb0 5 Author:lawliet zou(lawliet.zou@gmail.com)
loovee 0:6d297fe482af 6 2013-7-21
loovee 0:6d297fe482af 7
loovee 0:6d297fe482af 8 This library is free software; you can redistribute it and/or
loovee 0:6d297fe482af 9 modify it under the terms of the GNU Lesser General Public
loovee 0:6d297fe482af 10 License as published by the Free Software Foundation; either
loovee 0:6d297fe482af 11 version 2.1 of the License, or (at your option) any later version.
loovee 0:6d297fe482af 12
loovee 0:6d297fe482af 13 This library is distributed in the hope that it will be useful,
loovee 0:6d297fe482af 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
loovee 0:6d297fe482af 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
loovee 0:6d297fe482af 16 Lesser General Public License for more details.
loovee 0:6d297fe482af 17
loovee 0:6d297fe482af 18 You should have received a copy of the GNU Lesser General Public
loovee 0:6d297fe482af 19 License along with this library; if not, write to the Free Software
loovee 0:6d297fe482af 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
loovee 0:6d297fe482af 21 */
loovee 0:6d297fe482af 22 #include "mbed.h"
lawliet 1:a686793fb3d6 23 #include "string.h"
lawliet 1:a686793fb3d6 24 #include "gprs.h"
loovee 0:6d297fe482af 25
lawliet 1:a686793fb3d6 26 #define SEND_SMS_TEST 0
lawliet 1:a686793fb3d6 27 #define CALL_UP_TEST 0
lawliet 1:a686793fb3d6 28 #define ANSWER_TEST 0
lawliet 1:a686793fb3d6 29 #define READ_SMS_TEST 0
lawliet 3:517631946eb0 30
lawliet 3:517631946eb0 31 #define PHONE_NUMBER "150****9566"
loovee 0:6d297fe482af 32
lawliet 3:517631946eb0 33 #define PINPWR P1_2 // power on EG 10, low enable
lawliet 3:517631946eb0 34 #define PINONOFF P1_7 // switch of EG10, low enable, low for 2s to turn on EG10
loovee 0:6d297fe482af 35
lawliet 1:a686793fb3d6 36 DigitalOut eg10_pwr(PINPWR);
lawliet 1:a686793fb3d6 37 DigitalOut eg10_on(PINONOFF);
lawliet 3:517631946eb0 38 GPRS gprsTest(P0_19, P0_18, 115200, PHONE_NUMBER);
loovee 0:6d297fe482af 39
lawliet 1:a686793fb3d6 40 void EG10_PowerUp(void)
lawliet 1:a686793fb3d6 41 {
lawliet 1:a686793fb3d6 42 eg10_pwr = 1;
lawliet 1:a686793fb3d6 43 eg10_on = 1;
lawliet 1:a686793fb3d6 44 wait(2);
lawliet 1:a686793fb3d6 45 eg10_pwr = 0;
lawliet 1:a686793fb3d6 46 eg10_on = 0;
lawliet 1:a686793fb3d6 47 wait(2);
lawliet 1:a686793fb3d6 48 eg10_on = 1;
lawliet 1:a686793fb3d6 49 wait(2);
loovee 0:6d297fe482af 50 }
loovee 0:6d297fe482af 51
loovee 0:6d297fe482af 52 int main(void)
loovee 0:6d297fe482af 53 {
lawliet 3:517631946eb0 54 EG10_PowerUp();
lawliet 3:517631946eb0 55 while(0 != gprsTest.init()) {
lawliet 3:517631946eb0 56 wait(2);
lawliet 3:517631946eb0 57 }
lawliet 1:a686793fb3d6 58
lawliet 1:a686793fb3d6 59 #if CALL_UP_TEST
lawliet 3:517631946eb0 60 gprsTest.callUp(PHONE_NUMBER);
lawliet 1:a686793fb3d6 61 #endif
lawliet 1:a686793fb3d6 62
lawliet 1:a686793fb3d6 63 #if SEND_SMS_TEST
lawliet 3:517631946eb0 64 gprsTest.sendSMS(PHONE_NUMBER,"hello,lawliet");
lawliet 1:a686793fb3d6 65 #endif
loovee 0:6d297fe482af 66
lawliet 1:a686793fb3d6 67 #if ANSWER_TEST || READ_SMS_TEST
lawliet 3:517631946eb0 68 while(1) {
lawliet 3:517631946eb0 69 int messageType = gprsTest.loopHandle();
lawliet 3:517631946eb0 70 if(MESSAGE_RING == messageType) {
lawliet 3:517631946eb0 71 gprsTest.answer();
lawliet 3:517631946eb0 72 } else if(MESSAGE_SMS == messageType) {
lawliet 3:517631946eb0 73 char smsMessage[SMS_MAX_LENGTH];
lawliet 3:517631946eb0 74 gprsTest.getSMS(smsMessage);
lawliet 3:517631946eb0 75 }
lawliet 3:517631946eb0 76 }
lawliet 1:a686793fb3d6 77 #endif
lawliet 1:a686793fb3d6 78
lawliet 1:a686793fb3d6 79 return 0;
lawliet 1:a686793fb3d6 80 }