N neilcarter New Member Licensed User Longtime User Jul 28, 2021 #1 Hi New to B4A - looking to read the raw advertising packet from a BLE peripheral, the peripheral uses a custom advertising packet and I have gone through the examples but am at a loss how to do this. Neil
Hi New to B4A - looking to read the raw advertising packet from a BLE peripheral, the peripheral uses a custom advertising packet and I have gone through the examples but am at a loss how to do this. Neil
Erel B4X founder Staff member Licensed User Longtime User Jul 28, 2021 #2 The advertising data is received in the DeviceFound event. You should get whatever you need from the map. Upvote 0
The advertising data is received in the DeviceFound event. You should get whatever you need from the map.
N neilcarter New Member Licensed User Longtime User Jul 28, 2021 #3 Yes I understand that and how to get the standard elements of the packet - but i cant see how to get the raw packet needed as its a custom packet - maybe im missing something obvious - but i cant find it anywhere. Upvote 0
Yes I understand that and how to get the standard elements of the packet - but i cant see how to get the raw packet needed as its a custom packet - maybe im missing something obvious - but i cant find it anywhere.
Erel B4X founder Staff member Licensed User Longtime User Jul 29, 2021 #4 The advertising data map will hold all the data. It doesn't matter whether it is custom or not. Key 0 will return the complete data. Upvote 0
The advertising data map will hold all the data. It doesn't matter whether it is custom or not. Key 0 will return the complete data.
N neilcarter New Member Licensed User Longtime User Jul 29, 2021 #5 ok thank you , i will try key 0, can you point me at any documentation for the map and what is returned in the different keys ? Upvote 0
ok thank you , i will try key 0, can you point me at any documentation for the map and what is returned in the different keys ?
Erel B4X founder Staff member Licensed User Longtime User Jul 29, 2021 #6 BleManager parses the advertising data to keys and values and returns a map with those pairs. This is why there is really no reason to get the complete data. You will just need to parse it yourself. The meaning of the various keys and values depend on the specific peripheral that you are communicating with. You can see the information with: Code: Copy Dim bc As ByteConverter For Each k As Int In AdvertisingData.Keys Log($"${k}: ${bc.HexFromBytes(AdvertisingData.Get(k))}"$) Next Upvote 0
BleManager parses the advertising data to keys and values and returns a map with those pairs. This is why there is really no reason to get the complete data. You will just need to parse it yourself. The meaning of the various keys and values depend on the specific peripheral that you are communicating with. You can see the information with: Code: Copy Dim bc As ByteConverter For Each k As Int In AdvertisingData.Keys Log($"${k}: ${bc.HexFromBytes(AdvertisingData.Get(k))}"$) Next