是否可以在控制台应用程序项目.Net Framework中连接两个BLE设备? [英] is it possible to connect two BLE devices in a console app project .Net Framework?

查看:284
本文介绍了是否可以在控制台应用程序项目.Net Framework中连接两个BLE设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


1。我在控制台应用程序中连接两个BLE设备,但如果其中一个没有发送所有时间信息
或3秒后,Characteristics_ValueChanged处理程序停止监听,另外如果有一个设备连接但3秒后没有发送信息  Characteristic_ValueChanged停止监听如何解决这个问题?或者它是如何推卸特征的.ValueChanged?

2。当我通过控制台应用程序连接两个BLE设备时,Characteristics_ValueChanged只是从一个
设备监听其特性,我必须将设备的特性保存在列表中,然后将它们发送到Characteristics_ValueChanged。它是如何工作的这个Characteristics_ValueChanged或characteristic.ValueChanged?

GattCommunicationStatus status = GattCommunicationStatus.Unreachable;
  var cccdValue = GattClientCharacteristicConfigurationDescriptorValue.None;
 if(characteristic.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Indicate))
 {
cccdValue = GattClientCharacteristicConfigurationDescriptorValue.Indicate;
  }
 else if (characteristic.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Notify))
 {
cccdValue = GattClientCharacteristicConfigurationDescriptorValue.Notify;
}
 try
 {
  status = await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(cccdValue);
 if (status == GattCommunicationStatus.Success)
{
 //characteristic.ValueChanged += Characteristic_ValueChanged;
devicesCharacteristicsList.Add(characteristic);
 }
foreach (GattCharacteristic characteristic in devicesCharacteristicsList)
{
characteristic.ValueChanged += Characteristic_ValueChanged;
}


private void Characteristic_ValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
{

switch (sender.Uuid.ToString())
myCases:.......       
        
}






推荐答案

您好OmarWin,

Hi OmarWin,

当您连接到两个BLE设备时,您尝试使用Parallel或Async吗?这将使他们没有两个设备之间的互动。

When you connect to two BLE device, have you try to use Parallel or Async? It would make them without interaction between the two devices.

最好的问候,

Wendy


这篇关于是否可以在控制台应用程序项目.Net Framework中连接两个BLE设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆