From 43a6e280c0bb649803a10b9a3136b0c9572b8214 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 2 Nov 2023 16:08:49 +0100 Subject: [PATCH] Fixed bluetooth read timeouts on Android in environments with hight 2.4G noise --- RNS/Interfaces/Android/RNodeInterface.py | 5 ++++- RNS/Interfaces/RNodeInterface.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RNS/Interfaces/Android/RNodeInterface.py b/RNS/Interfaces/Android/RNodeInterface.py index cb71c6c..fd3cfe8 100644 --- a/RNS/Interfaces/Android/RNodeInterface.py +++ b/RNS/Interfaces/Android/RNodeInterface.py @@ -602,8 +602,11 @@ class RNodeInterface(Interface): raise IOError("Invalid device firmware") if self.serial != None and self.port != None: + self.timeout = 200 RNS.log("Serial port "+self.port+" is now open") + if self.bt_manager != None and self.bt_manager.connected: + self.timeout = 1500 RNS.log("Bluetooth connection to RNode now open") RNS.log("Configuring RNode interface...", RNS.LOG_VERBOSE) @@ -1170,7 +1173,7 @@ class RNodeInterface(Interface): if got == 0: time_since_last = int(time.time()*1000) - last_read_ms if len(data_buffer) > 0 and time_since_last > self.timeout: - RNS.log(str(self)+" serial read timeout", RNS.LOG_WARNING) + RNS.log(str(self)+" serial read timeout in command "+str(command), RNS.LOG_WARNING) data_buffer = b"" in_frame = False command = KISS.CMD_UNKNOWN diff --git a/RNS/Interfaces/RNodeInterface.py b/RNS/Interfaces/RNodeInterface.py index d15178e..f0292a0 100644 --- a/RNS/Interfaces/RNodeInterface.py +++ b/RNS/Interfaces/RNodeInterface.py @@ -799,7 +799,7 @@ class RNodeInterface(Interface): else: time_since_last = int(time.time()*1000) - last_read_ms if len(data_buffer) > 0 and time_since_last > self.timeout: - RNS.log(str(self)+" serial read timeout", RNS.LOG_WARNING) + RNS.log(str(self)+" serial read timeout in command "+str(command), RNS.LOG_WARNING) data_buffer = b"" in_frame = False command = KISS.CMD_UNKNOWN