send with and without quotes
This commit is contained in:
parent
2cdbb1670c
commit
84cec432bd
1 changed files with 13 additions and 4 deletions
|
@ -24,15 +24,24 @@ class SSDPProtocol(MulticastProtocol):
|
||||||
self.notifications: List = []
|
self.notifications: List = []
|
||||||
self.replies: List = []
|
self.replies: List = []
|
||||||
|
|
||||||
async def m_search(self, address, timeout: int = 1, service=UPNP_ORG_IGD) -> SSDPDatagram:
|
def send_m_search_packet(self, service, address, man):
|
||||||
if (address, service) in self.discover_callbacks:
|
|
||||||
return self.discover_callbacks[(address, service)]
|
|
||||||
packet = SSDPDatagram(
|
packet = SSDPDatagram(
|
||||||
SSDPDatagram._M_SEARCH, host="{}:{}".format(SSDP_IP_ADDRESS, SSDP_PORT), st=service,
|
SSDPDatagram._M_SEARCH, host="{}:{}".format(SSDP_IP_ADDRESS, SSDP_PORT), st=service,
|
||||||
man="\"%s\"" % SSDP_DISCOVER, mx=1
|
man=man, mx=1
|
||||||
)
|
)
|
||||||
log.debug("sending packet to %s:%i: %s", address, SSDP_PORT, packet)
|
log.debug("sending packet to %s:%i: %s", address, SSDP_PORT, packet)
|
||||||
self.transport.sendto(packet.encode().encode(), (address, SSDP_PORT))
|
self.transport.sendto(packet.encode().encode(), (address, SSDP_PORT))
|
||||||
|
|
||||||
|
async def m_search(self, address, timeout: int = 1, service=UPNP_ORG_IGD) -> SSDPDatagram:
|
||||||
|
if (address, service) in self.discover_callbacks:
|
||||||
|
return self.discover_callbacks[(address, service)]
|
||||||
|
|
||||||
|
# D-Link, Cisco
|
||||||
|
self.send_m_search_packet(service, address, "%s" % SSDP_DISCOVER)
|
||||||
|
|
||||||
|
# DD-WRT
|
||||||
|
self.send_m_search_packet(service, address, SSDP_DISCOVER)
|
||||||
|
|
||||||
f: Future = Future()
|
f: Future = Future()
|
||||||
self.discover_callbacks[(address, service)] = f
|
self.discover_callbacks[(address, service)] = f
|
||||||
return await asyncio.wait_for(f, timeout)
|
return await asyncio.wait_for(f, timeout)
|
||||||
|
|
Loading…
Reference in a new issue