python-aidot 0.3.1__tar.gz → 0.3.2__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.
- {python_aidot-0.3.1 → python_aidot-0.3.2}/PKG-INFO +1 -1
- {python_aidot-0.3.1 → python_aidot-0.3.2}/aidot/discover.py +18 -8
- {python_aidot-0.3.1 → python_aidot-0.3.2}/python_aidot.egg-info/PKG-INFO +1 -1
- {python_aidot-0.3.1 → python_aidot-0.3.2}/setup.py +1 -1
- {python_aidot-0.3.1 → python_aidot-0.3.2}/LICENSE +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/README.md +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/aidot/__init__.py +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/aidot/aes_utils.py +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/aidot/client.py +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/aidot/const.py +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/aidot/exceptions.py +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/aidot/lan.py +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/aidot/login_const.py +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/python_aidot.egg-info/SOURCES.txt +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/python_aidot.egg-info/dependency_links.txt +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/python_aidot.egg-info/requires.txt +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/python_aidot.egg-info/top_level.txt +0 -0
- {python_aidot-0.3.1 → python_aidot-0.3.2}/setup.cfg +0 -0
|
@@ -12,7 +12,7 @@ from .exceptions import AidotOSError
|
|
|
12
12
|
_LOGGER = logging.getLogger(__name__)
|
|
13
13
|
|
|
14
14
|
class BroadcastProtocol:
|
|
15
|
-
|
|
15
|
+
_is_closed = False
|
|
16
16
|
def __init__(self,callback,user_id):
|
|
17
17
|
self.aes_key = bytearray(32)
|
|
18
18
|
key_string = "T54uednca587"
|
|
@@ -28,6 +28,9 @@ class BroadcastProtocol:
|
|
|
28
28
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
|
29
29
|
|
|
30
30
|
def send_broadcast(self) -> None:
|
|
31
|
+
if self._is_closed is True:
|
|
32
|
+
_LOGGER.error(f"{self.user_id}:Connection is closed")
|
|
33
|
+
return
|
|
31
34
|
current_timestamp_milliseconds = int(time.time() * 1000)
|
|
32
35
|
seq = str(current_timestamp_milliseconds + 1)[-9:]
|
|
33
36
|
message = {
|
|
@@ -44,7 +47,10 @@ class BroadcastProtocol:
|
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
send_data = aes_encrypt(json.dumps(message).encode(),self.aes_key)
|
|
47
|
-
|
|
50
|
+
try:
|
|
51
|
+
self.transport.sendto(send_data, ('255.255.255.255', 6666))
|
|
52
|
+
except Exception as error:
|
|
53
|
+
_LOGGER.error(f"{self.user_id}:Connection lost due to error: {error}")
|
|
48
54
|
|
|
49
55
|
def datagram_received(self, data, addr):
|
|
50
56
|
data_str = aes_decrypt(data,self.aes_key)
|
|
@@ -56,16 +62,21 @@ class BroadcastProtocol:
|
|
|
56
62
|
self._discover_cb(devId,{CONF_IPADDRESS : addr[0]})
|
|
57
63
|
|
|
58
64
|
def error_received(self, exc):
|
|
59
|
-
_LOGGER.error(f"Error occurred: {exc}")
|
|
65
|
+
_LOGGER.error(f"{self.user_id}:Error occurred: {exc}")
|
|
60
66
|
|
|
61
67
|
def close(self) -> None:
|
|
62
|
-
|
|
68
|
+
try:
|
|
69
|
+
self.transport.close()
|
|
70
|
+
except Exception as error:
|
|
71
|
+
_LOGGER.error(f"Connection lost due to error: {error}")
|
|
72
|
+
|
|
63
73
|
|
|
64
74
|
def connection_lost(self, exc):
|
|
75
|
+
self._is_closed = True
|
|
65
76
|
if exc:
|
|
66
|
-
_LOGGER.error(f"Connection lost due to error: {exc}")
|
|
77
|
+
_LOGGER.error(f"{self.user_id}:Connection lost due to error: {exc}")
|
|
67
78
|
else:
|
|
68
|
-
_LOGGER.info("Connection closed.")
|
|
79
|
+
_LOGGER.info("{self.user_id}:Connection closed.")
|
|
69
80
|
|
|
70
81
|
class Discover:
|
|
71
82
|
_login_info: dict[str: Any] = None
|
|
@@ -96,5 +107,4 @@ class Discover:
|
|
|
96
107
|
def close(self) -> None:
|
|
97
108
|
if self._broadcast_protocol is not None:
|
|
98
109
|
self._broadcast_protocol.close()
|
|
99
|
-
|
|
100
|
-
|
|
110
|
+
self._broadcast_protocol.send_broadcast()
|
|
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
|