Skip to content

Instantly share code, notes, and snippets.

@AlexxIT
Created January 13, 2020 13:56
Show Gist options
  • Save AlexxIT/3b163770e8d0c9edc0919c9f3ccc716b to your computer and use it in GitHub Desktop.
Save AlexxIT/3b163770e8d0c9edc0919c9f3ccc716b to your computer and use it in GitHub Desktop.
import socket
_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
_socket.settimeout(5.0)
try:
_socket.sendto('{"cmd":"whois"}'.encode(), ('224.0.0.50', 4321))
recv = _socket.recvfrom(1024)
print(recv)
except Exception as e:
print('ERROR', e)
finally:
_socket.close()
import socket
HOST = '192.168.1.123'
MAC = '04:CF:8C:XX:XX:XX'
sid = MAC.replace(':', '').lower()
_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
_socket.settimeout(10.0)
try:
_socket.sendto(f'{{"cmd":"read","sid":"{sid}"}}'.encode(), (HOST, 9898))
recv = _socket.recvfrom(1024)
print(recv)
except Exception as e:
print('ERROR', e)
finally:
_socket.close()
@AlexxIT
Copy link
Author

AlexxIT commented Jan 13, 2020

Первый скрипт найдёт Xiaomi Gateway в сети (в режиме разработчика).
Второй скрипт узнает у Gateway его состояние (необходимо заменить HOST и MAC на свои, можно узнать в окне, где включается режим разработчика).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment