0
我正在玩Android和iOS的實驗性Bluetooth LE
程序,現在我在iOS端發送Android端過濾信標廣告時遇到了一些麻煩。 Android有一個功能,可以通過UUID過濾廣告(我需要這個功能,因爲我試圖獲得以特定值開頭的UUID),但是我無法使其工作。這就是我想要的:Android藍牙LE屏蔽UUID過濾器
private void freshen() {
// kill current scanner
if (mLEScanner != null)
mLEScanner.stopScan(mScanCallback);
// set new one to be a match scanner
ScanSettings settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.build();
List<ScanFilter> filters = new ArrayList<>();
// create data uuid starting with the value 1
ParcelUuid data = ParcelUuid.fromString("10000000-0000-0000-0000-000000000000");
// create a mask to ensure only that value is searched
ParcelUuid mask = ParcelUuid.fromString("10000000-0000-0000-0000-000000000000");
// build the filter
ScanFilter.Builder builder = new ScanFilter.Builder();
builder.setServiceUuid(data, mask);
ScanFilter filter = builder.build();
// add the filter to the scanner
filters.add(filter);
mLEScanner.startScan(filters, settings, mScanCallback);
}
它正在產生零結果。即使我將所有掩碼值設置爲0(這是忽略的數字),它仍然會產生零結果。當我刪除過濾器時,會出現大量以1開頭的結果。這在Android的當前版本中打破了嗎?