Author Topic: Connect to GATTClient without Discover  (Read 13853 times)

Offline DME

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Connect to GATTClient without Discover
« on: March 21, 2022, 02:21:45 PM »
How can I connect to a Gatt client without first running a Discover?
If I only know the address of a device and would like to connect to it.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Connect to GATTClient without Discover
« Reply #1 on: March 21, 2022, 04:38:43 PM »
Hello,

It is easy: Just use wclGattClient, set device's address and call Connect(). However, Microsoft Bluetooth driver requires that the device has to be found first any how. The simplest way to do that is to use wclBluetoothLeBeaconWatcher and any of its event (take a look on Beacons demo). Once device appears as available you can connect to it without any problem.

Offline DME

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Connect to GATTClient without Discover
« Reply #2 on: March 21, 2022, 04:56:53 PM »
Thank you for the quick reply. I have now also managed by directly creating a BluetoothManager and passed the radio from GetLERadio to the Connect function. When I try it as you described I get an error when compiling because the Connect method needs a radio.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Connect to GATTClient without Discover
« Reply #3 on: March 21, 2022, 05:02:12 PM »
Yes, it needs the Radio object and that is good way to use GetLeRadio() method (we also use this way). Also I do recommend to take a look on our WeDo implementation where we use wclBluetoothLeBeaconWatcher to detect WeDo HUBs by its primary service. I hope the code saves your time: https://github.com/btframework/WeDo/blob/master/NET%20Edition/WeDo%20Framework/wclWeDoWatcher.cs

It works as devices monitoring: when device found or lost it fires events.

 

Sitemap 1 2 3 4 5 6 7