From 903ab53fc9a5f3ef8f64ded5e4bd9a003fdb272a Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 5 Oct 2024 17:04:39 +0200 Subject: [PATCH] Fixed init fail due to missing library on Android/Termux --- RNS/Interfaces/Android/RNodeInterface.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/RNS/Interfaces/Android/RNodeInterface.py b/RNS/Interfaces/Android/RNodeInterface.py index 36e9e47..293f9e0 100644 --- a/RNS/Interfaces/Android/RNodeInterface.py +++ b/RNS/Interfaces/Android/RNodeInterface.py @@ -28,8 +28,14 @@ import time import math import RNS -from able import BluetoothDispatcher, GATT_SUCCESS -from able.adapter import require_bluetooth_enabled +try: + from able import BluetoothDispatcher, GATT_SUCCESS +except Exception as e: + GATT_SUCCESS = 0x00 + class BluetoothDispatcher(): + def __init__(**kwargs): + RNS.log("Attempt to initialise BLE connectivity, but Android BLE support library is unavailable", RNS.LOG_ERROR) + raise OSError("No BLE support available") class KISS(): FEND = 0xC0 @@ -81,6 +87,8 @@ class KISS(): ERROR_INITRADIO = 0x01 ERROR_TXFAILED = 0x02 ERROR_EEPROM_LOCKED = 0x03 + ERROR_QUEUE_FULL = 0x04 + ERROR_MEMORY_LOW = 0x05 ERROR_INVALID_FIRMWARE = 0x10 ERROR_INVALID_BLE_MTU = 0x20 @@ -1242,6 +1250,9 @@ class RNodeInterface(Interface): elif (byte == KISS.ERROR_TXFAILED): RNS.log(str(self)+" hardware TX error (code "+RNS.hexrep(byte)+")", RNS.LOG_ERROR) raise IOError("Hardware transmit failure") + elif (byte == KISS.ERROR_MEMORY_LOW): + RNS.log(str(self)+" hardware error (code "+RNS.hexrep(byte)+"): Memory exhausted", RNS.LOG_ERROR) + self.hw_errors.append({"error": KISS.ERROR_MEMORY_LOW, "description": "Memory exhausted on connected device"}) else: RNS.log(str(self)+" hardware error (code "+RNS.hexrep(byte)+")", RNS.LOG_ERROR) raise IOError("Unknown hardware failure")