SSDP Server - working version provides SSDP based network discovery, and with a companion web server, may provide other functionalities.

Dependents:   X10Svr SSDP_Server

Revision:
7:1e8c677e3d28
Parent:
6:9df748509c3d
Child:
8:e8f0dc2b78c4
--- a/SSDP.cpp	Sun Nov 18 04:01:58 2018 +0000
+++ b/SSDP.cpp	Mon Nov 19 01:16:59 2018 +0000
@@ -84,13 +84,11 @@
         ShowSignOfLife(2);
         int n = server.receiveFrom(client, buffer, sizeof(buffer)-1);
         if (n > 0) {
-            buffer[n] = '\0';
-        }
-        if (n) {
             char * p = buffer;
             volatile int delay = 0;
             uint8_t mask = 0x00;    // fragments we found in the received packet
             
+            buffer[n] = '\0';
             INFO("SSDP receiveFrom %d bytes from %s:%d", n, 
                 client.get_address(), client.get_port());
             INFO("SSDP\n%s", buffer);
@@ -107,6 +105,8 @@
                         delay = atoi(p + 3);
                     } else if (sw_stristr(p, "ST:") && sw_stristr(p, "upnp:rootdevice")) {
                         mask |= 0x08;
+                    } else if (sw_stristr(p, "ST:") && sw_stristr(p, "ssdp:all")) {
+                        mask |= 0x08;
                     } else if (sw_stristr(p, "HOST: ")) {
                         mask |= 0x10;                               // HOST: 239.255.255.250:49152
                         char * pColon = strchr(p+6, ':');