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:
parent
953f429f84
commit
61f68c8ea9
@ -21,6 +21,7 @@
|
|||||||
#
|
#
|
||||||
import socket
|
import socket
|
||||||
import argparse
|
import argparse
|
||||||
|
import struct
|
||||||
|
|
||||||
version = 0.1
|
version = 0.1
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ commands = {'info' : '{"system":{"get_sysinfo":{}}}',
|
|||||||
# XOR Autokey Cipher with starting key = 171
|
# XOR Autokey Cipher with starting key = 171
|
||||||
def encrypt(string):
|
def encrypt(string):
|
||||||
key = 171
|
key = 171
|
||||||
result = "\0\0\0\0"
|
result = struct.pack(">I", len(string))
|
||||||
for i in string:
|
for i in string:
|
||||||
a = key ^ ord(i)
|
a = key ^ ord(i)
|
||||||
key = a
|
key = a
|
||||||
|
Loading…
Reference in New Issue
Block a user