ReactiveBeacons
ReactiveBeacons copied to clipboard
ScanRecord passing into Beacon object
It would be valuable to have ScanRecord object passed in Beacon object. Currently there is only the raw byte[] buffer - it is difficult to extract vender specific information from raw data.
Hi @dominolog,
Thanks for the nice idea. Right now, there is just array of bytes because BluetoothAdapter.LeScanCallback
provides it by default. It's possible to return ScanRecord
object as well, but we need to provide a method to convert bytes into this object. As far as I see ScanRecord
doesn't have anything like that in the public API, but I'm pretty sure it must be hidden somewhere in the source of files in android.bluetooth.le
package. Once I figure it out, I'll add this. Of course PRs are welcome, if you want this feature quicker :).
Regards, Piotr
I've added this feature on scanresult-in-beacon branch, but it works LollipopScanStrategy
only for now. It means it will work for Lollipop Android version or higher. I'm not sure if it's possible to add it in PreLollipopScanStrategy
with the API provided before Lollipop. Right now, ScanResult
in Beacon
class will be null
in Android version older than Lollipop. You can test and investigate it on the feature branch.
Sorry, I've added ScanResult
instead of ScanRecord
, but ScanRecord
can be extracted from it and it still works for Lollipop or higher only. I'll investigate it further.