check registered commands
This commit is contained in:
parent
752f603066
commit
87e9617499
1 changed files with 12 additions and 2 deletions
|
@ -160,6 +160,11 @@ class Gateway:
|
||||||
igd_args: OrderedDict = None, ssdp_socket: socket.socket = None,
|
igd_args: OrderedDict = None, ssdp_socket: socket.socket = None,
|
||||||
soap_socket: socket.socket = None, unicast: bool = False):
|
soap_socket: socket.socket = None, unicast: bool = False):
|
||||||
ignored: set = set()
|
ignored: set = set()
|
||||||
|
required_commands = [
|
||||||
|
'AddPortMapping',
|
||||||
|
'DeletePortMapping',
|
||||||
|
'GetExternalIPAddress'
|
||||||
|
]
|
||||||
while True:
|
while True:
|
||||||
if not igd_args:
|
if not igd_args:
|
||||||
m_search_args, datagram = await asyncio.wait_for(fuzzy_m_search(lan_address, gateway_address, timeout, ssdp_socket,
|
m_search_args, datagram = await asyncio.wait_for(fuzzy_m_search(lan_address, gateway_address, timeout, ssdp_socket,
|
||||||
|
@ -172,8 +177,13 @@ class Gateway:
|
||||||
gateway = cls(datagram, m_search_args, lan_address, gateway_address)
|
gateway = cls(datagram, m_search_args, lan_address, gateway_address)
|
||||||
log.debug('get gateway descriptor %s', datagram.location)
|
log.debug('get gateway descriptor %s', datagram.location)
|
||||||
await gateway.discover_commands(soap_socket)
|
await gateway.discover_commands(soap_socket)
|
||||||
log.debug('found gateway device %s', datagram.location)
|
requirements_met = all([required in gateway._registered_commands for required in required_commands])
|
||||||
return gateway
|
if not requirements_met:
|
||||||
|
log.debug("found gateway, but it does not implement required soap commands")
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
log.debug('found gateway device %s', datagram.location)
|
||||||
|
return gateway
|
||||||
except (asyncio.TimeoutError, UPnPError) as err:
|
except (asyncio.TimeoutError, UPnPError) as err:
|
||||||
log.debug("get %s failed (%s), looking for other devices", datagram.location, str(err))
|
log.debug("get %s failed (%s), looking for other devices", datagram.location, str(err))
|
||||||
ignored.add(datagram.location)
|
ignored.add(datagram.location)
|
||||||
|
|
Loading…
Reference in a new issue