upnp.SSDP module

class upnp.SSDP.AnnouncerService

Bases: ssdp.SimpleServiceDiscoveryProtocol

Endpoint for UDP packets (used by asyncio)

connection_made(transport)

Called when the connection is made

Parameters:transport (asyncio.BaseTransport) – The endpoint transport
request_received(request, addr)

Handle a new SSDP packet

Parameters:
  • request – Request informations
  • addr – Adress of the peer
response_received(response, addr)

Not used

class upnp.SSDP.Answer(config, status_code, reason)

Bases: ssdp.SSDPResponse

Answer packet for M-SEARCH queries

send(device, ip, addr)

Send the UDP answer

Parameters:
  • device (upnp.Objects.Device) – Device to announce
  • ip (str) – IP of device
  • addr (str) – Destination IP
sendto(transport, addr)

Rewriting of raw sending method (error at the end of headers).

Parameters:
  • transport (asyncio.BaseTransport) – Transport to use
  • addr (str) – Destination address
class upnp.SSDP.Notify(config, device)

Bases: ssdp.SSDPRequest

SSDP Notify packet

send(ip, usn=None, transport=None)

Build and send the packet

Parameters:
  • ip (str) – Destination IP
  • usn (str) – USN to notify
  • transport (asyncio.BaseTransport) – Transport to use
sendto(transport, addr)

Rewriting of raw sending method (error at the end of headers).

Parameters:
  • transport (asyncio.BaseTransport) – Transport to use
  • addr (str) – Destination address
class upnp.SSDP.SSDP(annoncer, netBind='0.0.0.0')

Bases: object

Public class to handle SSDP protocol

dispose()

Close SSDP handling

initLoop(loop)

Initiate an asyncio event loop

Parameters:loop (asyncio.AbstractEventLoop) – An asyncio event loop
notify()

Send NOTIFY packets

class upnp.SSDP.SSDP_Protocol(config)

Bases: object

Simple class to send packets

answer(st, addr)

Answer to an M-SEARCH query

Parameters:
  • st (str) – Queried subject
  • addr ((str, int)) – Destination address of answer
getDevices(st)

Get all devices which match ST

Parameters:st (str) – Queried subject to match
Returns:List of devices that match query
Return type:list(upnp.Objects.Device)
notify(device, ip)

Send NOTIFY packets for a device (services and embedded devices)

Parameters:
provides(usn)

Check if USN is provided by root device

Parameters:usn (str) – USN to test
Returns:True if USN is provided
Return type:bool