有没有办法在 Windows 10 开发中使用 ibeacons?由于使用以前版本的 Windows 开发 ibeacons 似乎几乎是不可能的,我们现在有机会支持这项技术吗?
有没有人开始开发这样的东西?
有没有办法在 Windows 10 开发中使用 ibeacons?由于使用以前版本的 Windows 开发 ibeacons 似乎几乎是不可能的,我们现在有机会支持这项技术吗?
有没有人开始开发这样的东西?
是的,Windows 10 中的 Windows 应用程序通过Windows.Devices.Bluetooth.Advertisement 命名空间支持信标
有关详细信息,请参阅构建谈话在 Windows 10 中构建引人注目的蓝牙应用程序和蓝牙广告观察者和发布者示例。
以下是您如何使用基于 Rob Caplan 回答中提到的新 Windows 10 API 的 Apple iBeacons:
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();
}
}
}
}
这也是我在开源通用信标库中实现它的方式,它附带了完整的示例代码和一个可以试用的应用程序:https ://github.com/andijakl/universal-beacon
微软此前曾表示,它将支持在 Windows 10 中对蓝牙 LE 设备进行应用程序控制的扫描。这是 Windows 8.x 中缺少的移动和桌面设备的基本功能。有关更多信息,请参见此处:https ://stackoverflow.com/a/26234432/1461050
到目前为止,已发布的 Windows 10 预览 API 尚未公开此功能。如果并且当它被公开时,这些 API 应该可以构建一个库来检测蓝牙 LE 信标。
编辑:此功能现在可在新BluetoothLeAdvertisementWatcher
课程中使用。出于对这种能力的预期,我们已经开始开发一个开源的Windows 信标库,该库最终将设计用于 Windows 10。这项工作还处于起步阶段。目前,它只能在 Windows 8.x 设备上与附加的蓝牙扫描加密狗一起使用,后者可以将扫描结果传递给库进行解析。
如果您有兴趣帮助这项工作,请通过上面链接的 GitHub 项目发送说明。
对于 Windows 10 之前的版本,您可以使用托管 C# 库WinBeacon。该库使用简单的 HCI 层并直接与加密狗对话,而不是使用默认的蓝牙堆栈。