linknlink 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {linknlink-0.2.2 → linknlink-0.2.4}/PKG-INFO +1 -1
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink/remote.py +16 -12
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink.egg-info/PKG-INFO +1 -1
- {linknlink-0.2.2 → linknlink-0.2.4}/setup.py +1 -1
- {linknlink-0.2.2 → linknlink-0.2.4}/LICENSE +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/README.md +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink/__init__.py +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink/const.py +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink/device.py +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink/exceptions.py +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink/protocol.py +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink/sensor.py +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink.egg-info/SOURCES.txt +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink.egg-info/dependency_links.txt +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink.egg-info/not-zip-safe +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink.egg-info/requires.txt +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/linknlink.egg-info/top_level.txt +0 -0
- {linknlink-0.2.2 → linknlink-0.2.4}/setup.cfg +0 -0
|
@@ -22,12 +22,17 @@ class ehub(Device):
|
|
|
22
22
|
# sensor function
|
|
23
23
|
def _send(self, command: int, data: bytes = b"") -> bytes:
|
|
24
24
|
"""Send a packet to the device."""
|
|
25
|
-
|
|
25
|
+
if 20000 <= self.devtype <= 29999:
|
|
26
|
+
packet = struct.pack("<HI", len(data) + 4, command) + data
|
|
27
|
+
else:
|
|
28
|
+
packet = struct.pack("<I", command) + data
|
|
26
29
|
resp = self.send_packet(0x6A, packet)
|
|
27
30
|
e.check_error(resp[0x22:0x24])
|
|
28
31
|
payload = self.decrypt(resp[0x38:])
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
if 20000 <= self.devtype <= 29999:
|
|
33
|
+
p_len = struct.unpack("<H", payload[:0x2])[0]
|
|
34
|
+
return payload[0x6 : p_len + 2]
|
|
35
|
+
return payload[0x4:]
|
|
31
36
|
|
|
32
37
|
def check_sensors(self) -> dict:
|
|
33
38
|
"""Return the state of the sensors."""
|
|
@@ -95,12 +100,17 @@ class eremote(Device):
|
|
|
95
100
|
|
|
96
101
|
def _send(self, command: int, data: bytes = b"") -> bytes:
|
|
97
102
|
"""Send a packet to the device."""
|
|
98
|
-
|
|
103
|
+
if 20000 <= self.devtype <= 29999:
|
|
104
|
+
packet = struct.pack("<HI", len(data) + 4, command) + data
|
|
105
|
+
else:
|
|
106
|
+
packet = struct.pack("<I", command) + data
|
|
99
107
|
resp = self.send_packet(0x6A, packet)
|
|
100
108
|
e.check_error(resp[0x22:0x24])
|
|
101
109
|
payload = self.decrypt(resp[0x38:])
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
if 20000 <= self.devtype <= 29999:
|
|
111
|
+
p_len = struct.unpack("<H", payload[:0x2])[0]
|
|
112
|
+
return payload[0x6 : p_len + 2]
|
|
113
|
+
return payload[0x4:]
|
|
104
114
|
|
|
105
115
|
def _sendV2(self, command: int, data: bytes = b"") -> bytes:
|
|
106
116
|
"""Send a packet to the device."""
|
|
@@ -133,8 +143,6 @@ class eremote(Device):
|
|
|
133
143
|
while True:
|
|
134
144
|
# 接收数据
|
|
135
145
|
data, client_address = udp_server_socket.recvfrom(1024)
|
|
136
|
-
print(f"收到来自 {client_address} 的消息:{data.decode('utf-8')}")
|
|
137
|
-
|
|
138
146
|
if self.cb:
|
|
139
147
|
try:
|
|
140
148
|
data_dict = json.loads(data.decode('utf-8'))
|
|
@@ -153,16 +161,12 @@ class eremote(Device):
|
|
|
153
161
|
"""Send a packet to the device."""
|
|
154
162
|
while True:
|
|
155
163
|
data = (("""{"port":%s, "timeout":60}""") % (self.Port)).encode('utf-8')
|
|
156
|
-
print(data)
|
|
157
|
-
print(len(data) + 4)
|
|
158
164
|
packet = struct.pack("<I", 20000) + data
|
|
159
165
|
# packet = struct.pack("<HI", len(data) + 4, 20000) + data
|
|
160
|
-
print(packet.hex())
|
|
161
166
|
try:
|
|
162
167
|
resp = self.send_packet(0x6A, packet)
|
|
163
168
|
except Exception as e:
|
|
164
169
|
print(e)
|
|
165
|
-
print(resp.hex())
|
|
166
170
|
time.sleep(60)
|
|
167
171
|
|
|
168
172
|
def getalldev(self) -> dict:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|