讀取iPhone燈塔按照Bluetooth Advertisement sample,我需要設置CompanyID
(UINT16)和數據(IBuffer,一個UINT16樣品中)以開始觀看廣告客戶。我可以用Windows.Devices.Bluetooth.Advertisement.BluetoothLEManufacturerData
在iPhone中,我可以將信標UUID設置爲4B503F1B-C09C-4AEE-972F-750E9D346784
。並在互聯網上閱讀,我found蘋果公司的ID是0x004C
,所以我試着0x004C
和0x4C00
。
所以,這是我到目前爲止的代碼,但當然,它不工作。
var manufacturerData = new BluetoothLEManufacturerData();
// Then, set the company ID for the manufacturer data. Here we picked an unused value: 0xFFFE
manufacturerData.CompanyId = 0x4C00;
// Finally set the data payload within the manufacturer-specific section
// Here, use a 16-bit UUID: 0x1234 -> {0x34, 0x12} (little-endian)
var writer = new DataWriter();
writer.WriteGuid(Guid.Parse("4B503F1B-C09C-4AEE-972F-750E9D346784"));
// Make sure that the buffer length can fit within an advertisement payload. Otherwise you will get an exception.
manufacturerData.Data = writer.DetachBuffer();
我也試過在UUID反轉字節:
writer.WriteGuid(Guid.Parse("504B1B3F-9CC0-EE4A-2F97-0E75349D8467"));
不是成功爲止。我混合兩種完全不同的技術嗎?
即絕對正確。我只是將'watcher.AdvertisementFilter.Advertisement.ManufacturerData'註釋掉了。Add',返回的樣本是'type = ConnectableUndirected,rssi = -50,name =,manufacturerData = [0x4C:02-15-0F-4E-1E-48-26-F7-4A-47-A0-6C-D9 -B8-42-7D-30-3F-00-01-00-00-09]'。所以,我猜,'02-15'必須是燈塔類型。 – kiewic
太棒了!我很高興聽到它的工作。 – davidgyoung
我已經測試過它,它工作的很好,非常感謝,它幫助了我很多! – Tom