-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates to CoreBluetooth backend #209
Conversation
Nice! I have not had the time to test it yet. Not sure I like adding variables to class instances. e.g self[xUUID]._error = None # Clear error prior to new event I believe it is a bit confusing and it makes pylint unhappy. Perhaps inherit class _BleakCorebluetoothEvent(asyncio.Event):
def __init__(self):
self._error = None
super().__init__()
def clear(self):
self._error = None
super().clear()
def set(error: NSError = None): # or pass a Exception?
self._error = error
super().set()
async def wait(self, timeout=None):
if timeout:
try:
await asyncio.wait_for(super().wait(), timeout)
except asyncio.TimeoutError:
raise TimeoutError("")
else:
await super().wait()
if self._error:
raise SomeException(self._error) |
My approach is a hack. I like the idea of a subclass (and better semantics for waits/timeouts). I'll probably try to incorporate your approach in the next few days. |
Whoa. This was a lot of changes in one PR... I would have liked them spread out over several to be able to review them better. Nevertheless, thank you! I will await you changes and then plan to look into this as soon as possible though. |
Yeah, sorry for the number of changes in one batch. It was one of my motivations for Issue #207 (Unit testing with devices). My development path was pretty haphazard. I'll try to be a little more structured in the future. I've incorporated a first pass at @5frank's approach, which is much much cleaner. It also provides an opportunity for timeouts on all device events, which could make "hanging" almost impossible. I think this could use further review discussion, but the constructors in |
+1 This fixed bleak breaking in Catalina |
I have planned on devoting an entire day to bleak during next week, with explicit focus on macOS issues. @dlech Could you integrate your changes on with these ones (if needed)? I could merge this into a separate branch in my repo so that additional changes can be appended. Would that help? @bsiever Thank you for the work done here. I will try it out first thing on the Bleak-day! |
@hbldh I hope Bleak Day goes well! If you have a micro:bit the unit tests I've made can help quickly vet that additions aren't breaking too many things. @dlech It's clear that you caught things I missed and I restructured parts and added features you haven't hit. We both made a lot of changes and it's definitely a bit messy to integrate. The "big ones" for me were:
I probably won't have time to make many updates for the next week or two, but I should have time to reply to any questions. |
I merged the PR #227 before this one, since it was smaller and contained exacty what I needed for the moment. Regrettably I have to had time to merge this with that yet, so I will leave this one for a 0.7.X release in a few days. |
…er-develop Merge #209 # Conflicts: # bleak/backends/corebluetooth/CentralManagerDelegate.py # bleak/backends/corebluetooth/PeripheralDelegate.py # bleak/backends/corebluetooth/__init__.py # bleak/backends/corebluetooth/client.py # bleak/backends/corebluetooth/discovery.py # bleak/backends/corebluetooth/scanner.py
@bsiever I tried to do a careful merge of your changes into a separate branch ( The things I liked in the PR, that wasn't solved in merging of #227:
|
This includes several updates to the CoreBluetooth backend. These include:
There are a lot of changes. I'm happy to answer any questions and won't be hurt if this is rejected. I'm also able to do a PR for my test suite (pretty rough) to help quickly vet the work (requires 1+ microbit).