Skip to content

Commit d5a4d86

Browse files
committed
Merge remote-tracking branch 'origin/master' into protobuf-ble-logging
2 parents 188f9d5 + 0e6a0eb commit d5a4d86

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

meshtastic/__main__.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,16 +1442,6 @@ def initParser():
14421442
"--reply", help="Reply to received messages", action="store_true"
14431443
)
14441444

1445-
group.add_argument(
1446-
"--gpio-wrb", nargs=2, help="Set a particular GPIO # to 1 or 0", action="append"
1447-
)
1448-
1449-
group.add_argument("--gpio-rd", help="Read from a GPIO mask (ex: '0x10')")
1450-
1451-
group.add_argument(
1452-
"--gpio-watch", help="Start watching a GPIO mask for changes (ex: '0x10')"
1453-
)
1454-
14551445
group.add_argument(
14561446
"--no-time",
14571447
help="Suppress sending the current time to the mesh",
@@ -1490,7 +1480,7 @@ def initParser():
14901480
"--pos-fields",
14911481
help="Specify fields to send when sending a position. Use no argument for a list of valid values. "
14921482
"Can pass multiple values as a space separated list like "
1493-
"this: '--pos-fields POS_ALTITUDE POS_ALT_MSL'",
1483+
"this: '--pos-fields ALTITUDE HEADING SPEED'",
14941484
nargs="*",
14951485
action="store",
14961486
)
@@ -1531,6 +1521,21 @@ def initParser():
15311521
action="store_true",
15321522
)
15331523

1524+
remoteHardwareArgs = parser.add_argument_group('Remote Hardware', 'Arguments related to the Remote Hardware module')
1525+
1526+
remoteHardwareArgs.add_argument(
1527+
"--gpio-wrb", nargs=2, help="Set a particular GPIO # to 1 or 0", action="append"
1528+
)
1529+
1530+
remoteHardwareArgs.add_argument(
1531+
"--gpio-rd", help="Read from a GPIO mask (ex: '0x10')"
1532+
)
1533+
1534+
remoteHardwareArgs.add_argument(
1535+
"--gpio-watch", help="Start watching a GPIO mask for changes (ex: '0x10')"
1536+
)
1537+
1538+
15341539
have_tunnel = platform.system() == "Linux"
15351540
if have_tunnel:
15361541
tunnelArgs = parser.add_argument_group('Tunnel', 'Arguments related to establishing a tunnel device over the mesh.')

meshtastic/ble_interface.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ def __init__(
6161
self.close()
6262
raise e
6363

64-
#self.client.start_notify(LEGACY_LOGRADIO_UUID, self.legacy_log_radio_handler)
65-
self.client.start_notify(LOGRADIO_UUID, self.log_radio_handler)
64+
if self.client.has_characteristic(LEGACY_LOGRADIO_UUID):
65+
self.client.start_notify(LEGACY_LOGRADIO_UUID, self.legacy_log_radio_handler)
66+
67+
if self.client.has_characteristic(LOGRADIO_UUID):
68+
self.client.start_notify(LOGRADIO_UUID, self.log_radio_handler)
6669

6770
logging.debug("Mesh configure starting")
6871
self._startConfig()
@@ -270,6 +273,10 @@ def read_gatt_char(self, *args, **kwargs): # pylint: disable=C0116
270273
def write_gatt_char(self, *args, **kwargs): # pylint: disable=C0116
271274
self.async_await(self.bleak_client.write_gatt_char(*args, **kwargs))
272275

276+
def has_characteristic(self, specifier):
277+
"""Check if the connected node supports a specified characteristic."""
278+
return bool(self.bleak_client.services.get_characteristic(specifier))
279+
273280
def start_notify(self, *args, **kwargs): # pylint: disable=C0116
274281
self.async_await(self.bleak_client.start_notify(*args, **kwargs))
275282

0 commit comments

Comments
 (0)