Monitor for central heating system (e.g. 2zones+hw) Supports up to 15 temp probes (DS18B20/DS18S20) 3 valve monitors Gas pulse meter recording Use stand-alone or with nodeEnergyServer See http://robdobson.com/2015/09/central-heating-monitor
Dependencies: EthernetInterfacePlusHostname NTPClient Onewire RdWebServer SDFileSystem-RTOS mbed-rtos mbed-src
Revision 18:d419ccebc666, committed 2015-09-28
- Comitter:
- Bobty
- Date:
- Mon Sep 28 11:16:46 2015 +0000
- Parent:
- 17:ede9b4bbc4d6
- Child:
- 19:0367cb46d003
- Commit message:
- Updated to set the hostname of the unit
Changed in this revision
| EthernetInterface.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/EthernetInterface.lib Mon Sep 28 10:38:09 2015 +0000 +++ b/EthernetInterface.lib Mon Sep 28 11:16:46 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/EthernetInterface/#2fc406e2553f +https://developer.mbed.org/users/Bobty/code/EthernetInterfacePlusHostname/#8e692841213c
--- a/main.cpp Mon Sep 28 10:38:09 2015 +0000
+++ b/main.cpp Mon Sep 28 11:16:46 2015 +0000
@@ -8,6 +8,9 @@
#include "Watchdog.h"
#include "Logger.h"
+// System name (used for hostname)
+char systemName[20] = "RdGasUseMonitor";
+
// Web and UDB ports
const int WEBPORT = 80; // Port for web server
const int BROADCAST_PORT = 42853; // Arbitrarily chosen port number
@@ -23,7 +26,6 @@
DigitalOut led4(LED4); //server status
// Web server
-EthernetInterface eth;
UDPSocket sendUDPSocket;
Endpoint broadcastEndpoint;
@@ -237,11 +239,23 @@
// Get the current count from the SD Card
gasUseCounter.Init();
- // setup ethernet interface
- eth.init(); //Use DHCP
- eth.connect();
- pc.printf("IP Address is %s\r\n", eth.getIPAddress());
+ // Setup ethernet interface
+ char macAddr[6];
+ mbed_mac_address(macAddr);
+ pc.printf("Ethernet MAC address: %02x:%02x:%02x:%02x:%02x:%02x\r\n", macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], macAddr[5]);
+ pc.printf("Connecting to ethernet ...\r\n");
+
+ // Init ethernet
+ EthernetInterface::init();
+
+ // Using code described here https://developer.mbed.org/questions/1602/How-to-set-the-TCPIP-stack-s-hostname-pr/
+ // to setName on the ethernet interface
+ EthernetInterface::setName(systemName);
+
+ // Connect ethernet
+ EthernetInterface::connect();
+ pc.printf("IP Address: %s HostName %s\r\n", EthernetInterface::getIPAddress(), EthernetInterface::getName());
// NTP Time setter
Thread ntpTimeSetter(&ntp_thread);