USSDTest, working with SARA-G350 on C027
Dependencies: C027 UbloxUSBModem mbed
Fork of C027_HTTPClientTest by
main.cpp
- Committer:
- donatien
- Date:
- 2012-08-29
- Revision:
- 3:d104a904eeed
- Parent:
- 2:d1a092234f72
- Child:
- 4:47a1a2527e25
File content as of revision 3:d104a904eeed:
#include "mbed.h" #include "VodafoneUSBModem.h" #include "HTTPClient.h" void test(void const*) { VodafoneUSBModem modem; HTTPClient http; char str[512]; //int ret = modem.connect("pp.vodafone.co.uk"); int ret = modem.connect("SMART"); if(ret) { printf("Could not connect\n"); return; } //GET data printf("Trying to fetch page...\n"); 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 text(str, 512); map.put("Hello", "World"); map.put("test", "1234"); printf("Trying to post data...\n"); ret = http.post("http://httpbin.org/post", map, &text); 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()); } modem.disconnect(); while(1) { } } int main() { Thread testTask(test, NULL, osPriorityNormal, 1024 * 4); DigitalOut led(LED1); while(1) { led=!led; Thread::wait(1000); } return 0; }