Tag: bluetooth lowenergy

Windows Phone 8.1中的信标 – 没有可能吗?

首先,是的,我已经阅读了所有其他类似的问题。 其次,我正在开发app(WP 8.1 WinRT),它必须使用Beacons。 我读了很多关于它的信息,我知道,如果没有先配对它,通常无法与BLE设备连接。 但希望终于死了,所以我想询问我的任何可能性。 可以在代码中配对设备(根据我读过的文章 – 不是,但也许有人知道的方式)? 或者只是获取附近的Beacons Id或Name,或者有关它们的任何信息? 我发现的所有post都已过时(从去年开始,也许MS或某人发布了一些更新/ api?)我搜索任何类型的解决方案,api或只是想法如何避免配对问题。 手动配对不起作用 – 1.不确定是否可以配对信标,2。它太多了(我需要的信标)我无论如何都要寻找通信甚至获取信标。 我会很感激任何选择或想法

如何停止调用导致IAsyncOperation?

在我的应用程序中,我通知多个设备 如果设备无法访问且几秒钟内没有响应,我想取消呼叫。 我的代码是: await characteristic0.WriteClientCharacteristicConfigurationDescriptorAsync (GattClientCharacteristicConfigurationDescriptorValue.Notify); 经过一些研究后我发现通常可以传递CancelationToken(_ct)并执行此操作: 首先创建一个包含调用的操作: IAsyncOperation operation = characteristic0.WriteClientCharacteristicConfigurationDescriptorAsync (GattClientCharacteristicConfigurationDescriptorValue.Notify); 然后使用CancellationToken创建任务: Task task = operation.AsTask(_ct); 然后等待它: GattCommunicationStatus status = await task; 现在,即使CancellationToken的IsCancellationRequested -Property设置为true,也是如此。 电话不会停止。 并且,设备在第一行之后已经通知 ! 是不是应该在await之后发生? 我是否在使用令牌时犯了错误,或者这是一个更大的问题? 编辑 在与@Andrii Litvinov交谈之后,我将更多代码添加到我对问题的初步描述中。 这是整个方法: public async Task NotifyDevice(DeviceInformationDisplay deviceInfo, CancellationToken _ct) { try { BluetoothLEDevice device = await BluetoothLEDevice.FromIdAsync(deviceInfo.Id); service = device.GetGattService(new Guid(Service_UUID)); characteristic0 […]

如何在桌面.NET应用程序中获得BLE广告回调?

我试图从.NET Windows桌面应用程序获取BLE广告回调。 我能够调用API,但是从未在WPF或命令行应用程序中从OS调用Received事件。 当从VS2015中的unit testing或通用Windows应用程序调用代码时,我确实得到了事件。 但是,我需要做其他通用Windows中没有的东西。 这是代码: using Windows.Devices.Bluetooth.Advertisement; public static void ScanForAdvertisments() { mWatcher = new BluetoothLEAdvertisementWatcher(); mWatcher.Received += OnAdvertismentReceived; mWatcher.ScanningMode = BluetoothLEScanningMode.Active; mWatcher.Start(); } public static void OnAdvertismentReceived(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args) { ulong address = args.BluetoothAddress; short rssi = args.RawSignalStrengthInDBm; } 我引用了Windows.winmd以包含BLE / UWP名称空间。 我在Windows 10周年纪念版上使用框架版本4.6.1,我在之前的Windows版本中也遇到了同样的问题。 使用UWP应用程序我在appxmanifest中为蓝牙设置了DeviceCapability。 unit testing项目似乎不需要这个,我不知道如何将appxmanifests应用于桌面项目。 status属性报告扫描程序正在运行,并且也永远不会触发已停止的事件。 无论如何,这是一个Windows错误吗? 有办法解决它吗? 我试着研究应用程序服务,但似乎没有设置好很好地调用桌面代码,从UWP调用桌面代码似乎很难部署。 […]

如何使用C#手动绑定到WinForm中的BlueTooth低能耗设备?

这个问题主要通过以下方式解答: Windows UWP在发现后连接到BLE设备 我正在编写一个自定义服务并测试,目前,在Windows 10上使用C#.NET WinForm连接到蓝牙低功耗(BLE)设备。 我正在使用Framework 4.6.1。 我们使用TI SmartRF06评估板和TI CC2650 BLE子卡。 另一位开发人员正在处理董事会的固件。 目前使用类似于上面参考答案的方法,我能够连接到已经绑定的BLE设备。 此设备是手动绑定的,Windows确实要求我输入PIN。 由于设备没有PIN,只需输入“0”即可让设备连接。 一旦连接,以这种方式,我可以获得所有GATT服务并做我需要做的事情。 所以我找到并获得广告BLE设备没有任何问题。 问题是如何连接尚未配对的BLE设备? 我已经浏览了网络并找到了许多BLE代码示例,但没有具体说明如何完成代码中的配对。 不确定我甚至需要它配对,但Windows似乎只在配对设备上显示我的GATT服务。 当我使用不成对的设备执行此操作时: private void BleWatcherOnReceived(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args) { var dev = await BluetoothLEDevice.FromBluetoothAddressAsync(args.BluetoothAddress); // dev.DeviceInformation.Pairing.CanPair is true // dpr.Status is Failed DevicePairingResult dpr = await dev.DeviceInformation.Pairing.PairAsync(DevicePairingProtectionLevel.None); var service = await GattDeviceService.FromIdAsync(dev.DeviceInformation.Id); } 当设备尚未手动配对时,dpr的结果始终失败。 这导致GattDeviceServices为空。 […]

如何从Windows Phone 8.1中发现蓝牙低功耗设备(BLE)

我正在编写一个Silverlight Windows Phone 8.1应用程序,我正在尝试从Windows Phone 8.1连接蓝牙低功耗(BLE)设备,该设备是“心率”,但我没有得到结果。 请参阅下面的代码。 protected async override void OnNavigatedTo(NavigationEventArgs e) { var devices = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid (GattServiceUuids.HeartRate)); if (devices.Count > 0) { } } 我还在appmanifest文件中添加了function。 一切似乎都很好,但我没有得到输出。 出了什么问题?

后台任务注册在UWP中使用GattCharacteristicNotificationTrigger挂起

我正在尝试使用进程内后台任务来获取蓝牙LE设备的通知。 但是,以下代码在最后一行挂起并且不返回: var bldr = new BackgroundTaskBuilder(); bldr.Name = guid.ToString(“N”); var trigger = new GattCharacteristicNotificationTrigger(ch); bldr.SetTrigger(trigger); bldr.Register(); 在应用程序中使用基于事件的模型时,获取设备的通知是有效的。 此外,使用TimeTrigger注册任务是有效的,因此应用程序清单中的声明是可以的。 计算机运行创建者更新,但UWP设置为至少需要周年纪念更新。

C#建立从笔记本电脑内部蓝牙4.0到蓝牙低功耗(BLE)外设的流

我正在尝试编写一个连接到蓝牙低功耗设备(BLE)的程序,然后在更新或给定间隔内读取特征。 我的外设是德州仪器CC2540 BLE设备。 我的出发点是查看TI的示例程序,它有一个心率监视器: http : //processors.wiki.ti.com/index.php/Category : HealthDemo 然而,这使用加密狗,我的任务是使用内部蓝牙4.0调制解调器(稍后将在Android上制作它,但是现在,我只使用Windows)。 现在我的问题是加密狗创建了一个COM端口,但内部调制解调器没有。 我仍然设法使用32feet API扫描并成功找到CC2540。 但是,从这里我不知道该怎么办。 我试过调用connect()方法,但它总是无法连接,无论是超时还是声明存在死网络。 任何想法为什么会这样? 我应该做些什么而不是调用我的device.connect()? 代码段: BluetoothClient cli; BluetoothDeviceInfo[] peers; BluetoothDeviceInfo device; BluetoothAddress adr; //… skipping code that finds the device and assigns the address to it. if (device.InstalledServices.Length != 0) { try { //MessageBox.Show(“attempting to connect”); cli.Connect(device.DeviceAddress, device.InstalledServices[2]); //tbDeviceInfo.AppendText(“\n\nConnected ” + device.Connected); […]

c#蓝牙LE – 写配置错误 – 从未调用ValueChanged

所以我尝试将我的c#WPF程序连接到BLE设备,这是连接到设备的代码: private async Task ConnectToWatcher(DeviceInformation deviceInfo) { try { // get the device BluetoothLEDevice device = await BluetoothLEDevice.FromIdAsync(deviceInfo.Id); // get the GATT service Thread.Sleep(150); var gattServicesResult = await device.GetGattServicesForUuidAsync(new Guid(RX_SERVICE_UUID)); service = gattServicesResult.Services[0]; // get the GATT characteristic Thread.Sleep(150); var gattCharacteristicsResult = await service.GetCharacteristicsForUuidAsync(new Guid(RX_CHAR_UUID)); characteristic = gattCharacteristicsResult.Characteristics[0]; // register for notifications Thread.Sleep(150); characteristic.ValueChanged += […]

FromBluetoothAddressAsync永远不会在WPF应用程序中的Windows 10 Creators Update上返回

我升级到Windows 10,版本1703 build 15063(Creators Update)正式发布。 当我在WPF桌面应用程序中运行以下代码时,BluetoothLEDevice.FromBluetoothAddressAsync永远不会返回。 在我的Windows 10更新(即之前的1607版本14393)之前,此代码工作正常。 如果它在新的Win 10 1703中作为UWP运行,该代码也可以正常工作。 BluetoothLEAdvertisementWatcher BleWatcher = null; private void Button_Click(object sender, RoutedEventArgs e) { BleWatcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active }; BleWatcher.Received += Watcher_Received; BleWatcher.Start(); } private async void Watcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args) { var device = await BluetoothLEDevice.FromBluetoothAddressAsync(args.BluetoothAddress); // never continues beyond this point […]

.Net中的蓝牙低功耗(C#)

是否可以在控制台应用程序中使用蓝牙低功耗(ble)和.Net(C#)? 例如,在uwp应用程序中使用windows.devices.bluetooth。 我只是在uwp中这样做,但我需要为.Net设计的vJoy和作为传感器的MbientLab Metawear C硬件。