使用 BT 经典模拟 BLE 广播角色?
Simulate BLE broadcast role using BT classic?
据我所知,目前只有少数android设备具有支持BLE外设模式的芯片组。对于我的应用程序,我希望我的设备充当信标,但我不关心功耗。是否可以使用常规 BT 来广播广告数据,所以附近的手机 运行 BLE 在中央模式下会 "hear" 那个广告?
是的,Android Lollipop 可以。检查 Android 5.0 API:
中的蓝牙低功耗部分
https://developer.android.com/about/versions/android-5.0.html
BluetoothManager bluetoothManager = (BluetoothManager)
getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter myBluetoothAdapter = bluetoothManager.getAdapter();
BluetoothLeAdvertiser myBluetoothLeAdvertiser = myBluetoothAdapter.getBluetoothLeAdvertiser ();
myBluetoothLeAdvertiser.startAdvertising (AdvertiseSettings settings, AdvertiseData advertiseData, AdvertiseCallback callback);
这不应该起作用,因为与 "old" BR/EDR 模式相比,低功耗蓝牙的工作方式非常不同。由于 BLE 使用不同的通道映射和协议,物理层甚至发生了变化。
如果您可以在非常非常低的级别(即固件)上访问您的蓝牙 2.1 控制器,那么通过大量的工作,您可能会成功地以正确的频率偷偷播放广告。不过那是猜测。
据我所知,目前只有少数android设备具有支持BLE外设模式的芯片组。对于我的应用程序,我希望我的设备充当信标,但我不关心功耗。是否可以使用常规 BT 来广播广告数据,所以附近的手机 运行 BLE 在中央模式下会 "hear" 那个广告?
是的,Android Lollipop 可以。检查 Android 5.0 API:
中的蓝牙低功耗部分https://developer.android.com/about/versions/android-5.0.html
BluetoothManager bluetoothManager = (BluetoothManager)
getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter myBluetoothAdapter = bluetoothManager.getAdapter();
BluetoothLeAdvertiser myBluetoothLeAdvertiser = myBluetoothAdapter.getBluetoothLeAdvertiser ();
myBluetoothLeAdvertiser.startAdvertising (AdvertiseSettings settings, AdvertiseData advertiseData, AdvertiseCallback callback);
这不应该起作用,因为与 "old" BR/EDR 模式相比,低功耗蓝牙的工作方式非常不同。由于 BLE 使用不同的通道映射和协议,物理层甚至发生了变化。
如果您可以在非常非常低的级别(即固件)上访问您的蓝牙 2.1 控制器,那么通过大量的工作,您可能会成功地以正确的频率偷偷播放广告。不过那是猜测。