From 84cec432bdf1860900a253de5a538d9214b4bf41 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Mon, 8 Oct 2018 18:14:56 -0400 Subject: [PATCH] send with and without quotes --- aioupnp/protocols/ssdp.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/aioupnp/protocols/ssdp.py b/aioupnp/protocols/ssdp.py index 5f65908..75f1194 100644 --- a/aioupnp/protocols/ssdp.py +++ b/aioupnp/protocols/ssdp.py @@ -24,15 +24,24 @@ class SSDPProtocol(MulticastProtocol): self.notifications: List = [] self.replies: List = [] - 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)] + def send_m_search_packet(self, service, address, man): packet = SSDPDatagram( 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) 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() self.discover_callbacks[(address, service)] = f return await asyncio.wait_for(f, timeout)