Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C027_Support_AerCloud HTTPClient_AerCloud mbed
Fork of HTTPClient_Cellular_HelloWorld by
Revision 3:412a526d7054, committed 2014-05-12
- Comitter:
- mazgch
- Date:
- Mon May 12 09:17:35 2014 +0000
- Parent:
- 2:270e2d0bb85a
- Child:
- 4:7fd97087e573
- Commit message:
- cellular port of httpclient example
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C027.lib Mon May 12 09:17:35 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/ublox/code/C027/#89c45165ee87
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C027_Support.lib Mon May 12 09:17:35 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/ublox/code/C027_Support/#8071747a7cb3
--- a/EthernetInterface.lib Thu Aug 30 15:42:06 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/EthernetInterface/#a0ee3ae75cfa
--- a/main.cpp Thu Aug 30 15:42:06 2012 +0000
+++ b/main.cpp Mon May 12 09:17:35 2014 +0000
@@ -1,79 +1,125 @@
#include "mbed.h"
-#include "EthernetInterface.h"
#include "HTTPClient.h"
+#include "C027.h"
+#include "MDM.h"
-EthernetInterface eth;
-HTTPClient http;
+//----------------------------------------------------------------------
+// You may need to configure these parameters
+
+/** Set your secret SIM pin here "1234"
+*/
+#define SIMPIN NULL
+
+/** The APN of your network operator, sometimes it is "internet"
+ check your contract with the network operator
+*/
+#define APN "gprs.swisscom.ch"
+
+/** Set the user name for your APN, or NULL if not needed
+*/
+#define USERNAME NULL
+
+/** Set the password for your APN, or NULL if not needed
+*/
+#define PASSWORD NULL
+
+C027 c027;
+
char str[512];
int main()
{
- eth.init(); //Use DHCP
-
- eth.connect();
-
- //GET data
- printf("\nTrying to fetch page...\n");
- int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
- if (!ret)
- {
- printf("Page fetched successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
- }
- else
- {
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
+ // turn on the supplies of the Modem and the GPS
+ c027.mdmPower(true);
+ wait(2);
+ // Create the modem object
+ MDMSerial mdm;
- //POST data
- HTTPMap map;
- HTTPText inText(str, 512);
- map.put("Hello", "World");
- map.put("test", "1234");
- printf("\nTrying to post data...\n");
- ret = http.post("http://httpbin.org/post", map, &inText);
- if (!ret)
+ // initialize the modem
+ printf("Modem Initialize\r\n");
+ MDMParser::DevStatus devStatus;
+ bool mdmOk = mdm.init(SIMPIN, &devStatus);
+ if (mdmOk)
{
- printf("Executed POST successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
- }
- else
- {
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
+ // wait until we are connected
+ printf("Network Check\r\n");
+ MDMParser::NetStatus netStatus;
+ while (!mdm.checkNetStatus(&netStatus))
+ wait_ms(1000);
+
+ printf("Network Join\r\n");
+ // join the internet connection
+ MDMParser::IP ip = mdm.join(APN,USERNAME,PASSWORD);
+ if (ip != NOIP)
+ {
+ printf(" IP Address: " IPSTR "\r\n", IPNUM(ip));
+ HTTPClient http;
- //PUT data
- strcpy(str, "This is a PUT test!");
- HTTPText outText(str);
- //HTTPText inText(str, 512);
- printf("\nTrying to put resource...\n");
- ret = http.put("http://httpbin.org/put", outText, &inText);
- if (!ret)
- {
- printf("Executed PUT successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
- }
- else
- {
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
+ //GET data
+ printf("\nTrying to fetch page...\n");
+ int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
+ if (!ret)
+ {
+ printf("Page fetched successfully - read %d characters\n", strlen(str));
+ printf("Result: %s\n", str);
+ }
+ else
+ {
+ printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+ }
+
+ //POST data
+ HTTPMap map;
+ HTTPText inText(str, 512);
+ map.put("Hello", "World");
+ map.put("test", "1234");
+ printf("\nTrying to post data...\n");
+ ret = http.post("http://httpbin.org/post", map, &inText);
+ if (!ret)
+ {
+ printf("Executed POST successfully - read %d characters\n", strlen(str));
+ printf("Result: %s\n", str);
+ }
+ else
+ {
+ printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+ }
+
+ //PUT data
+ strcpy(str, "This is a PUT test!");
+ HTTPText outText(str);
+ //HTTPText inText(str, 512);
+ printf("\nTrying to put resource...\n");
+ ret = http.put("http://httpbin.org/put", outText, &inText);
+ if (!ret)
+ {
+ printf("Executed PUT successfully - read %d characters\n", strlen(str));
+ printf("Result: %s\n", str);
+ }
+ else
+ {
+ printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+ }
+
+ //DELETE data
+ //HTTPText inText(str, 512);
+ printf("\nTrying to delete resource...\n");
+ ret = http.del("http://httpbin.org/delete", &inText);
+ if (!ret)
+ {
+ printf("Executed DELETE successfully - read %d characters\n", strlen(str));
+ printf("Result: %s\n", str);
+ }
+ else
+ {
+ printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+ }
- //DELETE data
- //HTTPText inText(str, 512);
- printf("\nTrying to delete resource...\n");
- ret = http.del("http://httpbin.org/delete", &inText);
- if (!ret)
- {
- printf("Executed DELETE successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
+ mdm.disconnect();
+ }
}
- else
- {
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
+ mdm.powerOff();
+ c027.mdmPower(false);
- eth.disconnect();
-
- while(1) {
- }
+ while(true);
}
--- a/mbed-rtos.lib Thu Aug 30 15:42:06 2012 +0000 +++ b/mbed-rtos.lib Mon May 12 09:17:35 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#9654a71f5a90 +http://mbed.org/users/mbed_official/code/mbed-rtos/#5dfe422a963d
--- a/mbed.bld Thu Aug 30 15:42:06 2012 +0000 +++ b/mbed.bld Mon May 12 09:17:35 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/976df7c37ad5 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file


