first commit
This commit is contained in:
23
test/control.py
Normal file
23
test/control.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import socket
|
||||
from protocol import build_frame
|
||||
|
||||
SERVER_IP = '127.0.0.1'
|
||||
SERVER_PORT = 9000
|
||||
|
||||
TARGET_DEVICE = 10000052
|
||||
|
||||
# 控制 2、3 开;5 关
|
||||
payload = bytes([
|
||||
0x02, 0x01,
|
||||
0x03, 0x01,
|
||||
0x05, 0x00
|
||||
])
|
||||
|
||||
frame = build_frame(0xA0, TARGET_DEVICE, payload)
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.connect((SERVER_IP, SERVER_PORT))
|
||||
# CTRL + device_id + frame
|
||||
msg = b'CTRL' + TARGET_DEVICE.to_bytes(4, 'little') + frame
|
||||
s.sendall(msg)
|
||||
print("[CONTROL] send command")
|
||||
Reference in New Issue
Block a user