How to get BLE advertising channel index number

谁说胖子不能爱 提交于 2021-01-28 03:33:20

问题


I would like to get the advertising channel index number when I read the advertisement packet. I can only see that the advertisement information consists of a header info, UUID, major number, minor number and RSSI value. does any of this information have the channel number embedded into it? Can I tell if I'm reading the packet on channel 37/38/39?


回答1:


On all host platforms that use HCI to communicate with the Bluetooth controller, this is not possible since HCI does not expose the channel index in the advertising event. Most "big" systems use HCI, such as Android, iOS, Linux, Windows, ESP32.

Some embedded systems where the Bluetooth controller and host run on the same cpu, might not use HCI. Possibly an API for such a system includes channel index in advertising events. But I have not seen any such API.




回答2:


Neither iOS nor Android provide any APIs to tell you which of the three BLE advertising channels the radio was on when a packet came in.

Lower level platforms like the embedded Nordic SDK do not provide this info either — it is not part of the BLE spec, although it is possible to infer the channel by knowing when BLE scan interval starts and when the packet arrived relative to the start of this interval. Unfortunately, the equivalent technique is not practical on iOS and Android as you have no way of knowing when the scan interval starts. This could be possible on these platforms with an external hardware transmitter designed to send an advertisement only on the first channel, allowing you to infer the timings, and then be able to infer the channel on non-customized BLE devices scanned. But without this, you are out of luck on mobile devices.



来源:https://stackoverflow.com/questions/64310118/how-to-get-ble-advertising-channel-index-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!