-
Notifications
You must be signed in to change notification settings - Fork 9
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
Parsing advertisement data into elements #34
Comments
Quick answer: yes, if there is a change you'd like to make to this gem - especially if it would be helpful for more than just your particular use case - we'd be happy to get a PR. The Currently this gem makes the assumption that you are scanning for manufacturer or service advertisements. If you'd like to scan for "complete local name" advertisements as well as your example parsing code above seems to do, we could modify this if statement to make this work a little better. if ad_type == 0x03 # service ad
yield(ad_data[9..-1], mac, rssi, ad_type)
else
yield(ad_data[5..-1], mac, rssi, ad_type)
end That would make it so that it only skips ahead to ignore the service UUID list when it knows it has a service ad. Then when it gets a "local name" ad, it wouldn't accidentally chop it up by skipping ahead to byte 9. With this change to the Does this make sense? |
Hey, sorry for not replying in a long time. I have to admit, the thing that confuses me the most (e.g. also in your code snippet) is the use of fixed offsets. As far as I understand the bluetooth spec (the very few parts I read... actually lots of blog posts), the advertisement data can contain multiple elements, that can occur in any order, some elements might be omitted and some elements have a dynamic length. Therefore using the fixed offsets in the actual code and your example above seems to only target very specific kinds of beacons. I feel like I am missing an important point here... Regarding my proposal for a Pull Request: I am not sure if there would be a good general way to integrate my parser method into the general code base without introducing breaking changes. Also I could only test anything on Linux. I could provide my element-based iterator as an alternative method in the What do you think? |
Hi there,
tl; dr: I want to offer making a contribution to the gem, in case you are interested and still maintaining it.
thanks for this gem, I am going to use it to scan custom BTLE advertisements I am sending out from an ESP32.
Since my custom advertisements were not yet supported, I first looked into
BlueZScanner
, to see how advertisements get parsed. While I could immediately see my advertisements usingBlueZScanner.each_advertisement
, the data looked off:I noticed that the scanner is depending on fixed offsets in the
ad_data
, which seems to collide with my beacon announcing its device name.I scribbled together some parsing code, which will (hopefully) correctly unpack the
ad_data
into separate AD elements:which gives me correct output for my beacon:
Now to my question: Would you be interested in integrating that into your gem? In that case I would try to prepare a pull request that makes this parsing available. However, in case you are not interested, I'd just have a "local" method for my own project.
Disclaimer: I have my Bluetooth LE knowledge from blog articles and I am probably still not knowing all the relevant details...
The text was updated successfully, but these errors were encountered: