iotile / iotile/coretools

Move bled112 to use OperationManager for concurrency

Open
#909 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
14
Forks
7
PR merge metrics
No merged PRs in 30d

Description

> **Note:** This is a placeholder issue mainly.

The goal is to be able to write complex coroutines that implement BLE primitives like `read_gatt_table` in the following way:

```python
async def read_gatt_table(mac):
await bled112.write_command("read gatt table", end_paused=True)

await manager.gather_until(specs=['gatt chars'], until='gatt ended', start_unpaused=True)
```

This would write one packet and wait for the response. The `OperationManager` would temporarily pause dispatching packets immediately after the response packet was handled (in case there was no error) so that the `gather_until` operation could be setup without any race condition that you might miss the first gatt table entry that could come immediately after the successful command acknowledgement.

You would need to be able to pause the `OperationManager` and pause calls would need to be nestable like a recursive lock (simple counter would suffice).

There would also need to be a way for the reader thread to inject packets into the `OperationManager` while it was paused that would cause them to be queued and then automatically start flushing the queue once `unpause()` was called enough times.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.