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: main.cpp
- Revision:
- 5:9fa79cb5ec98
- Parent:
- 3:60f5f6d5f765
- Child:
- 6:060cb9725ce3
--- a/main.cpp Mon Dec 20 14:21:40 2010 +0000 +++ b/main.cpp Wed Jan 12 11:18:44 2011 +0000 @@ -22,6 +22,7 @@ #include "EthernetNetIf.h" #include "NTPClient.h" #include "HTTPClient.h" +#include "Agentbed.h" #ifdef USE_I2CLEDDISP #include "I2CLEDDisp.h" @@ -57,11 +58,16 @@ DigitalOut led_g(p25), led_y(p26); DigitalIn eth_link(P1_25), eth_speed(P1_26); +extern AgentbedClass Agentbed; +extern uint32_t locUpTime; + void writefile (char *); void pachube (char *); void twitter (); +void weatherstations (); void ntpdate (); int check_action (char); +void pduReceived (); float get_photo (AnalogIn &ain) { float f; @@ -126,6 +132,11 @@ twitter(); } } + if (check_action('S')) { + if (conf.ipaddr[0] && conf.stations_id[0] && conf.stations_pin[0]) { + weatherstations(); + } + } } void init () { @@ -161,15 +172,22 @@ } pc.printf("Ethernet: %d.%d.%d.%d\r\n", eth->getIp()[0], eth->getIp()[1], eth->getIp()[2], eth->getIp()[3]); - if (conf.ipaddr[0] && conf.ntpserver[0]) { - // ntp - pc.printf("Ntp: %s\r\n", conf.ntpserver); - ntpdate(); - } + if (conf.ipaddr[0]) { + + if (conf.ntpserver[0]) { + // ntp + pc.printf("Ntp: %s\r\n", conf.ntpserver); + ntpdate(); + } - if (conf.ipaddr[0]) { clientP = new HTTPClient; clientT = new HTTPClient; + + if (conf.snmp_commname[0]) { + Agentbed.begin(conf.snmp_commname, "None", SNMP_DEFAULT_PORT, eth); + Agentbed.onPduReceive(pduReceived); + pc.printf("Snmp community name: %s\r\n", conf.snmp_commname); + } } } @@ -301,10 +319,9 @@ // pc.putc('.'); led_g = eth_link ? 1 : 0; led_y = eth_speed ? 1 : 0; -#ifdef NONBLOCKING Net::poll(); -#endif } timer.reset(); + locUpTime = locUpTime + (conf.interval * 100); } }