diff --git a/RNS/Interfaces/Android/KISSInterface.py b/RNS/Interfaces/Android/KISSInterface.py index 13c8386..595e655 100644 --- a/RNS/Interfaces/Android/KISSInterface.py +++ b/RNS/Interfaces/Android/KISSInterface.py @@ -66,10 +66,18 @@ class KISSInterface(Interface): if RNS.vendor.platformutils.is_android(): self.on_android = True if importlib.util.find_spec('usbserial4a') != None: + if importlib.util.find_spec('jnius') == None: + RNS.log("Could not load jnius API wrapper for Android, KISS interface cannot be created.", RNS.LOG_CRITICAL) + RNS.log("This probably means you are trying to use an USB-based interface from within Termux or similar.", RNS.LOG_CRITICAL) + RNS.log("This is currently not possible, due to this environment limiting access to the native Android APIs.", RNS.LOG_CRITICAL) + RNS.panic() + from usbserial4a import serial4a as serial self.parity = "N" + else: RNS.log("Could not load USB serial module for Android, KISS interface cannot be created.", RNS.LOG_CRITICAL) + RNS.log("You can install this module by issuing: pip install usbserial4a", RNS.LOG_CRITICAL) RNS.panic() else: raise SystemError("Android-specific interface was used on non-Android OS") diff --git a/RNS/Interfaces/Android/RNodeInterface.py b/RNS/Interfaces/Android/RNodeInterface.py index 68537e1..9fdb318 100644 --- a/RNS/Interfaces/Android/RNodeInterface.py +++ b/RNS/Interfaces/Android/RNodeInterface.py @@ -99,10 +99,18 @@ class RNodeInterface(Interface): if RNS.vendor.platformutils.is_android(): self.on_android = True if importlib.util.find_spec('usbserial4a') != None: + if importlib.util.find_spec('jnius') == None: + RNS.log("Could not load jnius API wrapper for Android, RNode interface cannot be created.", RNS.LOG_CRITICAL) + RNS.log("This probably means you are trying to use an USB-based interface from within Termux or similar.", RNS.LOG_CRITICAL) + RNS.log("This is currently not possible, due to this environment limiting access to the native Android APIs.", RNS.LOG_CRITICAL) + RNS.panic() + from usbserial4a import serial4a as serial self.parity = "N" + else: RNS.log("Could not load USB serial module for Android, RNode interface cannot be created.", RNS.LOG_CRITICAL) + RNS.log("You can install this module by issuing: pip install usbserial4a", RNS.LOG_CRITICAL) RNS.panic() else: raise SystemError("Android-specific interface was used on non-Android OS") diff --git a/RNS/Interfaces/Android/SerialInterface.py b/RNS/Interfaces/Android/SerialInterface.py index 537ba21..25a52b4 100644 --- a/RNS/Interfaces/Android/SerialInterface.py +++ b/RNS/Interfaces/Android/SerialInterface.py @@ -56,10 +56,18 @@ class SerialInterface(Interface): if RNS.vendor.platformutils.is_android(): self.on_android = True if importlib.util.find_spec('usbserial4a') != None: + if importlib.util.find_spec('jnius') == None: + RNS.log("Could not load jnius API wrapper for Android, Serial interface cannot be created.", RNS.LOG_CRITICAL) + RNS.log("This probably means you are trying to use an USB-based interface from within Termux or similar.", RNS.LOG_CRITICAL) + RNS.log("This is currently not possible, due to this environment limiting access to the native Android APIs.", RNS.LOG_CRITICAL) + RNS.panic() + from usbserial4a import serial4a as serial self.parity = "N" + else: RNS.log("Could not load USB serial module for Android, Serial interface cannot be created.", RNS.LOG_CRITICAL) + RNS.log("You can install this module by issuing: pip install usbserial4a", RNS.LOG_CRITICAL) RNS.panic() else: raise SystemError("Android-specific interface was used on non-Android OS") diff --git a/RNS/Interfaces/Android/__init__.py b/RNS/Interfaces/Android/__init__.py new file mode 100644 index 0000000..ba9eae1 --- /dev/null +++ b/RNS/Interfaces/Android/__init__.py @@ -0,0 +1,27 @@ +# MIT License +# +# Copyright (c) 2016-2022 Mark Qvist / unsigned.io +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os +import glob + +modules = glob.glob(os.path.dirname(__file__)+"/*.py") +__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')] \ No newline at end of file diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 37000d7..90f378d 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -34,6 +34,7 @@ if get_platform() == "android": from .Interfaces.Android import KISSInterface else: from .Interfaces import * + from .Interfaces.Android import * from .vendor.configobj import ConfigObj import configparser diff --git a/RNS/_version.py b/RNS/_version.py index 8966e1c..39774cf 100644 --- a/RNS/_version.py +++ b/RNS/_version.py @@ -1 +1 @@ -__version__ = "0.3.15" +__version__ = "0.3.16"