Android 5 static bluetooth MAC address for BLE advertising

我怕爱的太早我们不能终老 提交于 2019-11-26 23:21:02

问题


Android 5 introduces BLE MAC address rotating for increased privacy. Every time when calling BluetoothLeAdvertiser.startAdvertising(), the MAC-address is changed.

Is it possible to disable address rotating, and just use the same MAC address during the entire lifetime of BluetoothLeAdvertiser?


回答1:


The MAC Address is a physical address and does not change. In BLE terminology, it is the Public Device Address or BD_ADDR for BR/EDR. I haven't tried it, but reading it with readAddress() should return the same value each time.

What the Android's BLE framework does is NOT use that address when advertising. It rather enables privacy by using Private Resolvable Addresses which may change every few minutes or so but still allow bonded devices to recognize it using the IRK exchanged at bonding.

For obvious privacy reasons, Android's BLE framework does not allow you to set the Controller to use the public address when advertising. So you cannot disable the "address rotating".




回答2:


You can disable the BLE Privacy Feature to avoid the MAC address rotating, and change the bluedroid source code as follows:

http://androidxref.com/5.1.1_r6/xref/external/bluetooth/bluedroid/include/bt_target.h#1326

    * Toggles support for general LE privacy features such as remote address
    * resolution, local address rotation etc.
    */

    #ifndef BLE_PRIVACY_SPT 
    -#define BLE_PRIVACY_SPT         TRUE
    +#define BLE_PRIVACY_SPT         FLASE
    #endif


来源:https://stackoverflow.com/questions/28602672/android-5-static-bluetooth-mac-address-for-ble-advertising

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