none
is it possible to connect two BLE devices in a console app project .Net Framework? RRS feed

  • Question

  • 1. I am connecting two BLE devices in console app but if one of them is not sending all the time information or after 3 seconds the Characteristic_ValueChanged handler stop listening, Also if there is one device connected but not sending information after 3 seconds the  Characteristic_ValueChanged stop listening how to fix this? or how does it wirk the characteristic.ValueChanged?

    2. When I connect two BLE device through the console app the Characteristic_ValueChanged just listen from one device its characteristics, I had to save the characteristics of the devices in a list then send them to Characteristic_ValueChanged. How it works this Characteristic_ValueChanged or 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:.......       
            
    }


    Monday, February 19, 2018 3:20 PM

All replies

  • Hi OmarWin,

    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.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 21, 2018 3:57 PM
    Moderator
  • ok It's possible to connect two devices through console app in .net framework 

    GattDeviceServicesResult result = await bleDevice.bluetoothLEDevice.GetGattServicesAsync(BluetoothCacheMode.Uncached);

                                Debug.WriteLine("Services from: {0}", bleDevice.bluetoothLEDevice.Name, NotifyType.StatusMessage);
                                if (result.Status == GattCommunicationStatus.Success)
                                {

                                    Debug.WriteLine(String.Format("It is connect {0}  {1}", bleDevice.isConnect.ToString(), arg), NotifyType.StatusMessage);

    }

    Friday, March 9, 2018 12:36 PM
  • Hi OmarWin,

    Any update? Have you solved your problem? If yes, please mark the solution as answer. This will make answer searching easier in the forum and be beneficial to community members.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 12, 2018 5:50 AM
    Moderator