Skip to content
This repository was archived by the owner on Jul 20, 2025. It is now read-only.

Commit c020eeb

Browse files
authored
Merge pull request #4 from hbldh/feature/connect_fix
Fix for issue #3.
2 parents 7dad08b + a7bdf14 commit c020eeb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mbientlab/metawear/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,16 @@ def connect(self, **kwargs):
152152
@params:
153153
serialize - Optional : Serialize and cached C++ SDK state after initializaion, defaults to true
154154
"""
155-
self.gatt.connect(True, channel_type='random')
155+
try:
156+
self.gatt.connect(True, channel_type='random')
157+
except RuntimeError as e:
158+
# gattlib.connect's `wait=True` requires elevated permission
159+
# or modified capabilities.
160+
# It still connects, but a RuntimeError is raised. Check if
161+
# `self.gatt` is connected, and rethrow exception otherwise.
162+
if not self.gatt.is_connected():
163+
raise e
164+
156165

157166
self.services = set()
158167
for s in self.gatt.discover_primary():

0 commit comments

Comments
 (0)