mbed Weather Platform firmware http://mbed.org/users/okini3939/notebook/mbed-weather-platform-firmware/
Dependencies: EthernetNetIf SDHCFileSystem I2CLEDDisp Agentbed NTPClient_NetServices mbed BMP085 HTTPClient ConfigFile I2CLCD
Diff: func.cpp
- Revision:
- 9:8c63e4f3edab
- Parent:
- 7:0d3484dc13a9
- Child:
- 10:848a2205aed1
--- a/func.cpp Wed Jan 26 16:28:52 2011 +0000 +++ b/func.cpp Tue Feb 22 14:40:11 2011 +0000 @@ -19,7 +19,7 @@ extern int seq; extern char filename[]; extern Config conf; -extern DigitalOut led1, led2, led3, led4; +extern DigitalOut led_y, led2; extern EthernetNetIf *eth; extern NTPClient *ntp; @@ -30,7 +30,6 @@ void writefile (char *buf) { FILE *fp; - led3 = 1; fp = fopen(filename, "a"); if (fp) { fprintf(fp, buf); @@ -39,14 +38,13 @@ led2 = 0; conf.filetype = 0; } - led3 = 0; } void weatherstations () { char post_data[200]; HTTPText postContent("application/x-www-form-urlencoded"); - led3 = 1; + led_y = 0; strcpy(post_data, "fcd="); strcat(post_data, conf.stations_id); strcat(post_data, "&pin="); @@ -61,14 +59,13 @@ #else clientP->post(STATION_URL, postContent, NULL); #endif - led3 = 0; } void pachube (char *buf) { char uri[100]; HTTPText csvContent("text/csv"); - led3 = 1; + led_y = 0; clientP->setRequestHeader("X-PachubeApiKey", conf.pachube_apikey); csvContent.set(buf); strcpy(uri, "http://api.pachube.com/v1/feeds/"); @@ -81,7 +78,6 @@ #else clientP->post(uri, csvContent, NULL); #endif - led3 = 0; } void cb_clientP (HTTPResult status) { @@ -175,7 +171,7 @@ HTTPMap msg; char buf[170]; - led3 = 1; + led_y = 0; twitstr(buf, sizeof(buf)); msg["status"] = buf; @@ -187,13 +183,13 @@ #else clientT->post(TWITTER_URL, msg, NULL); #endif - led3 = 0; } void ntpdate () { ntp = new NTPClient; Host ntpserver(IpAddr(), 123, conf.ntpserver); + led_y = 0; #ifdef NONBLOCKING Net::poll(); ntp->setTime(ntpserver, &cb_settime); @@ -207,6 +203,7 @@ void cb_settime (NTPResult status) { if (status == NTP_OK) { + led_y = 0; time_t sec = time(NULL) + (60 * 60 * TIMEZONE); set_time(sec); pc.printf("Ntp success: %s\r\n", ctime(&sec));