wei zou / ARCH_GPRS_Xively

Dependencies:   GPRS mbed

Fork of USB2UART by Yihui Xiong

Files at this revision

API Documentation at this revision

Comitter:
lawliet
Date:
Wed Jan 22 02:06:06 2014 +0000
Parent:
4:430799dc43e9
Commit message:
version 2.1 (update with GPRS library)

Changed in this revision

GPRS.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
--- a/GPRS.lib	Tue Jan 21 07:06:21 2014 +0000
+++ b/GPRS.lib	Wed Jan 22 02:06:06 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/lawliet/code/GPRS/#63a2619b423b
+http://mbed.org/users/lawliet/code/GPRS/#ac2342f162fa
--- a/main.cpp	Tue Jan 21 07:06:21 2014 +0000
+++ b/main.cpp	Wed Jan 22 02:06:06 2014 +0000
@@ -10,6 +10,8 @@
 #define DATA_LENGTH     90
 #define HEAD_LEN        270
 
+#define NETWORK_APN     "CMNET"  //replace APN in your country
+
 #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
 
@@ -39,6 +41,9 @@
     snprintf(dataStream,DATA_LENGTH,"{\"version\":\"1.0.0\", \"datastreams\" : [{ \"id\" : \"%s\", \"current_value\" : \"%f\"}]}\r\n",SENSOR_ID,sensorValue);
     int dataLen = strlen(dataStream);
     snprintf(head,HEAD_LEN,"%sHost: api.xively.com\r\nX-ApiKey: %s\r\nUser-Agent: Xively-Arduino-Lib/1.0\r\nContent-Length: %d\r\n\r\n%s",request,XIVELY_KEY,dataLen,dataStream);
+    if(0 != gprs.networkInit(NETWORK_APN,NULL,NULL)){ //APN,User,PassWd
+        return -1;    
+    }
     if(0 != gprs.connectTCP(IP_ADDRSS,PORT)) {
         goto STOP;
     }