Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upnp Presentation URL #423

Closed
xoseperez opened this issue Jan 15, 2018 · 7 comments
Closed

Upnp Presentation URL #423

xoseperez opened this issue Jan 15, 2018 · 7 comments
Assignees
Labels
enhancement New feature or request major ssdp
Milestone

Comments

@xoseperez
Copy link
Owner

Originally reported by: Peter (Bitbucket: PG1234, GitHub: PG1234)


Hi, can you please add the Upnp presentation Url function. With that it's possible to find the devices in the Windows Network Neighborhood and with Upnp tools. It's small, only some lines of code and helps a lot during commissioning or with DHCP configured devices.

Peter

@xoseperez
Copy link
Owner Author

Do you have a sample code? There is already an SSDP implementation (see #282) but I cannot test it.

@xoseperez
Copy link
Owner Author

Original comment by Peter (Bitbucket: PG1234, GitHub: PG1234):


Two things are nessesary:

  1. a multi(broad)cast

  2. a presentation webside
    server.on("/description.xml", .......
    );

A full example you can find here:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266SSDP/ESP8266SSDP.cpp

For the beginning please take a UUID from an example !

@xoseperez
Copy link
Owner Author

Original comment by Peter (Bitbucket: PG1234, GitHub: PG1234):


Or: Parts from my code

#!arduino


server.on("/description.xml", HTTP_GET, [](AsyncWebServerRequest * request) {
    StreamString output;
    if (output.reserve(1024))
    {
      uint32_t ip = WiFi.localIP();
      uint32_t chipId = ESP.getChipId();
      output.printf(ssdpTemplate,
                    IP2STR(&ip),
                    hostName,
                    chipId,
                    modelName,
                    modelNumber,
                    (uint8_t) ((chipId >> 16) & 0xff),
                    (uint8_t) ((chipId >>  8) & 0xff),
                    (uint8_t)   chipId        & 0xff
                   );
      request->send(200, "text/xml", (String)output);
    }
    else
    {
      request->send(500);
    }
  });

static const char* ssdpTemplate =
  "<?xml version=\"1.0\"?>"
  "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">"
  "<specVersion>"
  "<major>1</major>"
  "<minor>0</minor>"
  "</specVersion>"
  "<URLBase>http://%u.%u.%u.%u:80/</URLBase>"
  "<device>"
  "<deviceType>upnp:rootdevice</deviceType>"
  "<friendlyName>%s</friendlyName>"
  "<presentationURL>/</presentationURL>"
  "<serialNumber>%u</serialNumber>"
  "<modelName>%s</modelName>"
  "<modelNumber>%s</modelNumber>"
  "<modelURL>http://www.espressif.com</modelURL>"
  "<manufacturer>Espurna</manufacturer>"
  "<manufacturerURL>https://bitbucket.org/xoseperez/espurna/</manufacturerURL>"
  "<UDN>uuid:38323636-4558-4dda-9188-cda0e6%02x%02x%02x</UDN>"
  "</device>"
  "</root>\r\n"
  "\r\n";

setup_upnp();

void setup_upnp()
{
  Serial.printf("Starting Upnp...\n");

  SSDP.setSchemaURL("description.xml");
  SSDP.setHTTPPort(80);
  SSDP.setName("Espurna");
  SSDP.setSerialNumber(String(ESP.getChipId()));
  SSDP.setURL("/");
  SSDP.setModelName("Espurna S on off Touch Sensor");
  SSDP.setModelNumber("929000226503");
  SSDP.setModelURL("http://www.sonoxxf.de/");
  SSDP.setManufacturer("sonoxxf");
  SSDP.setManufacturerURL("https://bitbucket.org/xoseperez/espurna/");
  SSDP.setDeviceType("upnp:rootdevice"); //https://github.com/esp8266/Arduino/issues/2283
  SSDP.begin();

  Serial.println("OK");
}

@xoseperez xoseperez added major enhancement New feature or request labels Jan 24, 2018
@xoseperez xoseperez added this to the 1.12.2 milestone Jan 24, 2018
@xoseperez xoseperez self-assigned this Jan 26, 2018
@xoseperez
Copy link
Owner Author

Will be released with 1.12.2

@ghost
Copy link

ghost commented Nov 11, 2018

Hi - it works well !
Looks like this in Win7:

2018-11-11 07_52_54-netzwerk

eigenschaften von espurna_29dbbb_0

Two things:

  1. It's no tnessesary to report each relay/switch. Only the hole device.
  2. Something is wrong with the data (mayby one parameter missing) the simple double click on the icon doesn't open the browser. I will check this.

(The Sonoff GW has no Upnp enabled ?)

Additional a description field in the Espurna Settings would be interesting. Like 'Switch in the Kitchen'. This could than also be visible in the Upnp Properties.

Peter

@philbowles
Copy link

I know I'm a year too late, but if you would prefer them to look like this:
image

..then let me know: it's pretty easy change...

@mcspr
Copy link
Collaborator

mcspr commented Jan 10, 2020

If you mean Belkin names from the screenshot above, I think those are from Alexa (back when it was announcing as Belkin Wemo and not Hue bridge)
Stuff that was added is enabled via SSDP_SUPPORT=1 define:
https://github.com/xoseperez/espurna/blob/master/code/espurna/ssdp.ino

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request major ssdp
Projects
None yet
Development

No branches or pull requests

3 participants