Beacons in Windows 10

对着背影说爱祢 提交于 2020-01-22 05:50:07

问题


Is there any way to use ibeacons with Windows 10 development? Since ibeacons development with previous versions of Windows seemed nearly impossible, will we have the oportunity to support this technology now?

Has anyone started developing something like this?


回答1:


Yes, Beacons are supported for Windows apps in Windows 10 via the Windows.Devices.Bluetooth.Advertisement namespace

See the Build talk Building Compelling Bluetooth Apps in Windows 10 and the Bluetooth Advertisement Watcher and Publisher sample for more information.




回答2:


Here is how you work with Apple iBeacons based on the new Windows 10 APIs mentioned in the answer by Rob Caplan:

  1. Start watching for beacons:

BluetoothLEAdvertisementWatcher watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };
watcher.Received += WatcherOnReceived;
  1. Handle beacon data - note that depending on your scenario, you might need to distinguish between beacons by storing them and comparing the Bluetooth address

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();
            }
        }
    }
}

This is also how I implemented it in the open source Universal Beacon Library, which comes with complete sample code and an app to try it out: https://github.com/andijakl/universal-beacon




回答3:


Microsoft has previously indicated it would support application-controlled scanning for Bluetooth LE devices in Windows 10. This is the fundamental capability that is missing from Windows 8.x for both Mobile and desktop. See here for more info: https://stackoverflow.com/a/26234432/1461050

So far, the published preview APIs for Windows 10 have not exposed this functionality. If and when it is exposed, these APIs should be possible to build a library to detect Bluetooth LE beacons.

EDIT:This capability is now available in the new BluetoothLeAdvertisementWatcher class. In anticipation of this capability, we have started work on an open source Windows Beacon Library which will ultimately be designed for use on Windows 10. This work is only in its infancy. For now, it can only be used on Windows 8.x devices in conjunction with add-on Bluetooth scanning dongles that can pass their scan results to the library for parsing.

If you are interested in helping in this effort, please send a note through the GitHub project linked above.




回答4:


For pre-Windows 10, you could use the managed C# library WinBeacon. The library uses a simple HCI layer and talks directly to the dongle instead of using a default Bluetooth stack.



来源:https://stackoverflow.com/questions/30035696/beacons-in-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!