Add support for HS105 protocol

Compared to the HS100 and HS110, where messages sent and received
begin with a four-byte header that can be safely ignored (and set to
zero in the existing code), the HS105 mini-plug requires queries to
have a correct length header matching the message length.

This changeset provides such a header when sending queries. We still
ignore the header when receiving responses from the smart plug.
This commit is contained in:
David Haguenauer 2017-12-29 23:13:41 -05:00
parent 953f429f84
commit 61f68c8ea9
1 changed files with 2 additions and 1 deletions

View File

@ -21,6 +21,7 @@
#
import socket
import argparse
import struct
version = 0.1
@ -51,7 +52,7 @@ commands = {'info' : '{"system":{"get_sysinfo":{}}}',
# XOR Autokey Cipher with starting key = 171
def encrypt(string):
key = 171
result = "\0\0\0\0"
result = struct.pack(">I", len(string))
for i in string:
a = key ^ ord(i)
key = a