Simple Server for the Simple Services Discovery Protocol
SSDP allows devices on LAN to announce themselves and their services to other devices.
If available in Hex, the package can be installed as:
-
Add nerves_ssdp_server to your list of dependencies in
mix.exs
:def deps do [{:nerves_ssdp_server, "~> 0.2.2"}] end
-
Ensure nerves_ssdp_server is started before your application:
def application do [applications: [:nerves_ssdp_server]] end
In SSDP, every service needs to define a USN (unique service name), and a ST (service type). That's the minimum required to publish a service. With that info, it's as simple as this:
alias Nerves.SSDPServer
SSDPServer.publish "my_unique_service_name", "my-service-type"
Other parameters you might specify for the second parameter to publish
are included as fields of the published service. For instance, you can do..
alias Nerves.SSDPServer
@ssdp_fields [
location: "http://localhost:3000/myservice.json",
server: "MyServerName",
"cache-control": "max-age=1800"
]
SSDPServer.publish "my-service-name", "my-service-type", @ssdp_fields
You can call publish
to publish multiple services, each with a unique USN, but you can only publish each USN once, as per the SSDP spec.
- LOCATION if present, specifies a URL to grab a cell description
Here is are some links with background information about SSDP.
http://www.w3.org/TR/discovery-api/#simple-service-discovery-protocol-ssdp http://www.upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0-20080424.pdf