Author Topic: .Net Device Discover  (Read 11483 times)

Offline sommerat

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
.Net Device Discover
« on: October 31, 2018, 02:08:42 PM »
In Framework Version 7.5.x the wclBluetoothRadio.Discover() Function runs for ~the amount of timeout seconds but then it hangs for another ~timeout seconds where the whole program freezes. After that the Callback OnDiscoveringCompleted is fired and program is working fine.
Windows 10, VS 2015, WPF Application, Microsoft Stack
Will try the demo application now to see if it occurs there too.

We have used wcl Librabry prior to Version 7 and when the Bluetooth Framework came out we used the Demo of Version 7.3.2.0 to see if there are any improvements.
There were, so we decided to switch to the Framework and it was fine for Version 7.3.2.0

Offline sommerat

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: .Net Device Discover
« Reply #1 on: October 31, 2018, 02:39:53 PM »
Just checked - Bluetooth Manager Demo Project Version 7.5.6.0 does not show bad behaviour.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: .Net Device Discover
« Reply #2 on: October 31, 2018, 02:49:28 PM »
Hello,

Unfortunately its hard to say what can be wrong without seeing your code. Probably you do something inside OnDiscoverCompleted event.

Offline sommerat

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: .Net Device Discover
« Reply #3 on: October 31, 2018, 05:23:55 PM »
The freeze actually occurs before OnDeviceFound and freezes longer if there are more devices around.
The Callbacks do pretty much the same as in the Bluetooth Manager example - add devices to a List and set result for a task on completion; but they are called after the freeze, so it cannot be something inside those.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: .Net Device Discover
« Reply #4 on: October 31, 2018, 05:27:46 PM »
Can you please send me the code that reproduces the issue by skype (mike.petrichenko) or by-email (mike@btframework.com) so I can reproduce it here and fix if it is something in Bluetooth Framework?

In fact there is nothing that may cause freez of main UI thread because discovering runs in separate thread always and simple posts (not send!) notification to the main thread.

Also, do you run it (discovering) in thread? If so, how do you do it?

You can contact me by Skype to solve the problem faster.

Offline sommerat

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: .Net Device Discover
« Reply #5 on: October 31, 2018, 05:51:17 PM »
Thanks for the reply; I just found out that it really does happen in OnDeviceFound - I call GetRemotePaired and EnumRemoteServices and the such inside it. If I remove that from code there is no freeze of UI.
But before 7.5.x this sequence of function calls worked like a charm...
I guess i can restructure the program to call those Radio functions after the discovery has finished unless you would say this should still work; then I could send you some code snippets.

I will get back to you next week!

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: .Net Device Discover
« Reply #6 on: October 31, 2018, 06:06:17 PM »
EnumRemoteServices executes connection to device and always takes time. Also that is no good idea (by few reasons) to query device until OnDisconveryCompleted fired. It may cause problems becuase disocvering command is exclusive. Its better to store device's MAC in the list inside OnDeviceFound and then do all the things you need inside OnDiscoveryCompleted.

It is not a problem to run EnumRemoteServices for each found devices in separate threads so ti will not blovk UI.

 

Sitemap 1 2 3 4 5 6 7