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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linknlink
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Python API for controlling linknlink devices
5
5
  Home-page: https://github.com/xuanxuan000/python-linknlink
6
6
  Author: Zhao Zehua
@@ -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
- packet = struct.pack("<HI", len(data) + 4, command) + data
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
- p_len = struct.unpack("<H", payload[:0x2])[0]
30
- return payload[0x6 : p_len + 2]
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
- packet = struct.pack("<HI", len(data) + 4, command) + data
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
- p_len = struct.unpack("<H", payload[:0x2])[0]
103
- return payload[0x6 : p_len + 2]
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linknlink
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Python API for controlling linknlink devices
5
5
  Home-page: https://github.com/xuanxuan000/python-linknlink
6
6
  Author: Zhao Zehua
@@ -5,7 +5,7 @@
5
5
  from setuptools import setup, find_packages
6
6
 
7
7
 
8
- version = '0.2.2'
8
+ version = '0.2.4'
9
9
 
10
10
  setup(
11
11
  name="linknlink",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes