-
Notifications
You must be signed in to change notification settings - Fork 292
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
Device Name Characteristic (2A00) Write Access Denied - Windows #849
Comments
LightBlue runs on mobile devices, not Windows, correct? The "Access Denied" error also happens when trying to use HID characteristics which it is documented that it is not allowed. Maybe there is a different way that we are supposed to change the device name on Windows? The BluetoothLEDevice.Name property is also read-only. But maybe there is another more generic device name property or method somewhere that I am missing? |
Yes, LightBlue is an android app. However, i have used the NRF Connect bluetooth program on my windows computer, and it is able to change the Device Name. However it does use an external bluetooth radio, not the computer's built in bluetooth radio |
Yeah, that has it's own Bluetooth stack. |
The device name is in the service I have now run the script on both Windows and LInux (using a rasbperry pi with Rasbian) and have got the results below. EDIT: rasbian BlueZ version: bluetoothctl: 5.55 Interestingly, the windows script gets access denied trying to write to the Generic Access Profile, and the linux script cannot even see the Generic Access Profile service! I think this may be a problem with how the backends on each platfom or bleak handle the Generic Access profile. I have tried writing to a different characteristic in a different service (the UIN_UUID in the results below) and that can be written to on both Windows and linux.
|
BlueZ like to hide services and characteristics that it uses internally completely. Like Windows, there is a Name property in BlueZ that can be used instead, but unlike Windows, I think it is actually writable. |
I've been doing various fault finding, and it occured to me that the problem may be that i'm trying to access a 16-bit UUID with a 128bit UUID, e.g. "00002a00-0000-1000-8000-00805f9b34fb" rather than "2A00" Could this be causing the issue? |
No, on Windows, all UUIDs must be converted to a 128-bit GUID before being passed to the Windows APIs. |
I had a very similar problem while writing data to a Nordic UART service. I had many access denies errors when I started with bleak version 0.13 and after updating to 0.15 it change more to "The object is already closed" or "A method was called at an unexpected time" (don't know the exact error messages as my system reported them in German)
For my device I get the event 11 times during the first service discovery and if I reload them after I got the event everything works as expected. |
It would also be helpful to see a wireshark log of what the device is actually doing. |
Here is a extract of the log at the moment the failure happend. 2022-09-14 10:52:01.588753 I expect Windows to clear all services as described in the documentation as soon as the "Service Changed" event is received and they are not available until the new service service discovery is completed. I can send you the full wireshark log via e-mail if you are interested in. |
Windows is protective of some well-known services/characteristics and won't allow accessing them. Similarly, BlueZ hides the GAP Service completely, making the device name inaccessible. Furthermore, the device name displayed by the operating system may not be the same one as read by this characteristic - many OSes allow "changing the name" but it really means providing a local alias for the device and not actually writing that name to the device. I think the ServicesChanged issue is a separate issue and we should start a new issue for that. For the device name issue, I think we should have a property to get the device name instead of reading a characteristic. I don't think writing the device name will be possible cross-platform. And as mentioned already, this name may be a local OS alias rather than the Device Name characteristic. If you control the device firmware, you could add a custom attribute to update the device name if you really need to update the name on the device. |
I had a similar issue. After seeing the discussion above, I added the custom characteristic to the custom service insted of the exisiting service, and I no longer get Accedd Denied. |
Description
I am trying to use bleak to write to the device name
00002a00-0000-1000-8000-00805f9b34fb
on a Nordic nrf52840.I can read and write to it using LightBlue, but on windows i keep getting the following errors when using the test script below.
bleak.exc.BleakError: Could not write value b'TEST' to characteristic 0002: Access Denied
The value is reported as writeable when i read it:
[Characteristic] 00002a00-0000-1000-8000-00805f9b34fb: (read,write) | Name: , Value: No Value
I think this is a similar error to this one.
I don't think it's an issue with the peripheral's code, as the device name can be changed using the LightBlue app. Is this an issue with bleak/bleak-winrt, or am i doing something wrong?
What I Did
Script
Result
Here is the output of
service_explorer.py
The text was updated successfully, but these errors were encountered: