Skip to content

Commit

Permalink
Merge pull request #23 from iomz/fix-no-service
Browse files Browse the repository at this point in the history
fix: repeat once if gets stuck
  • Loading branch information
iomz authored Aug 10, 2023
2 parents 94c59f0 + df65e5c commit 87decf8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions myo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ async def command(self, client: BleakClient, cmd: Command):
"""
Command Characteristic
"""
await client.write_gatt_char(Handle.COMMAND.value, cmd.data, True)
try:
await client.write_gatt_char(Handle.COMMAND.value, cmd.data, True)
except AttributeError:
# wait a bit and try once again
await asyncio.sleep(0.1)
await client.write_gatt_char(Handle.COMMAND.value, cmd.data, True)

async def deep_sleep(self, client: BleakClient):
"""
Expand Down Expand Up @@ -330,8 +335,7 @@ async def on_classifier_event(self, ce: ClassifierEvent):

async def on_data(self, data):
"""
for on_aggregated_data
data is either FVData or IMUData
<> for on_aggregated_data: data is either FVData or IMUData
"""
if isinstance(data, FVData):
self.fv_aggregated = data
Expand All @@ -345,8 +349,8 @@ async def on_data(self, data):

async def on_aggregated_data(self, ad: AggregatedData):
"""
on_aggregated_data is invoked when both FVData and IMUData are ready.
it doesn't support EMGData since it is collected at different interval (200HZ instead of 50Hz)
<> on_aggregated_data is invoked when both FVData and IMUData are ready
it doesn't support EMGData since it is collected at different interval (200HZ instead of 50Hz)
"""
raise NotImplementedError()

Expand Down Expand Up @@ -504,6 +508,7 @@ async def stop(self):
# vibrate short*2
await self.vibrate(VibrationType.SHORT)
await self.vibrate(VibrationType.SHORT)

# unsubscribe from notify/indicate
if self.emg_mode in [EMGMode.SEND_EMG, EMGMode.SEND_RAW]:
await self.stop_notify(Handle.EMG0_DATA.value)
Expand Down

0 comments on commit 87decf8

Please sign in to comment.