X10 Server - IOT device to leverage a collection of old X10 devices for home automation and lighting control.

Dependencies:   IniManager mbed HTTPClient SWUpdate mbed-rtos Watchdog X10 SW_HTTPServer SW_String EthernetInterface TimeInterface SSDP

X10 Server

See the X10 Server Nodebook page

Revision:
0:de1dfa2ab813
Child:
4:5da66fab599c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jul 03 02:10:23 2018 +0000
@@ -0,0 +1,58 @@
+//
+// A simple SSDP example
+//
+#include "mbed.h"               // ver 120; mbed-rtos ver 111
+#include "EthernetInterface.h"  // ver 55
+#include "SW_HTTPServer.h"      // ver 50
+#include "TimeInterface.h"      // ver 23
+#include "Watchdog.h"           // ver 6
+#include "SW_String.h"          // ver 1
+#include "SSDP.h"               // ver 0
+
+#include "WebPages.h"           // Private handler for web queries
+
+RawSerial pc(USBTX, USBRX);
+
+EthernetInterface eth;
+TimeInterface ntp(&eth);
+Watchdog wd;
+time_t lastboottime;
+
+//FlashFileSystem flash("flash");             // static files here for reliability and speed
+LocalFileSystem local("local");             // some place to hold settings and maybe the static web pages
+
+const char * Server_Root = "/local";
+
+// public for the WebPages handler to see
+//
+const char * BUILD_DATE = __DATE__ " " __TIME__;
+const char * PROG_NAME = "SSDP Server";
+const char * My_Name = "MBED SSDP Node";
+const char * My_SerialNum = "0000001";
+const int Server_Port = 80;
+// end public information
+
+
+int main() {
+    pc.baud(460800);
+    pc.printf("\r\n%s Build %s\r\n", PROG_NAME, BUILD_DATE);
+    if (wd.WatchdogCausedReset()) {
+        pc.printf("**** Watchdog Event caused reset at %s ****\r\n", ntp.ctime(&lastboottime));
+    }
+    wd.Configure(45);       // very generous, but this is a network appliance, so a bit less deterministic.
+
+    eth.init(); //Use DHCP
+    eth.connect();
+    printf("IP: %s\n", eth.getIPAddress());
+    //Thread thr(SSDPListener, NULL, osPriorityLow);
+    HTTPServer svr(Server_Port, Server_Root, 15, 30, 20, 50, &pc);
+    svr.RegisterHandler("/", RootPage);
+    svr.RegisterHandler("/setup.xml", Setup_xml);
+    SSDP ssdp("Friendly Node", eth.getMACAddress(), eth.getIPAddress(), Server_Port);
+    
+    while (1) {
+        wd.Service();
+        svr.Poll();         // non-blocking, but also not deterministic
+        Thread::yield();
+    }
+}