Repository navigation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Many characteristics support only READ | NOTIFY but not WRITE, so if they have the permissions, CCCD could be unwritable?
Though I agree with the concern, I didn't come up with a good solution here. Maybe we can let users to determine this?
Uh oh!
There was an error while loading. Please reload this page.
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.
Indeed, maybe it could be better to do:
characteristic.permissions | att.Attribute.READABLE | att.Attribute.WRITEABLEThat will ensure cccd to be writable even if the char is only read|notify
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.
I am perservative on this change because:
If necessary, I tend to add a default CCCD constructor function and let callers control permissions there.
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.
Thx for your quick response!
Maybe I should also have explained, why I needed that for my project.
In my case, I use this permission on the cccd to trigger the pairing on the mobile app side.
At the moment I just override the permissions to get the same permissions like the ones I proposed and everything works fine. I just thought this would have been the default behavior. But I guess there is a lot of use cases I don't know.
I'm not to much into Bluetooth, so I don't understand what you mean by: "The access control might be introduced for notify and indicate, instead of CCCD themselves."
For the constructor, how the users could handle the permissions ? By passing them when adding the service ? monkey patching ? or something else ?
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.
The current GATT server only adds CCCD if notification is enabled and CCCD doesn't exist. You can check the conditions above around line #250.
So if users want to pass their own CCCD, just add them when constructing characteristics, like
You can check
notify_subscriber()to see how notification is implemented.bumble/bumble/gatt_server.py
Line 333 in d112901
In short, CCCD is a flag to enable and disable subscriptions, and servers can decide whether to send notifications based on it, and other factors like permissions. The current implementation won't send notifications if value is not present by callers, and we can add a checker to block notifications if they don't have enough permissions to Characteristics themselves, but CCCD permission is another thing.
Uh oh!
There was an error while loading. Please reload this page.
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.
Actually we can't add the descriptor with the lambda function to update the characteristic value when we define the characteristic, because the gatt server is created on runtime.
But yeah that's what I do (adding the descriptor, with permissions), and just before adding the service, I override the characteristicto have the callbacks on the characteristic value for the CCCD.
Adding the permissions by default from the characteristic sounded easier but if it doesn't work for all cases, you are right it's fine the way it is.
Thx a lot for the explanation and you're time!
I think we can close then this topic :)
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.
Since it's really not easy to compose a CCCD value callback, later we may add a helper to construct it.