-
-
Notifications
You must be signed in to change notification settings - Fork 346
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 framework #2115
UPnP framework #2115
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
If you find something useful feel free to use it in your SSDP component (documentation, sample, code, etc.).
Do you mean SSDP? When yes take a look at #2114 Thank you for your fantastic work ! |
Service requests and discovery are UPnP things. https://smingdev.readthedocs.io/en/feature-upnp/_inc/Sming/Libraries/UPnP/index.html. |
This library at present is focused on supporting devices, whereas your application is to control other devices. The SSDP library does support sending out search requests, and the responses flow into a callback handler. The UPnP DeviceHost class registers this so that all To initiate a search call
Have a look at DeviceHost.cpp to see how it interacts with SSDP. Using the full UPnP stack incoming SSDP messages get routed to a lambda callback in However, if you only care about SSDP and don't require any of the UPnP framework then you can use it stand-alone. |
9a83c96
to
76bb9d3
Compare
You can try discovery out with the Basic_UPnP sample and the above code fragment:
|
0a5e9be
to
5eecaa0
Compare
It would be great to allow Sming Applications to
@mikee47 I see in your last change how to search for a smart TV, but how to trigger a callback once such a device is found and get the reported headers? I guess this is quite easy and I am just missing to see it. |
@slaff No, you're not missing anything! The messages only appeared in debug output with I've now added an |
Found and fixed a bug in header parsing. Here's what my Chromecast reports:
Fetching the device description file:
I'd be curious to see what your Smart TV reports (I don't have a telly)... NB. The HTTP response headers contains |
This is getting interesting. I submit the following request:
and get this in response:
Hopefully you get something similar. |
This is what I get. Panasonic Viera TV. It has a running web browser and one can also get things like icons and control it remotely (soon also with Sming :) ) <?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:vli="urn:schemas-panasonic-com:vli" xmlns:viera="urn:schemas-panasonic-com:viera" xmlns:pxn="urn:schemas-panasonic-com:pxn">
<specVersion><major>1</major><minor>0</minor></specVersion>
<device>
<deviceType>urn:panasonic-com:device:p00RemoteController:1</deviceType>
<friendlyName>xxxxx_Series</friendlyName>
<manufacturer>Panasonic</manufacturer>
<modelName>Panasonic VIErA</modelName>
<modelNumber>S500</modelNumber>
<UDN>uuid:4D454930-0200-1000-8001-20C6EBB4B17A</UDN>
<viera:X_DMSUDN>uuid:4Dxxxxxxxxxxxxxx</viera:X_DMSUDN>
<viera:X_DMRUDN>uuid:4Dxxxxxxxxx</viera:X_DMRUDN>
<viera:X_NRCUDN>uuid:4Dxxxxxxxxxxxxxxxxxxx</viera:X_NRCUDN>
<viera:X_MHC_DEV_ID>4284xxxxxxxx</viera:X_MHC_DEV_ID>
<viera:X_VERSION>NRC-3.00</viera:X_VERSION>
<viera:X_DEVICE_TYPE>DTV</viera:X_DEVICE_TYPE>
<viera:X_KEY_TYPE>PAL-21,PAL-11,PAL-1</viera:X_KEY_TYPE>
<viera:X_PAD_TYPE></viera:X_PAD_TYPE>
<viera:X_NRCCAP>VR_DMR,VR_DMS,VR_VECTOR,VR_BROWSER,VR_LAUNCH,VR_MEDIADMS,VR_LVDMS,VR_UPDMS,VR_TUNER1,VR_TVMUTE,VR_MES,VR_UPBROWSER</viera:X_NRCCAP>
<iconList>
<icon>
<mimetype>image/png</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/nrc/dlna_icon_48.png</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/nrc/dlna_icon_120.png</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/nrc/dlna_icon_48.jpg</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/nrc/dlna_icon_120.jpg</url>
</icon>
</iconList>
<serviceList>
<service>
<serviceType>urn:panasonic-com:service:p00NetworkControl:1</serviceType>
<serviceId>urn:upnp-org:serviceId:p00NetworkControl</serviceId>
<SCPDURL>/nrc/sdd_0.xml</SCPDURL>
<controlURL>/nrc/control_0</controlURL>
<eventSubURL>/nrc/event_0</eventSubURL>
</service>
</serviceList>
</device>
</root>
|
@slaff Have you found details of what commands these |
|
Those JSON files are large! I'm preparing a PR for a JSON streaming parser which will help. |
You know about these existing libraries: https://www.arduino.cc/reference/en/libraries/json-streaming-parser-2/ and https://www.arduino.cc/reference/en/libraries/json-streaming-parser/ , right? |
LOL, yep, it's a port of that library... may have made some 'improvements' :-) |
b6a781d
to
9a0596d
Compare
May contain spaces which must be removed, for example: CONTENT-TYPE: text/xml ; charset="utf-8"\r\n
…ing. Library header paths changed to <Network/SSDP/...> and <Network/UPnP/...> Standardise on `toString()` functions Library directory structures revised: source code goes into `src` subdirectory to keep things tidy RapidXML assertions changed to runtime error handling - empty string (bodyparser bug) caused it to hang system
Quirk of build system means it's better to use relative paths "" instead of <>
Add NTP client to ensure system clock is correct. Without this the UPnP headers won't contain a DATE field. Revisions to Hue Emulator library to fix device notifications for standard devices.
…rate unique base URL.
…us request handling
@mikee47 Is this PR ready for merging? |
@slaff Yes, all done for now. |
The framework contains three libraries:
Basic_UPnP
sample gives an idea of what can be done. See the library README for further details,The main purpose for this library was to provide an Alexa-compatible interface. It was important to provide a smooth end-user experience so that device discovery is reliable and painless. As such, device discovery and presentation is essentially complete, tested and working.
Also included is the
Basic_Alexa
sample withHueEmulator
library.Devices will appear in Windows explorer under 'Network'. You can find more comprehensive test tools at https://www.meshcommander.com/upnptools (Windows only - Device Spy is the most interesting! See #2114 README for notes on testing in Linux.
Both samples will run in Host emulator mode.
Additional changes:
Add
isLocal()
methods to AccessPoint & Station classesAdd additional toString() functions/methods
Make SMING_ARCH available to code and use it to generate Hue device names
HTTP Headers
Add
Accept
to standard header fieldsMove HTTP header field name handling into separate unit, and add BasicHttpHeaders
Fix HTTP content type field parsing
May contain spaces which must be removed, for example:
Also map
application/xml
(as well astext/xml
) toMIME_XML
Fix LimitedMemoryStream, and add
getStreamPointer
methodAttempting to write data larger than available space discards all of it.
Correct behaviour is to write as much as possible, but still discard the remainder.
Also, seek operation (for reading) is now bi-directional between the start of the buffer and the current write position.
TODO:
TODO.rst
.