C027_Support library test
Dependencies: C027_Support
Dependents: C027_SupportTest_xively_location software_test_v1
Fork of Seeed_GPRS_Library_HelloWorld by
When running this example make sure you have:
- edited the SIM PIN, APN, USER and PASSWORD for you network operator
- have inserted a SIM card with enough credits
- the antennas connected
- have good reception (especially for GPS)
- installed the mbed CDC drivers if you run windows
- connected a terminal program, such as teraterm
The example will connect the modem to the network and attach it. I will place a post request to download a file from mbed website. It will do a USSD request and finally wait for incoming SMS. It will try to answer your SMS (try asking "where are you").
You should see a similar output in your preferred console program:
C027 Support Example Device Init Device Status: Device: SARA-G350 Power Save: Active SIM: Ready CCID: xxxxxxxxxxxxxxxxxxxxxxxxxxx IMEI: xxxxxxxxxxxxxxxxxxx IMSI: xxxxxxxxxxxxxxxxxxx Manufacturer: u-blox Model: SARA-G350 Version: 08.49 Network Check Network Status: Registration: Home Signal Strength: -87 dBm Operator: Swisscom Phone Number: +41xxxxxxxxxxx Network Join IP Address: xx.xx.xx.xx Socket Create Socket Connect Make a Http Post Request Socket Send Socket Recving Socket 0: 337 bytes pending Socket 0: 145 bytes pending Socket 0: closed by remote host Socket Recv "HTTP/1.1 200 OK Server: nginx/1.1.19 Date: Thu, 10 Apr 2014 13:09:02 GMT Content-Type: text/plain Connection: close Last-Modified: Fri, 27 Jul 2012 13:30:34 GMT Cache-Control: max-age=36000 Expires: Thu, 10 Apr 2014 20:43:53 GMT Vary: Accept-Encoding X-Mystery-Header: 260358892 X-be: web0_prod_sjc Age: 8709 Hello world! " Socket Close Socket Free Network Disconnect Send Ussd Command *#134# Got Ussd Answer: "UNKNOWN APPLICATION" Checking SMS and GPS GPS Location: 47.28xxx 8.56xxx GPS Location: 47.28xxx 8.56xxx ... GPS Location: 47.28xxx 8.56xxx GPS Location: 47.28xxx 8.56xxx Network Status: Registration: Home Signal Strength: -89 dBm Operator: Swisscom Phone Number: +41xxxxxxxxx GPS Location: 47.28xxx 8.56xxx GPS Location: 47.28xxx 8.56xxx ...
main.cpp
- Committer:
- lawliet
- Date:
- 2014-02-25
- Revision:
- 0:4e3cb26f6019
- Child:
- 2:b77151f111a9
File content as of revision 0:4e3cb26f6019:
/* main.cpp 2013 Copyright (c) Seeed Technology Inc. All right reserved. Author:lawliet zou(lawliet.zou@gmail.com) 2014-02-18 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 "GPRSInterface.h" #include "mbed.h" #if defined(TARGET_LPC11U24)//SEEEDUINO_ARCH #define PIN_TX P1_22 #define PIN_RX P1_21 #elif defined(TARGET_LPC1768)//SEEEDUINO_ARCH_PRO #define PIN_TX P0_0 #define PIN_RX P0_1 #else //please redefine the following pins #define PIN_TX #define PIN_RX #endif GPRSInterface gprsInterface(PIN_TX,PIN_RX,19200,"cmnet",NULL,NULL); int main(void) { // use DHCP gprsInterface.init(); // attempt DHCP while(false == gprsInterface.connect()) { wait(2); } // successful DHCP printf("IP Address is %s\n", gprsInterface.getIPAddress()); TCPSocketConnection sock; if(false == sock.connect("mbed.org", 80)) { return -1; } char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\r\n\r\n"; sock.send_all(http_cmd, sizeof(http_cmd)-1); char buffer[512]; int ret; while (true) { ret = sock.receive(buffer, sizeof(buffer)-1); if (ret <= 0) break; buffer[ret] = '\0'; printf("Recv %d bytes:\n%s\n",ret,buffer); } sock.close(); gprsInterface.disconnect(); return 0; }