used for ARCH GPRS AT Command Debug

Dependencies:   USBDevice mbed

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)
  2014-1-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 "USBSerial.h"
 
#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);
 
Serial gprs(USBTX, USBRX);
USBSerial pc;
 
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);
}
 
// Called by ISR
void settingsChanged(int baud, int bits, int parity, int stop)
{
    const Serial::Parity parityTable[] = {Serial::None, Serial::Odd, Serial::Even, Serial::Forced0, Serial::Forced1};
 
    if (stop != 2) {
        stop = 1;   // stop bit(s) = 1 or 1.5
    }
 
    gprs.baud(baud);
    gprs.format(bits, parityTable[parity], stop);
}
 
int main()
{
    pc.attach(settingsChanged);
    EG10_PowerUp();
 
    while (1) {
        while (gprs.readable()) {
            pc.putc(gprs.getc());
        }
 
        while (pc.readable()) {
            gprs.putc(pc.getc());
        }
    }
}
Committer:
lawliet
Date:
Tue Jan 21 07:02:21 2014 +0000
Revision:
0:1718a77b8291
Initial Version (used for GPRS AT Command Debug)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lawliet 0:1718a77b8291 1 /*
lawliet 0:1718a77b8291 2 main.cpp
lawliet 0:1718a77b8291 3 2013 Copyright (c) Seeed Technology Inc. All right reserved.
lawliet 0:1718a77b8291 4
lawliet 0:1718a77b8291 5 Author:lawliet zou(lawliet.zou@gmail.com)
lawliet 0:1718a77b8291 6 2014-1-21
lawliet 0:1718a77b8291 7
lawliet 0:1718a77b8291 8 This library is free software; you can redistribute it and/or
lawliet 0:1718a77b8291 9 modify it under the terms of the GNU Lesser General Public
lawliet 0:1718a77b8291 10 License as published by the Free Software Foundation; either
lawliet 0:1718a77b8291 11 version 2.1 of the License, or (at your option) any later version.
lawliet 0:1718a77b8291 12
lawliet 0:1718a77b8291 13 This library is distributed in the hope that it will be useful,
lawliet 0:1718a77b8291 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
lawliet 0:1718a77b8291 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
lawliet 0:1718a77b8291 16 Lesser General Public License for more details.
lawliet 0:1718a77b8291 17
lawliet 0:1718a77b8291 18 You should have received a copy of the GNU Lesser General Public
lawliet 0:1718a77b8291 19 License along with this library; if not, write to the Free Software
lawliet 0:1718a77b8291 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
lawliet 0:1718a77b8291 21 */
lawliet 0:1718a77b8291 22 #include "mbed.h"
lawliet 0:1718a77b8291 23 #include "USBSerial.h"
lawliet 0:1718a77b8291 24
lawliet 0:1718a77b8291 25 #define PINPWR P1_2 // power on EG 10, low enable
lawliet 0:1718a77b8291 26 #define PINONOFF P1_7 // switch of EG10, low enable, low for 2s to turn on EG10
lawliet 0:1718a77b8291 27
lawliet 0:1718a77b8291 28 DigitalOut eg10_pwr(PINPWR);
lawliet 0:1718a77b8291 29 DigitalOut eg10_on(PINONOFF);
lawliet 0:1718a77b8291 30
lawliet 0:1718a77b8291 31 Serial gprs(USBTX, USBRX);
lawliet 0:1718a77b8291 32 USBSerial pc;
lawliet 0:1718a77b8291 33
lawliet 0:1718a77b8291 34 void EG10_PowerUp(void)
lawliet 0:1718a77b8291 35 {
lawliet 0:1718a77b8291 36 eg10_pwr = 1;
lawliet 0:1718a77b8291 37 eg10_on = 1;
lawliet 0:1718a77b8291 38 wait(2);
lawliet 0:1718a77b8291 39 eg10_pwr = 0;
lawliet 0:1718a77b8291 40 eg10_on = 0;
lawliet 0:1718a77b8291 41 wait(2);
lawliet 0:1718a77b8291 42 eg10_on = 1;
lawliet 0:1718a77b8291 43 wait(2);
lawliet 0:1718a77b8291 44 }
lawliet 0:1718a77b8291 45
lawliet 0:1718a77b8291 46 // Called by ISR
lawliet 0:1718a77b8291 47 void settingsChanged(int baud, int bits, int parity, int stop)
lawliet 0:1718a77b8291 48 {
lawliet 0:1718a77b8291 49 const Serial::Parity parityTable[] = {Serial::None, Serial::Odd, Serial::Even, Serial::Forced0, Serial::Forced1};
lawliet 0:1718a77b8291 50
lawliet 0:1718a77b8291 51 if (stop != 2) {
lawliet 0:1718a77b8291 52 stop = 1; // stop bit(s) = 1 or 1.5
lawliet 0:1718a77b8291 53 }
lawliet 0:1718a77b8291 54
lawliet 0:1718a77b8291 55 gprs.baud(baud);
lawliet 0:1718a77b8291 56 gprs.format(bits, parityTable[parity], stop);
lawliet 0:1718a77b8291 57 }
lawliet 0:1718a77b8291 58
lawliet 0:1718a77b8291 59 int main()
lawliet 0:1718a77b8291 60 {
lawliet 0:1718a77b8291 61 pc.attach(settingsChanged);
lawliet 0:1718a77b8291 62 EG10_PowerUp();
lawliet 0:1718a77b8291 63
lawliet 0:1718a77b8291 64 while (1) {
lawliet 0:1718a77b8291 65 while (gprs.readable()) {
lawliet 0:1718a77b8291 66 pc.putc(gprs.getc());
lawliet 0:1718a77b8291 67 }
lawliet 0:1718a77b8291 68
lawliet 0:1718a77b8291 69 while (pc.readable()) {
lawliet 0:1718a77b8291 70 gprs.putc(pc.getc());
lawliet 0:1718a77b8291 71 }
lawliet 0:1718a77b8291 72 }
lawliet 0:1718a77b8291 73 }
lawliet 0:1718a77b8291 74