有没有办法在Windows 10开发中使用iBeacons? 由于以前版本的Windows与iBeacons的开发似乎几乎不可能,现在我们是否有机会支持这项技术?
是否有人开始开发类似的东西?
有没有办法在Windows 10开发中使用iBeacons? 由于以前版本的Windows与iBeacons的开发似乎几乎不可能,现在我们是否有机会支持这项技术?
是否有人开始开发类似的东西?
是的,在Windows 10中,通过Windows.Devices.Bluetooth.Advertisement命名空间支持Beacons用于Windows应用程序。
有关更多信息,请参见Build演讲在Windows 10中构建引人入胜的蓝牙应用程序和蓝牙广告观察器和发布者示例。
以下是在Rob Caplan的答案中提到的基于Windows 10 API与苹果iBeacon一起使用的方法:
BluetoothLEAdvertisementWatcher watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };
watcher.Received += WatcherOnReceived;
private void WatcherOnReceived(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs btAdv)
{
// Optional: distinguish beacons based on the Bluetooth address (btAdv.BluetoothAddress)
// Check if it's a beacon by Apple
if (btAdv.Advertisement.ManufacturerData.Any())
{
foreach (var manufacturerData in btAdv.Advertisement.ManufacturerData)
{
// 0x4C is the ID assigned to Apple by the Bluetooth SIG
if (manufacturerData.CompanyId == 0x4C)
{
// Parse the beacon data according to the Apple iBeacon specification
// Access it through: var manufacturerDataArry = manufacturerData.Data.ToArray();
}
}
}
}
这也是我在开源的 Universal Beacon Library 中实现它的方式,其中包含完整的示例代码和一个应用程序以供测试:https://github.com/andijakl/universal-beacon
BluetoothLeAdvertisementWatcher
类中提供。为了预见这个功能,我们已经开始开发一个开源的Windows Beacon Library,最终将专为在Windows 10上使用而设计。这项工作只是初步阶段。目前,它只能在Windows 8.x设备上与可附加的蓝牙扫描适配器一起使用,以便将其扫描结果传递给库进行解析。对于 Windows 10 之前的版本,您可以使用托管 C# 库 WinBeacon。该库使用简单的 HCI 层并直接与 dongle 进行通信,而不是使用默认的蓝牙堆栈。