From 9ffdc30c1f0bcfe5eec1a2ff645ee3625a9f99f6 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Sun, 30 Jun 2024 23:25:07 -0700 Subject: [PATCH 1/4] Make remote hardware args live in their own little box --- meshtastic/__main__.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index cc9cff0..45c4345 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -1442,16 +1442,6 @@ def initParser(): "--reply", help="Reply to received messages", action="store_true" ) - group.add_argument( - "--gpio-wrb", nargs=2, help="Set a particular GPIO # to 1 or 0", action="append" - ) - - group.add_argument("--gpio-rd", help="Read from a GPIO mask (ex: '0x10')") - - group.add_argument( - "--gpio-watch", help="Start watching a GPIO mask for changes (ex: '0x10')" - ) - group.add_argument( "--no-time", help="Suppress sending the current time to the mesh", @@ -1531,6 +1521,21 @@ def initParser(): action="store_true", ) + remoteHardwareArgs = parser.add_argument_group('Remote Hardware', 'Arguments related to the Remote Hardware module') + + remoteHardwareArgs.add_argument( + "--gpio-wrb", nargs=2, help="Set a particular GPIO # to 1 or 0", action="append" + ) + + remoteHardwareArgs.add_argument( + "--gpio-rd", help="Read from a GPIO mask (ex: '0x10')" + ) + + remoteHardwareArgs.add_argument( + "--gpio-watch", help="Start watching a GPIO mask for changes (ex: '0x10')" + ) + + have_tunnel = platform.system() == "Linux" if have_tunnel: tunnelArgs = parser.add_argument_group('Tunnel', 'Arguments related to establishing a tunnel device over the mesh.') From 33c5be5219d70323a81d4326165fb8bdea450519 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Sun, 30 Jun 2024 23:25:57 -0700 Subject: [PATCH 2/4] Update doc string for --pos-fields to use valid values --- meshtastic/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 45c4345..c032a36 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -1480,7 +1480,7 @@ def initParser(): "--pos-fields", help="Specify fields to send when sending a position. Use no argument for a list of valid values. " "Can pass multiple values as a space separated list like " - "this: '--pos-fields POS_ALTITUDE POS_ALT_MSL'", + "this: '--pos-fields ALTITUDE HEADING SPEED'", nargs="*", action="store", ) From 49bd9cb515fbbafce71860436783f2596dd241d9 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Sun, 30 Jun 2024 23:40:11 -0700 Subject: [PATCH 3/4] Support --ble on older firmwares that don't have the log-radio characteristic yet. --- meshtastic/ble_interface.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/meshtastic/ble_interface.py b/meshtastic/ble_interface.py index b5f9f7d..c57930a 100644 --- a/meshtastic/ble_interface.py +++ b/meshtastic/ble_interface.py @@ -56,7 +56,8 @@ class BLEInterface(MeshInterface): self.close() raise e - self.client.start_notify(LOGRADIO_UUID, self.log_radio_handler) + if self.client.has_characteristic(LOGRADIO_UUID): + self.client.start_notify(LOGRADIO_UUID, self.log_radio_handler) logging.debug("Mesh configure starting") self._startConfig() @@ -248,6 +249,12 @@ class BLEClient: def write_gatt_char(self, *args, **kwargs): # pylint: disable=C0116 self.async_await(self.bleak_client.write_gatt_char(*args, **kwargs)) + def has_characteristic(self, specifier): + if self.bleak_client.services.get_characteristic(specifier): + return True + else: + return False + def start_notify(self, *args, **kwargs): # pylint: disable=C0116 self.async_await(self.bleak_client.start_notify(*args, **kwargs)) From 3b4690e93299731f214153ad36f0ff6f3da2e5c5 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Mon, 1 Jul 2024 00:00:59 -0700 Subject: [PATCH 4/4] appease the linter --- meshtastic/ble_interface.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/meshtastic/ble_interface.py b/meshtastic/ble_interface.py index c57930a..885502f 100644 --- a/meshtastic/ble_interface.py +++ b/meshtastic/ble_interface.py @@ -250,10 +250,8 @@ class BLEClient: self.async_await(self.bleak_client.write_gatt_char(*args, **kwargs)) def has_characteristic(self, specifier): - if self.bleak_client.services.get_characteristic(specifier): - return True - else: - return False + """Check if the connected node supports a specified characteristic.""" + return bool(self.bleak_client.services.get_characteristic(specifier)) def start_notify(self, *args, **kwargs): # pylint: disable=C0116 self.async_await(self.bleak_client.start_notify(*args, **kwargs))