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());
        }
    }
}

Files at this revision

API Documentation at this revision

Comitter:
lawliet
Date:
Tue Jan 21 07:02:21 2014 +0000
Commit message:
Initial Version (used for GPRS AT Command Debug)

Changed in this revision

USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 1718a77b8291 USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Tue Jan 21 07:02:21 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#4f6df64750bd
diff -r 000000000000 -r 1718a77b8291 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jan 21 07:02:21 2014 +0000
@@ -0,0 +1,74 @@
+/*
+  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());
+        }
+    }
+}
+
diff -r 000000000000 -r 1718a77b8291 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jan 21 07:02:21 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file