test
Dependencies: C027 HTTPClient UbloxUSBModem mbed
Fork of C027_HTTPClientTest by
main.cpp@17:99b8b4aa577b, 2014-03-06 (annotated)
- Committer:
- vwochnik
- Date:
- Thu Mar 06 21:42:57 2014 +0000
- Revision:
- 17:99b8b4aa577b
- Parent:
- 13:bcdb607b2c76
fix
Who changed what in which revision?
User | Revision | Line number | New 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); |
vwochnik | 17:99b8b4aa577b | 33 | |
mazgch | 7:c558c74ceb0f | 34 | if (!ret) { |
mazgch | 7:c558c74ceb0f | 35 | printf("Executed POST successfully - read %d characters\n", strlen(str)); |
mazgch | 7:c558c74ceb0f | 36 | printf("Result: %s\n", str); |
mazgch | 7:c558c74ceb0f | 37 | } else { |
mazgch | 7:c558c74ceb0f | 38 | printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); |
donatien | 0:f3f18ac13e0c | 39 | } |
mazgch | 7:c558c74ceb0f | 40 | |
mazgch | 7:c558c74ceb0f | 41 | modem.disconnect(); |
mazgch | 10:e2315bcdd7be | 42 | c027.mdmPower(false); |
mazgch | 10:e2315bcdd7be | 43 | |
mazgch | 7:c558c74ceb0f | 44 | return 0; |
donatien | 0:f3f18ac13e0c | 45 | } |