Nerves.SSDPServer v0.2.1 Nerves.SSDPServer

Implements a simple subset of the Simple Service Discovery Protocol.

This does not implement the full UPNP specification, but uses the multicast SSDP protocol in order to provide LAN presence annoucment and device discovery.

Summary

Types

Service Type — a string that identifies the type of SSDP service

Unique Service Identifier — Uniquely identifies the service, and must be unique on the local network

Functions

Publish the service, returning the USN (unique service name) for the service, which can later be used to unpublish the service

Stop publishing the service designated by usn

Types

st :: String.t

Service Type — a string that identifies the type of SSDP service.

usn :: String.t

Unique Service Identifier — Uniquely identifies the service, and must be unique on the local network.

Functions

publish(usn, st, fields \\ [])

Specs

publish(usn, st, Dict.t) ::
  {:ok, usn} |
  {:error, atom}

Publish the service, returning the USN (unique service name) for the service, which can later be used to unpublish the service.

  • usn (unique service name) - uniquely identifies the service, and must be unique on the local network. attempts to publish two services with the same usn on the same node will result in an error.

  • st (service type) :: SSDP Service Type - a string that identifies the type of service.

  • fields - Dict consiting of fields ot be added to the SSDP replies.

Examples

Simple Publishing

Nerves.SSDPServer.publish "my_unique_service_name", "my-service-type"

Publishing custom fields

Other parameters you might specify for the second paramter do publish are included as fields of the published service. For instance, you can do..

@ssdp_fields [
    location: "http://localhost:3000/myservice.json",
    server: "MyServerName",
    "cache-control": "max-age=1800"
]

Nerves.SSDPServer.publish "my-service-name", "my-service-type", @ssdp_fields
unpublish(usn)

Specs

unpublish(usn) :: :ok | {:error, atom}

Stop publishing the service designated by usn.