Incorrectly parsed response from `miiocli discover`
xobs opened this issue · comments
Describe the bug
The command miiocli discover
appears to be incorrectly parsing the response from miiocli discover
. When issued against a device, the command line is completely silent. However, a tcpdump shows that the device is actually responding.
Version information (please complete the following information):
- OS: Windows 11
- python-miio: [Use
miiocli -d discover --no-mdns --handshake --network 192.168.99.1
]
Device information:
If the issue is specific to a device [Use miiocli device --ip <ip address> --token <token> info
]:
- Model: dmaker-fan-p39
- Hardware version: RTL8720C
- Firmware version: 2.2.2
To Reproduce
Steps to reproduce the behavior:
- Put the dmaker-fan-p39 in "Pairing Mode"
- Connect to its AP
- Run
miiocli -d discover --no-mdns --handshake --network 192.168.99.1
Expected behavior
It should print out the token information
Console output
From miiocli:
miiocli -d discover --no-mdns --handshake --network 192.168.99.1
DEBUG Got a response: Container: miioprotocol.py:122
data = Container:
data = b'' (total 0)
value = b'' (total 0)
offset1 = 32
offset2 = 32
length = 0
header = Container:
data = b"!1\x00 \x00\x00\x00\x00'4\xb2\xe3\x00\x00\x05\xdd" (total 16)
value = Container:
length = 32
unknown = 0
device_id = unhexlify('2734b2e3')
ts = 1970-01-01 00:25:01+00:00
offset1 = 0
offset2 = 16
length = 16
checksum = b'\xebo\ns8\xba\x90!\xe7\xca\xeb\x93\xa2\xbc(\x92' (total 16)
Wireshark dump of packet response:
0000 a4 b1 c1 c4 81 28 64 9e 31 32 d6 e8 08 00 45 00
0010 00 3c 21 6d 00 00 40 11 11 f0 c0 a8 63 01 c0 a8
0020 63 02 d4 31 e1 27 00 28 00 00 21 31 00 20 00 00
0030 00 00 27 34 b2 e3 00 00 05 42 eb 6f 0a 73 38 ba
0040 90 21 e7 ca eb 93 a2 bc 28 92
Output from miiocli -d device
, which also doesn't give anything useful unless I specify the -d
parameter:
miiocli -d device --ip 192.168.99.1 --token eb6f0a7338ba9021e7caeb93a2bc2892 info
Running command info
DEBUG Unknown model, trying autodetection click_common.py:183
DEBUG Got a response: Container: miioprotocol.py:122
data = Container:
data = b'' (total 0)
value = b'' (total 0)
offset1 = 32
offset2 = 32
length = 0
header = Container:
data = b"!1\x00 \x00\x00\x00\x00'4\xb2\xe3\x00\x00\x06\xb2" (total 16)
value = Container:
length = 32
unknown = 0
device_id = unhexlify('2734b2e3')
ts = 1970-01-01 00:28:34+00:00
offset1 = 0
offset2 = 16
length = 16
checksum = b'\xebo\ns8\xba\x90!\xe7\xca\xeb\x93\xa2\xbc(\x92' (total 16)
DEBUG Discovered 2734b2e3 with ts: 1970-01-01 00:28:34+00:00, token: b'eb6f0a7338ba9021e7caeb93a2bc2892' miioprotocol.py:84
DEBUG 192.168.99.1:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []} miioprotocol.py:176
DEBUG 192.168.99.1:54321 (ts: 1970-01-01 00:28:34+00:00, id: 1) << {'exe_time': 71, miioprotocol.py:206
'id': 1,
'result': {'ap': {'bssid': '00:00:00:00:00:00',
'primary': 0,
'rssi': 0,
'ssid': '25c829b1922d3123_miwifi'},
'fw_ver': '2.2.2',
'hw_ver': 'RTL8720C',
'ipflag': 1,
'life': 1714,
'mac': '64:9E:31:32:D6:E7',
'mcu_fw_ver': '0002',
'miio_ver': '0.0.9',
'mmfree': 34304,
'model': 'dmaker.fan.p39',
'netif': {'gw': '0.0.0.0', 'localIp': '0.0.0.0', 'mask': '0.0.0.0'},
'token': 'eb6f0a7338ba9021e7caeb93a2bc2892',
'wifi_fw_ver': 'WifiVer.N/A'}}
DEBUG Detected model dmaker.fan.p39 device.py:140
DEBUG Using * for dmaker.fan.p39, please add it to supported models for <class devicefactory.py:73
'miio.integrations.genericmiot.genericmiot.GenericMiot'>
DEBUG Unknown model, trying autodetection click_common.py:183
ERROR Exception: [WinError 10049] The requested address is not valid in its context click_common.py:56
Traceback (most recent call last):
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\miio\click_common.py", line 54, in
__call__
return self.main(*args, **kwargs)
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\miio\click_common.py", line 308, in wrap
and getattr(result, "__cli_output__", None) is not None
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\miio\deviceinfo.py", line 103, in
__cli_output__
dev = DeviceFactory.create(self.ip_address, self.token, force_generic_miot=True)
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\miio\devicefactory.py", line 101, in
create
dev.info()
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\miio\click_common.py", line 184, in _wrap
self._fetch_info()
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\miio\device.py", line 138, in _fetch_info
devinfo = DeviceInfo(self.send("miIO.info"))
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\miio\device.py", line 98, in send
return self._protocol.send(
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\miio\miioprotocol.py", line 162, in send
self.send_handshake()
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\miio\miioprotocol.py", line 66, in
send_handshake
m = MiIOProtocol.discover(self.ip)
File "C:\Users\Sean\.espressif\python_env\idf5.3_py3.10_env\lib\site-packages\miio\miioprotocol.py", line 117, in
discover
s.sendto(helobytes, (addr, 54321))
OSError: [WinError 10049] The requested address is not valid in its context