Temperature dashboard assignment
Dependencies: EthernetInterface LM75B mbed-rtos mbed
Fork of temperature-dashboard-start by
main.cpp@17:c8a4886ba688, 2016-01-16 (annotated)
- Committer:
- gimohd
- Date:
- Sat Jan 16 17:13:41 2016 +0000
- Revision:
- 17:c8a4886ba688
- Parent:
- 16:58c33ec28b2a
upload
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:bb128f0e952f | 1 | #include "mbed.h" |
sillevl | 16:58c33ec28b2a | 2 | #include "TempDashSocketConnection.h" |
sillevl | 16:58c33ec28b2a | 3 | #include "TemperatureSensor.h" |
sillevl | 16:58c33ec28b2a | 4 | #include <string.h> |
sillevl | 16:58c33ec28b2a | 5 | |
sillevl | 16:58c33ec28b2a | 6 | Serial pc(USBTX, USBRX); // tx, rx |
sillevl | 16:58c33ec28b2a | 7 | |
gimohd | 17:c8a4886ba688 | 8 | std::string key = "c74d97b01eae257e44aa9d5bade97baf"; |
gimohd | 17:c8a4886ba688 | 9 | std::string name = "kristof"; |
sillevl | 16:58c33ec28b2a | 10 | static const char SERVER[] = "labict.be"; |
sillevl | 16:58c33ec28b2a | 11 | static const int PORT = 45678; |
donatien | 0:bb128f0e952f | 12 | |
emilmont | 7:65188f4a8c25 | 13 | int main() { |
sillevl | 16:58c33ec28b2a | 14 | pc.baud(115200); |
donatien | 0:bb128f0e952f | 15 | EthernetInterface eth; |
donatien | 0:bb128f0e952f | 16 | eth.init(); //Use DHCP |
donatien | 0:bb128f0e952f | 17 | eth.connect(); |
sillevl | 16:58c33ec28b2a | 18 | pc.printf("IP Address is %s\r\n", eth.getIPAddress()); |
donatien | 0:bb128f0e952f | 19 | |
sillevl | 16:58c33ec28b2a | 20 | TemperatureSensor sensor(p28, p27, key, name); |
donatien | 0:bb128f0e952f | 21 | |
sillevl | 16:58c33ec28b2a | 22 | TempDashSocketConnection sock; |
emilmont | 7:65188f4a8c25 | 23 | |
sillevl | 16:58c33ec28b2a | 24 | while(1) { |
sillevl | 16:58c33ec28b2a | 25 | if (sensor.open()) { |
sillevl | 16:58c33ec28b2a | 26 | sock.connect(SERVER, PORT); |
sillevl | 16:58c33ec28b2a | 27 | sock.sendSensorData(sensor.getDataPacket()); |
sillevl | 16:58c33ec28b2a | 28 | sock.close(); |
sillevl | 16:58c33ec28b2a | 29 | wait(1.0); |
sillevl | 16:58c33ec28b2a | 30 | } |
emilmont | 7:65188f4a8c25 | 31 | } |
emilmont | 7:65188f4a8c25 | 32 | eth.disconnect(); |
donatien | 0:bb128f0e952f | 33 | } |