wei zou / Mbed 2 deprecated ARCH_GPRS_Test

Dependencies:   GPRS mbed

Fork of ARCH_GPRS_Demo by hs loovee

Files at this revision

API Documentation at this revision

Comitter:
lawliet
Date:
Tue Jan 21 06:51:43 2014 +0000
Parent:
2:293881d1c5c9
Commit message:
version 2.0 (update with gprs library)

Changed in this revision

GPRS.lib Show annotated file Show diff for this revision Revisions of this file
gprs.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPRS.lib	Tue Jan 21 06:51:43 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/lawliet/code/GPRS/#63a2619b423b
--- a/gprs.lib	Mon Nov 18 06:23:03 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/lawliet/code/gprs/#16985da3a446
--- a/main.cpp	Mon Nov 18 06:23:03 2013 +0000
+++ b/main.cpp	Tue Jan 21 06:51:43 2014 +0000
@@ -1,8 +1,8 @@
 /*
-  main.cpp, iot_mbed demo
+  main.cpp
   2013 Copyright (c) Seeed Technology Inc.  All right reserved.
 
-  Author:Loovee
+  Author:lawliet zou(lawliet.zou@gmail.com)
   2013-7-21
 
   This library is free software; you can redistribute it and/or
@@ -23,25 +23,19 @@
 #include "string.h"
 #include "gprs.h"
 
-#define TRUE    1
-#define FALSE   0
-
-#define SERIAL_DEBUG            0
 #define SEND_SMS_TEST           0
 #define CALL_UP_TEST            0
 #define ANSWER_TEST             0
 #define READ_SMS_TEST           0
-#define TCP_TEST                0
+
+#define PHONE_NUMBER            "150****9566"
 
-#define IP_ADDRSS               "42.96.164.52"
-#define PORT                    "80"
+#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
 
-#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,"139****7382");
+GPRS  gprsTest(P0_19, P0_18, 115200, PHONE_NUMBER);
 
 void EG10_PowerUp(void)
 {
@@ -57,29 +51,29 @@
 
 int main(void)
 {
+    EG10_PowerUp();
+    while(0 != gprsTest.init()) {
+        wait(2);
+    }
 
-    EG10_PowerUp();
-    gprsTest.init();
-    wait(2);
-    
 #if CALL_UP_TEST
-    gprsTest.callUp("139****7382");
+    gprsTest.callUp(PHONE_NUMBER);
 #endif
 
 #if SEND_SMS_TEST
-    gprsTest.sendSMS("139****7382","hello,lawliet");
+    gprsTest.sendSMS(PHONE_NUMBER,"hello,lawliet");
 #endif
 
 #if ANSWER_TEST || READ_SMS_TEST
-    gprsTest.loop(FALSE);
-#endif
-
-#if TCP_TEST
-    gprsTest.connectTCP(IP_ADDRSS,PORT);
-#endif
-
-#if SERIAL_DEBUG
-    gprsTest.serialDebug(USBTX,USBRX);
+    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;