This commit is contained in:
Jack Robison 2018-07-29 00:54:16 -04:00
parent f5b7130083
commit a0625153dc
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 4 additions and 2 deletions

View file

@ -25,6 +25,8 @@ service_types = [
SSDP_IP_ADDRESS = '239.255.255.250' SSDP_IP_ADDRESS = '239.255.255.250'
SSDP_PORT = 1900 SSDP_PORT = 1900
SSDP_DISCOVER = "ssdp:discover" SSDP_DISCOVER = "ssdp:discover"
SSDP_ALL = "ssdp:all"
M_SEARCH_TEMPLATE = "\r\n".join([ M_SEARCH_TEMPLATE = "\r\n".join([
"M-SEARCH * HTTP/1.1", "M-SEARCH * HTTP/1.1",
"HOST: {}:{}", "HOST: {}:{}",

View file

@ -3,7 +3,7 @@ import binascii
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.protocol import DatagramProtocol from twisted.internet.protocol import DatagramProtocol
from txupnp.fault import UPnPError from txupnp.fault import UPnPError
from txupnp.constants import GATEWAY_SCHEMA, M_SEARCH_TEMPLATE, SSDP_DISCOVER, SSDP_IP_ADDRESS, SSDP_PORT from txupnp.constants import GATEWAY_SCHEMA, M_SEARCH_TEMPLATE, SSDP_DISCOVER, SSDP_IP_ADDRESS, SSDP_PORT, SSDP_ALL
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -75,7 +75,7 @@ class SSDPProtocol(DatagramProtocol):
return self._sem.run(self.do_start) return self._sem.run(self.do_start)
def send_m_search(self): def send_m_search(self):
data = M_SEARCH_TEMPLATE.format(self.ssdp_address, self.ssdp_port, GATEWAY_SCHEMA, SSDP_DISCOVER, self.ttl) data = M_SEARCH_TEMPLATE.format(self.ssdp_address, self.ssdp_port, GATEWAY_SCHEMA, SSDP_ALL, self.ttl)
try: try:
log.info("sending m-search (%i bytes) to %s:%i", len(data), self.ssdp_address, self.ssdp_port) log.info("sending m-search (%i bytes) to %s:%i", len(data), self.ssdp_address, self.ssdp_port)
self.transport.write(data.encode(), (self.ssdp_address, self.ssdp_port)) self.transport.write(data.encode(), (self.ssdp_address, self.ssdp_port))