compile ok 20140330 , update mbed and mbed-rtos
Dependencies: C12832 EthernetInterface HTTPClient mbed-rtos mbed MbedJSONValue
Fork of HTTPClient_HelloWorld by
main.cpp
- Committer:
- lamadio
- Date:
- 2014-04-25
- Revision:
- 5:6d5842b97059
- Parent:
- 4:b157cc2de561
- Child:
- 6:e822b760261d
File content as of revision 5:6d5842b97059:
#include "mbed.h" #include "EthernetInterface.h" #include "HTTPClient.h" #include "C12832.h" #include "MbedJSONValue.h" EthernetInterface eth; HTTPClient http; char str[2048]; C12832 lcd(p5, p7, p6, p8, p11); int main() { eth.init(); //Use DHCP eth.connect(); //GET data lcd.printf("\nTrying to fetch page...\n"); int ret = http.get("https://dweet.io/get/latest/dweet/for/modern-wheel", str, sizeof(str)); if (!ret) { lcd.cls(); lcd.locate(0,0); lcd.printf("read %d", strlen(str)); MbedJSONValue v; const char* start = str; const char* end = (const char*)(str + strlen(str)); std::string err; parse(v, start, end, &err); if (!err.empty()) { lcd.cls(); lcd.printf("Error - %s", err.c_str()); } else { lcd.cls(); int mousex = v["with"][0]["content"]["mouse_x"].get<int>(); lcd.printf("Success %d", mousex); } } else { lcd.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); } while(1) { } eth.disconnect(); }