【问题标题】:Using multiple Bluetooth HCI simultanously in IoT Core UWP在 IoT Core UWP 中同时使用多个蓝牙 HCI
【发布时间】:2016-11-28 17:25:05
【问题描述】:

在 UWP IoT Core 中,我们可以查询远程蓝牙设备

    var DeviceInfoCollection = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));

我想知道我们是否可以指定 HCI 控制器来查询远程设备,我们需要每个 HCI/加密狗连接 1 个蓝牙 LE 设备以保持数据速率 @100hz。

如果有人可以推荐 C# 或 C++ API,我们都可以选择。

【问题讨论】:

    标签: c# uwp bluetooth-lowenergy managed-c++ windows-10-iot-core


    【解决方案1】:

    不确定我是否完全理解您的问题,但是对于低功耗蓝牙设备,我已经在我的 UWP 应用中完成了类似以下 C# 的操作。

    using System;
    using Windows.Devices.Bluetooth.Advertisement;
    
    namespace WindowsIoTCorePi2FezHat
    {
        internal class BleTagWatcher
        {
            private ulong tagNo;
            private BluetoothLEAdvertisementWatcher watcher;
    
            private const short OutOfRange = -127;
            private short rssi;
            private DateTime lastDetected;
    
            public BleTagWatcher(ulong v)
            {
                this.tagNo = v;
                Rssi = OutOfRange;
    
                watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };
                watcher.Received += OnAdvertisementReceipt;
                watcher.Stopped += (s, a) => { Rssi = OutOfRange; };
                watcher.Start();
            }
    
            private void OnAdvertisementReceipt(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
            {
                if (args.BluetoothAddress == tagNo)
                    Rssi = args.RawSignalStrengthInDBm;
            }
    
            public short Rssi
            {
                get
                {
                    //if (lastDetected.AddSeconds(20) < DateTime.Now)
                    //    return OutOfRange;
                    return rssi;
                }
                set
                {
                    rssi = value;
                    lastDetected = DateTime.Now;
                }
            }
        }
    }
    

    当然,您可以从设备广告中获得更多信息。不仅仅是信号强度。

    有关信息,这是在使用 Windows 10 IoT Core 的 Raspberry Pi 3 上运行的。

    希望这能给你一些指导。

    【讨论】:

      猜你喜欢
      • 2020-09-14
      • 1970-01-01
      • 1970-01-01
      • 2016-11-09
      • 1970-01-01
      • 2015-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多