test
This commit is contained in:
parent
f5b7130083
commit
a0625153dc
2 changed files with 4 additions and 2 deletions
|
@ -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: {}:{}",
|
||||||
|
|
|
@ -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))
|
||||||
|
|
Loading…
Reference in a new issue