linknlink 0.2.2__tar.gz → 0.2.3__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.3
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,7 +22,10 @@ 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:])
@@ -95,7 +98,10 @@ class eremote(Device):
95
98
 
96
99
  def _send(self, command: int, data: bytes = b"") -> bytes:
97
100
  """Send a packet to the device."""
98
- packet = struct.pack("<HI", len(data) + 4, command) + data
101
+ if 20000 <= self.devtype <= 29999:
102
+ packet = struct.pack("<HI", len(data) + 4, command) + data
103
+ else:
104
+ packet = struct.pack("<I", command) + data
99
105
  resp = self.send_packet(0x6A, packet)
100
106
  e.check_error(resp[0x22:0x24])
101
107
  payload = self.decrypt(resp[0x38:])
@@ -133,8 +139,6 @@ class eremote(Device):
133
139
  while True:
134
140
  # 接收数据
135
141
  data, client_address = udp_server_socket.recvfrom(1024)
136
- print(f"收到来自 {client_address} 的消息:{data.decode('utf-8')}")
137
-
138
142
  if self.cb:
139
143
  try:
140
144
  data_dict = json.loads(data.decode('utf-8'))
@@ -153,16 +157,12 @@ class eremote(Device):
153
157
  """Send a packet to the device."""
154
158
  while True:
155
159
  data = (("""{"port":%s, "timeout":60}""") % (self.Port)).encode('utf-8')
156
- print(data)
157
- print(len(data) + 4)
158
160
  packet = struct.pack("<I", 20000) + data
159
161
  # packet = struct.pack("<HI", len(data) + 4, 20000) + data
160
- print(packet.hex())
161
162
  try:
162
163
  resp = self.send_packet(0x6A, packet)
163
164
  except Exception as e:
164
165
  print(e)
165
- print(resp.hex())
166
166
  time.sleep(60)
167
167
 
168
168
  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.3
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.3'
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