Hardware Connection fix
This commit is contained in:
+13
-3
@@ -25,10 +25,14 @@ HEADER_FMT = "<B B H I" # ID, Ver, Len, Timestamp
|
||||
TLV_FMT = "<B H"
|
||||
|
||||
class ESP32Communication(Thread):
|
||||
def __init__(self, host=cfg.esp32_ip, port=cfg.esp32_port):
|
||||
def __init__(self, host=None, port=None, ip=None):
|
||||
super().__init__(daemon=True)
|
||||
if ip is not None:
|
||||
host = ip
|
||||
host = cfg.esp32_ip if host is None else host
|
||||
port = cfg.esp32_port if port is None else port
|
||||
self.addr = (host, port)
|
||||
|
||||
|
||||
# UDP Socket - Zero Lag
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
||||
@@ -126,4 +130,10 @@ class ESP32Communication(Thread):
|
||||
|
||||
def stop(self):
|
||||
self.running.clear()
|
||||
self.sock.close()
|
||||
try:
|
||||
self.sock.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
self.stop()
|
||||
Reference in New Issue
Block a user