for znrobotics workshop
Dependencies: DHT22 HTTPClient SDFileSystem WIZnet_Library mbed
Fork of archlink_Temperture_dweetio by
This program is for seeed arch link, using wiznet w550 ethernet interface. not compatible with mbed ethernet interface.
Diff: main.cpp
- Revision:
- 6:dbf5cf5ca7b1
- Parent:
- 5:35f80d88820f
- Child:
- 7:98c5b9eba03a
--- a/main.cpp Thu Jun 16 03:09:43 2016 +0000 +++ b/main.cpp Thu Jun 16 03:34:49 2016 +0000 @@ -25,7 +25,7 @@ const int time_interval = 10; // 10 seconds; // timer event; -Timeout flipper; +Ticker flipper; void timer_ticked(); DigitalOut myled(LED1); @@ -45,47 +45,38 @@ printf("W5500 tested OK \r\n"); // start timer tick event. - flipper.attach(&timer_ticked, timer_interval); - - char str[512]; - char post_data[256]= ""; - - while(1) - { - float* th = temperature_get(); - printf("temperature: %.2f -- Humidity: %.2f.\r\n",th[0], th[1]); - - pc.printf("Posting message to znrobotics server.\r\n"); - // http://machine.address:port/did/temperature?param1=v1¶m2=v2 - sprintf(post_data, "http://192.168.1.222:3000/temperature?deviceid=%s&temperature=%.2f", DEVICE_ID, th[0]); - - HTTPClient http; - ret = http.get(get_msg, str, sizeof(str)); - if(!ret) - { - pc.printf("Result: %s\r\n", str); - } - else - { - pc.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); - } - wait(10); - } + flipper.attach(&timer_ticked, time_interval); } while(1) { - myled = 1; - printf("light on\r\n"); - wait(3); - myled = 0; - printf("light off\r\n"); - wait(3); + myled = !myled; + wait(10); } } void timer_ticked() { + char str[512]; + char post_data[256]= ""; + float* th = temperature_get(); + printf("temperature: %.2f -- Humidity: %.2f.\r\n",th[0], th[1]); + + pc.printf("Posting message to znrobotics server.\r\n"); + // http://machine.address:port/did/temperature?param1=v1¶m2=v2 + sprintf(post_data, "http://192.168.1.222:3000/temperature?deviceid=%s&temperature=%.2f", DEVICE_ID, th[0]); + pc.printf("post msg: %s\r\n", post_data); + + HTTPClient http; + ret = http.get(post_data, str, sizeof(str)); + if(!ret) + { + pc.printf("Result: %s\r\n", str); + } + else + { + pc.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); + } } int W5500_Test(void)