test

Dependencies:   C027 HTTPClient UbloxUSBModem mbed

Fork of C027_HTTPClientTest by u-blox

Committer:
vwochnik
Date:
Mon Mar 03 16:47:10 2014 +0000
Revision:
13:bcdb607b2c76
Parent:
11:ab536fc3a722
Child:
17:99b8b4aa577b
fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:f3f18ac13e0c 1 #include "mbed.h"
mazgch 6:77c131006c67 2 #include "C027.h"
mazgch 6:77c131006c67 3 #include "UbloxUSBGSMModem.h"
mazgch 6:77c131006c67 4
donatien 0:f3f18ac13e0c 5 #include "HTTPClient.h"
donatien 0:f3f18ac13e0c 6
mazgch 10:e2315bcdd7be 7 C027 c027;
mazgch 10:e2315bcdd7be 8
vwochnik 11:ab536fc3a722 9 int main(void)
donatien 0:f3f18ac13e0c 10 {
vwochnik 11:ab536fc3a722 11 c027.mdmWakeup();
vwochnik 11:ab536fc3a722 12 c027.mdmReset();
vwochnik 11:ab536fc3a722 13 c027.mdmPower(true);
mazgch 6:77c131006c67 14 UbloxUSBGSMModem modem; // for LISA-C use the UbloxUSBCDMAModem instead
donatien 1:6ea9ac27702c 15 HTTPClient http;
donatien 1:6ea9ac27702c 16 char str[512];
mazgch 7:c558c74ceb0f 17
vwochnik 11:ab536fc3a722 18 puts("Trying to connect to modem...");
vwochnik 11:ab536fc3a722 19 int ret = modem.connect("public4.m2minternet.com"); // eventaully set another apn here
mazgch 8:95a97898084a 20 if(ret)
mazgch 8:95a97898084a 21 {
mazgch 8:95a97898084a 22 printf("Could not connect %d\n", ret);
mazgch 7:c558c74ceb0f 23 return;
donatien 1:6ea9ac27702c 24 }
mazgch 8:95a97898084a 25
donatien 1:6ea9ac27702c 26 //POST data
donatien 0:f3f18ac13e0c 27 HTTPText text(str, 512);
vwochnik 13:bcdb607b2c76 28 // LONG AND SHORT REQUESTS
vwochnik 11:ab536fc3a722 29 HTTPText data("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
vwochnik 11:ab536fc3a722 30 //HTTPText data("23123123lala");
donatien 1:6ea9ac27702c 31 printf("Trying to post data...\n");
vwochnik 11:ab536fc3a722 32 ret = http.post("http://nocore.info:8888/", data, &text);
mazgch 7:c558c74ceb0f 33 if (!ret) {
mazgch 7:c558c74ceb0f 34 printf("Executed POST successfully - read %d characters\n", strlen(str));
mazgch 7:c558c74ceb0f 35 printf("Result: %s\n", str);
mazgch 7:c558c74ceb0f 36 } else {
mazgch 7:c558c74ceb0f 37 printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
donatien 0:f3f18ac13e0c 38 }
mazgch 7:c558c74ceb0f 39
mazgch 7:c558c74ceb0f 40 modem.disconnect();
mazgch 10:e2315bcdd7be 41 c027.mdmPower(false);
mazgch 10:e2315bcdd7be 42
mazgch 7:c558c74ceb0f 43 return 0;
donatien 0:f3f18ac13e0c 44 }