-
Notifications
You must be signed in to change notification settings - Fork 45
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
Setting the advertisting_data field of the Advertisement struct generates a parse error in BlueZ #49
Comments
I think that I am having a similar issue. I want to insert more than 6 bytes as manufacturer data which fails. let mut manufacturer_data = BTreeMap::new();
manufacturer_data.insert(0xffff, vec![0; 12]); // <--- here, more than 6 is not possible
let le_advertisement = Advertisement {
service_uuids: vec![config::SERVICE_UUID].into_iter().collect(),
manufacturer_data,
discoverable: Some(true),
local_name: Some("Test".to_string()),
..Default::default()
};
let adv_handle = adapter.advertise(le_advertisement).await.unwrap(); The error is the following: |
Interesting. I wonder if the failure to register advertisement error for manufacturer_data is related to the error I am seeing. I found that any advertising data with the Manufacturer Specific Data type (0xFF) I use results in the same parse error I showed initally. For example:
results in
|
I've never tried myself to get advertising data to work. For my purposes manufacturer data and service data were enough. It makes sense though that the size of these fields is limited, since all data must be packed into one BLE packet which is constrained in size. If you need to transmit more data using advertisements the only way is to periodically change your advertisement and break up your message into chunks. For finding out the exact rules what can be put into the advertising data field I recommend stepping through |
Although I compiled BlueZ I have not debugged kernel level modules before, so I'll come up to speed on that. In the meantime I did more debugging by capturing dbus messages and looking at them in Wireshark to compare what messages are sent by BlueR to BlueZ when the advertisements work and do not work. One difference I saw is the array length for the advertisement data property (Data). Advertising works when
BlueZ has a "Failed to parse advertisement." when
BlueZ has a "Failed to parse advertisement." when
@surban Does the array length of 8 and 9 in the above example look correct to you? |
I can't really tell if this is correct or not, since I am just a user of the D-Bus library and have no knowledge about the underlying protocol. However, I don't see why wrong D-Bus messages should be generated for advertising data but not for manufacturer data. You don't need to debug the kernel. The parse error is most likely coming from |
Oh cool I didn't realize bluetoothd is a user level process. I'll debug that and see what I find. |
I believe I found root cause and it is that BlueR is not sending the advertising data with the dbus wrapper expected by bluetoothd. I demonstrated this by looking in bluetoothd's advertising.c on line 654 it expects a DBUS_TYPE_VARIANT "v", but receives an array type "a" from BlueR. That caused the fail I was seeing. I found that if I I demonstrated this by creating an advertisement in BlueR with the line I found you are not able to send data types that are registered in Bluetooth's
This is why I used 0x0B. @surban would the next step be for me to modify BlueR's dbus wrapper to match what bluetoothd is expecting and file a PR? |
Yes. You could also extend the documentation with your findings about forbidden data types. |
Good idea, will do
…On Fri, Oct 7, 2022 at 6:57 AM Sebastian Urban ***@***.***> wrote:
Yes. You could also extend the documentation with your findings about
forbidden data types.
—
Reply to this email directly, view it on GitHub
<#49 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACLYMF2LF6OFYZFCEMKA5ATWB762PANCNFSM6AAAAAAQVFZKPY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
So what is working for me is modifying
to
This is satisfying D-Bus's variant requirement and the advertisements include the type and data in advertisting_data. I'll put together a PR with documentation updates for review. |
This is the file I used to test (renaming .txt to .rs) |
@ln-12 this is an interesting problem. The issue appears to be that the maximum payload size of the advertising packet (37 bytes) was reached. When I turned on debugging in bluetoothd I got the error message:
@surban do you think it is possible to have BlueR return a more descriptive error message? |
Generally |
# This is the 1st commit message: BLE Passive Scanning # This is the commit message #2: monitor # This is the commit message bluez#3: monitor # This is the commit message bluez#4: monitor # This is the commit message bluez#5: monitor # This is the commit message bluez#6: monitor # This is the commit message bluez#7: monitor # This is the commit message bluez#8: monitor # This is the commit message bluez#9: monitor # This is the commit message bluez#10: monitor # This is the commit message bluez#11: monitor # This is the commit message bluez#12: monitor # This is the commit message bluez#13: monitor # This is the commit message bluez#14: monitor # This is the commit message bluez#15: monitor # This is the commit message bluez#16: monitor # This is the commit message bluez#17: monitor # This is the commit message bluez#18: monitor # This is the commit message bluez#19: monitor # This is the commit message bluez#20: monitor # This is the commit message bluez#21: monitor # This is the commit message bluez#22: monitor # This is the commit message bluez#23: monitor # This is the commit message bluez#24: monitor # This is the commit message bluez#25: monitor # This is the commit message bluez#26: monitor # This is the commit message bluez#27: monitor # This is the commit message bluez#28: monitor # This is the commit message bluez#29: monitor # This is the commit message bluez#30: monitor # This is the commit message bluez#31: monitor # This is the commit message bluez#32: monitor # This is the commit message bluez#33: monitor # This is the commit message bluez#34: monitor # This is the commit message bluez#35: monitor # This is the commit message bluez#36: monitor # This is the commit message bluez#37: monitor # This is the commit message bluez#38: monitor # This is the commit message bluez#39: monitor # This is the commit message bluez#40: monitor # This is the commit message bluez#41: monitor # This is the commit message bluez#42: monitor # This is the commit message bluez#43: monitor # This is the commit message bluez#44: monitor # This is the commit message bluez#45: monitor # This is the commit message bluez#46: monitor # This is the commit message bluez#47: monitor # This is the commit message bluez#48: monitor # This is the commit message bluez#49: monitor # This is the commit message bluez#50: monitor # This is the commit message bluez#51: monitor # This is the commit message bluez#52: monitor # This is the commit message bluez#53: monitor # This is the commit message bluez#54: monitor # This is the commit message bluez#55: monitor # This is the commit message bluez#56: monitor # This is the commit message bluez#57: monitor # This is the commit message bluez#58: monitor # This is the commit message bluez#59: monitor # This is the commit message bluez#60: monitor # This is the commit message bluez#61: monitor # This is the commit message bluez#62: monitor
I cannot set the advertisting_data field of the Advertisement struct to a valid value.
Every value I have tried for
advertisting_data: BTreeMap<u8, Vec<u8>>
results in a BlueR error ofwhich results from the BlueZ bluetoothd which has the following debug information indicating an error parsing the Data property
I have looked in BlueZ's advertising.c, but it is unclear why it isn't happy with what BlueR is sending to it over D-Bus.
I have followed Silicon Lab's recommendation for sending advertising data.
For the advertising data type (the u8) I am following Bluetooth Document Generic Access Profile Revision Date: 2021-07-13 Assigned numbers and GAP.
I am assuming the advertising data is the data being placed in the AdvData field of ADV_IND, ADV_NONCONN_IND, ADV_SCAN_IND, AUX_ADV_IND, and AUX_CHAIN_IND PDUs as defined in
Bluetooth Core Specification 5.3:Vol. 3, Part C section 11
For the below examples
test_data
is defined aslet mut test_data = BTreeMap::<u8, Vec<u8>>::new();
is being passed to the advertisement:The following all generate the same parse error.
I set flag data type, 0x01, and I send data 0x06
test_data.insert(0x01, vec![0x06]);
I set the Complete List of 16-bit Service Class UUIDs data type, 0x03, with
test_data.insert(0x01, vec![0x09, 0x18]);
which is Health Thermometer service 0x1809I set the Complete Local Name data type, 0x09, with
test_data.insert(0x09, vec![0x54, 0x68, 0x65, 0x72, 0x6D, 0x6F, 0x6d, 0x65, 074, 0x65, 0x72, 0x20, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65]);
which is "Thermometer Example"Any thoughts on what the problem is?
The text was updated successfully, but these errors were encountered: