From 40cd961eabc223a9962431d3bac53cacb211e85a Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 30 Oct 2022 23:13:44 +0100 Subject: [PATCH] Added better teardown handling on RNodeInterfaces --- RNS/Interfaces/Android/RNodeInterface.py | 2 ++ RNS/Interfaces/RNodeInterface.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/RNS/Interfaces/Android/RNodeInterface.py b/RNS/Interfaces/Android/RNodeInterface.py index 1ec3c63..6b54dee 100644 --- a/RNS/Interfaces/Android/RNodeInterface.py +++ b/RNS/Interfaces/Android/RNodeInterface.py @@ -56,6 +56,8 @@ class KISS(): CMD_FB_EXT = 0x41 CMD_FB_READ = 0x42 CMD_FB_WRITE = 0x43 + CMD_FB_READL = 0x44 + CMD_BT_CTRL = 0x45 CMD_PLATFORM = 0x48 CMD_MCU = 0x49 CMD_FW_VERSION = 0x50 diff --git a/RNS/Interfaces/RNodeInterface.py b/RNS/Interfaces/RNodeInterface.py index d2418d6..813ea2e 100644 --- a/RNS/Interfaces/RNodeInterface.py +++ b/RNS/Interfaces/RNodeInterface.py @@ -44,6 +44,7 @@ class KISS(): CMD_RADIO_STATE = 0x06 CMD_RADIO_LOCK = 0x07 CMD_DETECT = 0x08 + CMD_LEAVE = 0x0A CMD_READY = 0x0F CMD_STAT_RX = 0x21 CMD_STAT_TX = 0x22 @@ -276,6 +277,12 @@ class RNodeInterface(Interface): if written != len(kiss_command): raise IOError("An IO error occurred while detecting hardware for "+self(str)) + def leave(self): + kiss_command = bytes([KISS.FEND, KISS.CMD_LEAVE, 0xFF, KISS.FEND]) + written = self.serial.write(kiss_command) + if written != len(kiss_command): + raise IOError("An IO error occurred while sending host left command to device") + def enable_external_framebuffer(self): if self.display != None: kiss_command = bytes([KISS.FEND, KISS.CMD_FB_EXT, 0x01, KISS.FEND]) @@ -681,6 +688,7 @@ class RNodeInterface(Interface): def detach(self): self.disable_external_framebuffer() self.setRadioState(KISS.RADIO_STATE_OFF) + self.leave() def __str__(self): return "RNodeInterface["+str(self.name)+"]"