12

有没有办法在 Windows 10 开发中使用 ibeacons?由于使用以前版本的 Windows 开发 ibeacons 似乎几乎是不可能的,我们现在有机会支持这项技术吗?

有没有人开始开发这样的东西?

4

4 回答 4

5

以下是您如何使用基于 Rob Caplan 回答中提到的新 Windows 10 API 的 Apple iBeacons:

  1. 开始观察信标:

BluetoothLEAdvertisementWatcher watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };
watcher.Received += WatcherOnReceived;

  1. 处理信标数据 - 请注意,根据您的情况,您可能需要通过存储信标并比较蓝牙地址来区分信标

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

于 2015-09-10T09:08:07.847 回答
3

微软此前曾表示,它将支持在 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 项目发送说明。

于 2015-05-04T18:49:23.127 回答
1

对于 Windows 10 之前的版本,您可以使用托管 C# 库WinBeacon。该库使用简单的 HCI 层并直接与加密狗对话,而不是使用默认的蓝牙堆栈。

于 2015-05-30T20:43:57.787 回答