Skip to content
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 a security level for writing the cccd (reading is always allowed) #62

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions blatann/gatt/gatts.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class GattsCharacteristicProperties(gatt.CharacteristicProperties):
def __init__(self, read=True, write=False, notify=False, indicate=False, broadcast=False,
write_no_response=False, signed_write=False, security_level=gatt.SecurityLevel.OPEN,
max_length=20, variable_length=True, sccd=False,
cccd_security_level=gatt.SecurityLevel.OPEN,
cccd_write_security_level=gatt.SecurityLevel.OPEN,
user_description: GattsUserDescriptionProperties = None,
presentation_format: PresentationFormat = None):
ThomasGerstenberg marked this conversation as resolved.
Show resolved Hide resolved
super(GattsCharacteristicProperties, self).__init__(read, write, notify, indicate, broadcast,
Expand All @@ -79,7 +79,7 @@ def __init__(self, read=True, write=False, notify=False, indicate=False, broadca
self.user_description = user_description
self.presentation = presentation_format
self.sccd = sccd
self.cccd_security_level = cccd_security_level
self.cccd_write_security_level = cccd_write_security_level


class GattsCharacteristic(gatt.Characteristic):
Expand Down Expand Up @@ -468,7 +468,7 @@ def add_characteristic(self, uuid: Uuid, properties: GattsCharacteristicProperti
char_md = nrf_types.BLEGattsCharMetadata(props)
# Create cccd metadata if notify/indicate enabled
if properties.notify or properties.indicate:
char_md.cccd_metadata = nrf_types.BLEGattsAttrMetadata(write_permissions=_security_mapping[properties.cccd_security_level])
char_md.cccd_metadata = nrf_types.BLEGattsAttrMetadata(write_permissions=_security_mapping[properties.cccd_write_security_level])

if properties.sccd:
char_md.sccd_metadata = nrf_types.BLEGattsAttrMetadata()
Expand Down