-
Im building a GTK application that uses this library to handle bluetooth as it seems like the most feature complete library for rust, however, due to the nature of discover_devices being infinite loop, the program just freezes whenever i try to run it. I would like to know if there's a way to break out of the loop when there are no more devices to list, or a way to get the number of devices to be used in a for loop. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
discover_devices returns a stream of devices. This is not an infinite loop. However, there is no way to be sure that all devices have been listed since Bluetooth device discovery is a stochastic process (sender and receiver need to hop on same channel simultaneously during discovery). Also new devices might become active during discovery. You might want to wait a predefined amount of time before ending discovery, or, better yet, update your GUI every time a new device is discovered. |
Beta Was this translation helpful? Give feedback.
-
yep, i figured i mustve messed something up and rewrote the program to be dynamically updated |
Beta Was this translation helpful? Give feedback.
discover_devices returns a stream of devices. This is not an infinite loop.
However, there is no way to be sure that all devices have been listed since Bluetooth device discovery is a stochastic process (sender and receiver need to hop on same channel simultaneously during discovery). Also new devices might become active during discovery.
You might want to wait a predefined amount of time before ending discovery, or, better yet, update your GUI every time a new device is discovered.