You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem
I tested a quick example where I have a GATT service with 1 characteristic, where it has READ/WRITE properties, but does not have read permissions (just to test)
I was able to read/write without any issues to that characteristic.
This test stemmed from trying out {read,write}_encryption_required permissions but being able to manipulate the field without pairing the devices.
Reproduction
importloggingimportasynciofromdatetimeimportdatetimefromtypingimportAny, Dictfromblessimport ( # type: ignoreBlessServer,
BlessGATTCharacteristic,
GATTCharacteristicProperties,
GATTAttributePermissions
)
logging.basicConfig(level=logging.DEBUG)
logger=logging.getLogger(name=__name__)
defwrite_request(
characteristic: BlessGATTCharacteristic,
value: Any,
**kwargs
):
logger.debug(f"Writing {value} to {characteristic}")
characteristic.value=valuelogger.debug(f"Char value set to {characteristic.value}")
defread_request(
characteristic: BlessGATTCharacteristic,
**kwargs
) ->bytearray:
logger.debug(f"Reading {characteristic.value}")
returncharacteristic.valueasyncdefrun(loop):
# Instantiate the servergatt: Dict= {
"0000ffe0-0000-1000-8000-00805f9b34fb": {
"61FF12BB-3ED8-46E5-B4F9-D64E2FEC021B": {
"Properties": (GATTCharacteristicProperties.read|GATTCharacteristicProperties.write),
"Permissions": (
# GATTAttributePermissions.read_encryption_required |GATTAttributePermissions.write_encryption_required),
"Value": None
},
}
}
server_name="MY_NOTIFY_SERVER"server=BlessServer(name=server_name, loop=loop, name_overwrite=True, )
server.write_request_func=write_request# not required if we don't have a write characteristicserver.read_request_func=read_requestawaitserver.add_gatt(gatt)
awaitserver.start()
whileTrue:
awaitasyncio.sleep(0.5)
logger.debug("Stopping")
awaitserver.stop()
loop=asyncio.get_event_loop()
loop.run_until_complete(run(loop))
Expected behavior
I should not be able to write unless the devices are paired and should not be able to read at all
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
OS: Raspbian GNU/Linux 11 (bullseye)
Additional context
The text was updated successfully, but these errors were encountered:
I'm also dealing with the same issue; apparently, the permissions (GATTAttributePermissions) are not used at all on the bluezdbus backend, used by 'linux'; they're only used on macOS and windows. If you run the sample code you provided on a non-linux machine, it should work as expected. I think the characteristic permissions on the bluezdbus backend are determined by the properties (GATTCharacteristicProperties) (maintainers, correct me if I'm wrong).
What worked for me was changing the property GATTCharacteristicProperties.write to GATTCharacteristicProperties.authenticated_signed_writes. In this case, you'll need to bond with the device first to be able to write to the characteristic. Not sure about 'protected reads'...
The problem
I tested a quick example where I have a GATT service with 1 characteristic, where it has READ/WRITE properties, but does not have read permissions (just to test)
I was able to read/write without any issues to that characteristic.
This test stemmed from trying out
{read,write}_encryption_required
permissions but being able to manipulate the field without pairing the devices.Reproduction
Expected behavior
I should not be able to write unless the devices are paired and should not be able to read at all
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: