mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-22 21:50:18 +00:00
Improved handling of Android interfaces in apps without hardware access
This commit is contained in:
parent
8fec5cedbe
commit
b479e14ca5
@ -66,10 +66,18 @@ class KISSInterface(Interface):
|
|||||||
if RNS.vendor.platformutils.is_android():
|
if RNS.vendor.platformutils.is_android():
|
||||||
self.on_android = True
|
self.on_android = True
|
||||||
if importlib.util.find_spec('usbserial4a') != None:
|
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
|
from usbserial4a import serial4a as serial
|
||||||
self.parity = "N"
|
self.parity = "N"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Could not load USB serial module for Android, KISS interface cannot be created.", RNS.LOG_CRITICAL)
|
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()
|
RNS.panic()
|
||||||
else:
|
else:
|
||||||
raise SystemError("Android-specific interface was used on non-Android OS")
|
raise SystemError("Android-specific interface was used on non-Android OS")
|
||||||
|
@ -99,10 +99,18 @@ class RNodeInterface(Interface):
|
|||||||
if RNS.vendor.platformutils.is_android():
|
if RNS.vendor.platformutils.is_android():
|
||||||
self.on_android = True
|
self.on_android = True
|
||||||
if importlib.util.find_spec('usbserial4a') != None:
|
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
|
from usbserial4a import serial4a as serial
|
||||||
self.parity = "N"
|
self.parity = "N"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Could not load USB serial module for Android, RNode interface cannot be created.", RNS.LOG_CRITICAL)
|
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()
|
RNS.panic()
|
||||||
else:
|
else:
|
||||||
raise SystemError("Android-specific interface was used on non-Android OS")
|
raise SystemError("Android-specific interface was used on non-Android OS")
|
||||||
|
@ -56,10 +56,18 @@ class SerialInterface(Interface):
|
|||||||
if RNS.vendor.platformutils.is_android():
|
if RNS.vendor.platformutils.is_android():
|
||||||
self.on_android = True
|
self.on_android = True
|
||||||
if importlib.util.find_spec('usbserial4a') != None:
|
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
|
from usbserial4a import serial4a as serial
|
||||||
self.parity = "N"
|
self.parity = "N"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Could not load USB serial module for Android, Serial interface cannot be created.", RNS.LOG_CRITICAL)
|
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()
|
RNS.panic()
|
||||||
else:
|
else:
|
||||||
raise SystemError("Android-specific interface was used on non-Android OS")
|
raise SystemError("Android-specific interface was used on non-Android OS")
|
||||||
|
27
RNS/Interfaces/Android/__init__.py
Normal file
27
RNS/Interfaces/Android/__init__.py
Normal file
@ -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')]
|
@ -34,6 +34,7 @@ if get_platform() == "android":
|
|||||||
from .Interfaces.Android import KISSInterface
|
from .Interfaces.Android import KISSInterface
|
||||||
else:
|
else:
|
||||||
from .Interfaces import *
|
from .Interfaces import *
|
||||||
|
from .Interfaces.Android import *
|
||||||
|
|
||||||
from .vendor.configobj import ConfigObj
|
from .vendor.configobj import ConfigObj
|
||||||
import configparser
|
import configparser
|
||||||
|
@ -1 +1 @@
|
|||||||
__version__ = "0.3.15"
|
__version__ = "0.3.16"
|
||||||
|
Loading…
Reference in New Issue
Block a user