BluetoothLeAdvertiser AdvertiseCallback引发ADVERTISE_FAILED_TOO_MANY_ADVERTISERS [英] BluetoothLeAdvertiser AdvertiseCallback throws ADVERTISE_FAILED_TOO_MANY_ADVERTISERS
问题描述
我具有以下代码来创建广告:
I have this code to create an Advertise:
private void startLeAdvertise() {
AdvertiseSettings settings = new AdvertiseSettings.Builder()
.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
.setConnectable(true)
.setTimeout(ADVERTISE_TIMEOUT)
.build();
AdvertiseData data = new AdvertiseData.Builder()
.addServiceUuid(new ParcelUuid(UUID.fromString(BEACON_SERVICE)))
.build();
mAdvertiseCallback = new AdvertiseCallback() {
@Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
super.onStartSuccess(settingsInEffect);
Log.i(TAG, "======= onStartSuccess:");
Log.i(TAG, settingsInEffect.toString());
}
@Override
public void onStartFailure(int errorCode) {
super.onStartFailure(errorCode);
String description = "";
if (errorCode == AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED) {
description = "ADVERTISE_FAILED_FEATURE_UNSUPPORTED";
} else if (errorCode == AdvertiseCallback.ADVERTISE_FAILED_TOO_MANY_ADVERTISERS) {
description = "ADVERTISE_FAILED_TOO_MANY_ADVERTISERS";
} else if (errorCode == AdvertiseCallback.ADVERTISE_FAILED_ALREADY_STARTED) {
description = "ADVERTISE_FAILED_ALREADY_STARTED";
} else if (errorCode == AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE) {
description = "ADVERTISE_FAILED_DATA_TOO_LARGE";
} else if (errorCode == AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR) {
description = "ADVERTISE_FAILED_INTERNAL_ERROR";
} else {
description = "unknown";
}
Log.i(TAG, "error: " + description);
}
};
mBluetoothLeAdvertiser = BluetoothAdapter.getDefaultAdapter().getBluetoothLeAdvertiser();
mBluetoothLeAdvertiser.startAdvertising(settings, data, mAdvertiseCallback);
}
无论我总是得到什么
ADVERTISE_FAILED_TOO_MANY_ADVERTISERS
ADVERTISE_FAILED_TOO_MANY_ADVERTISERS
我正在与
进行测试
一加X(ONE E1003)
-API 5.1.1;
-氧气2.2.0;
-内核3.4.0-pref +;
I'm testing with
One Plus X (ONE E1003)
- API 5.1.1;
- Oxygen 2.2.0;
- Kernel 3.4.0-pref+;
Nexus 5
-API 6.0.1;
-内核3.4.0-g7717f76;
Nexus 5
- API 6.0.1;
- Kernel 3.4.0-g7717f76;
(有趣的是,有了Nexus,我得到了isMultipleAdvertisementSupported == false
,所以它也不起作用...)
(funny thing, with Nexus I get isMultipleAdvertisementSupported == false
so it doesn't work either...)
编辑-使用此模型就可以了:
EDIT - With this model works just fine:
Galaxy S6(SM-G920F)
-API 5.1.1;
-内核3.10.61-5816106;
Galaxy S6 (SM-G920F)
- API 5.1.1;
- Kernel 3.10.61-5816106;
我最初的问题是,为什么我总是得到ADVERTISE_FAILED_TOO_MANY_ADVERTISERS
.现在,我发现它适用于S6,但不适用于Nexus 5,该怎么办?是制造商/硬件问题还是操作系统版本?谢谢.
My original question was, why I'm always getting ADVERTISE_FAILED_TOO_MANY_ADVERTISERS
. Now that I found that it works with S6 but not with Nexus 5 what can I assume? Is it a manufacturer/hardware problem or OS version? Thanks.
推荐答案
在其他设备上运行了更多测试之后,我发现这是实现它的正确方法,但仅适用于少数芯片组.有关此技术的更多信息,请访问:支持Android 5 BLE外设模式的芯片组/设备
After running more tests with other devices I found out that this is the proper way to implement it but it will only work with a few chipsets. More information about this technology here: Chipsets/Devices supporting Android 5 BLE peripheral mode
这篇关于BluetoothLeAdvertiser AdvertiseCallback引发ADVERTISE_FAILED_TOO_MANY_ADVERTISERS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!