-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add Treadmill webapp #516
base: main
Are you sure you want to change the base?
Add Treadmill webapp #516
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.