Fixed init fail due to missing library on Android/Termux

This commit is contained in:
Mark Qvist 2024-10-05 17:04:39 +02:00
parent f461a7827b
commit 903ab53fc9
1 changed files with 13 additions and 2 deletions

View File

@ -28,8 +28,14 @@ import time
import math
import RNS
try:
from able import BluetoothDispatcher, GATT_SUCCESS
from able.adapter import require_bluetooth_enabled
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")