Conversation
3b1808b to
5e060a2
Compare
| await self.peer.discover_all() | ||
| print("Service discovery complete!") | ||
|
|
||
| hr_measurement_characteristics = self.peer.get_characteristics_by_uuid( |
There was a problem hiding this comment.
You could use the HeartRateServiceProxy class from the profiles. Something like: heart_rate_service = peer.create_service_proxy(HeartRateServiceProxy).
(see examples/heart_rate_client.py for an example)
| uuid=GATT_HEART_RATE_MEASUREMENT_CHARACTERISTIC, | ||
| service=GATT_HEART_RATE_SERVICE, | ||
| ) | ||
| hr_measurement_characteristic = hr_measurement_characteristics[0] |
There was a problem hiding this comment.
It would be safe to check that the service actually has that characteristic, otherwise that's going to raise.
| if listener := self.listeners.get('on_security_request'): | ||
| listener() | ||
|
|
||
| def on(self, event_name, listener): |
There was a problem hiding this comment.
You can just subclass pyee.EventEmitter and get all the listener management and event emission implemented already for you.
| async def on_connection(self, connection: Connection): | ||
| self.emit_connection_updates(connection) | ||
| connection.listener = self | ||
| connection.on('security_request', self.on_security_request) |
There was a problem hiding this comment.
If you want to prompt the user to accept/reject pairing, you should probably use the PairingDelegate mechanism rather than intercepting security requests. See apps/pair.py for an example (see how the --prompt option is handled, it does exactly that: ask the user to accept pairing or not).
No description provided.