Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into protobuf-ble-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern committed Jul 1, 2024
2 parents 188f9d5 + 0e6a0eb commit d5a4d86
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
27 changes: 16 additions & 11 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -1490,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",
)
Expand Down Expand Up @@ -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.')
Expand Down
11 changes: 9 additions & 2 deletions meshtastic/ble_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ def __init__(
self.close()
raise e

#self.client.start_notify(LEGACY_LOGRADIO_UUID, self.legacy_log_radio_handler)
self.client.start_notify(LOGRADIO_UUID, self.log_radio_handler)
if self.client.has_characteristic(LEGACY_LOGRADIO_UUID):
self.client.start_notify(LEGACY_LOGRADIO_UUID, self.legacy_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()
Expand Down Expand Up @@ -270,6 +273,10 @@ def read_gatt_char(self, *args, **kwargs): # pylint: disable=C0116
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):
"""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))

Expand Down

0 comments on commit d5a4d86

Please sign in to comment.