You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a project based on GUI, that interacts with BLE device (device is not commercially avaiable). I use mainly Windows 10, but it works with Windows 11 too. I connect and disconnect with device with async functions:
asyncdef_handler_disconnecting(self, device_class, single_client):
try:
# here is not relevant and private codeifsingle_client.is_connected:
ifdevice_classisnotNone:
logger.debug("Disconnecting device, %s", datetime.now())
device_class.stop_all_notifies()
awaitsingle_client.disconnect()
whilesingle_client.is_connected:
continuelogger.debug('Disconnected single client: %s',
str(single_client.address))
else:
# device_class.stop_all_notifies()self._disconnect_callback(single_client)
logger.warning("Already disconnected: %s", single_client.address)
except (ValueError, Exception) ase:
logger.error('Error disconnecting to device, %s', e)
raiseException(e) frome
It works most of the time. Problem raises when:
a) device disconnects and connects again (this happens on lower levels of software than I reach)
b) device reset itself
After those, even though low-level code does reconnecting, my functions and Bleak objects are "dead". I canot send or receive GATT service and sometimes I get WinError -2147467260. This is a huge problem, because one of functions is reset after sending GATT service. It means, that ideally, after reset everything should get "reconnected". The device gets reconnected not openly (by Bleak or by Windows driver, I do not know). How can I get new object after this hiden reconnect?
I do know, which device did reset (by MAC address), but I do not know how to invoke this hidden new Bleak (?) client. If I create client with BleakClient(address, disconnected_callback=self._disconnect_callback) it is not the same client object, that got reconnected.
I do know that in different languages and on Android you can easily get this kind of "reconnect" event or control it. I do want to know how to do this with Bleak library on Windows. And I do not want to do disconnect and connect on my own, as it takes time and is something completely different for my application than auto-reconnect. I assume there is a some kind of data container in Bleak library, where all clients reside. From this data container I could receive proper, new object. Without proper client object I cannot use my app further. But I do not know what or where is it (or how to access it).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a project based on GUI, that interacts with BLE device (device is not commercially avaiable). I use mainly Windows 10, but it works with Windows 11 too. I connect and disconnect with device with async functions:
It works most of the time. Problem raises when:
a) device disconnects and connects again (this happens on lower levels of software than I reach)
b) device reset itself
After those, even though low-level code does reconnecting, my functions and Bleak objects are "dead". I canot send or receive GATT service and sometimes I get
WinError -2147467260
. This is a huge problem, because one of functions is reset after sending GATT service. It means, that ideally, after reset everything should get "reconnected". The device gets reconnected not openly (by Bleak or by Windows driver, I do not know). How can I get new object after this hiden reconnect?I do know, which device did reset (by MAC address), but I do not know how to invoke this hidden new Bleak (?) client. If I create client with
BleakClient(address, disconnected_callback=self._disconnect_callback)
it is not the same client object, that got reconnected.I do know that in different languages and on Android you can easily get this kind of "reconnect" event or control it. I do want to know how to do this with Bleak library on Windows. And I do not want to do disconnect and connect on my own, as it takes time and is something completely different for my application than auto-reconnect. I assume there is a some kind of data container in Bleak library, where all clients reside. From this data container I could receive proper, new object. Without proper client object I cannot use my app further. But I do not know what or where is it (or how to access it).
Anyone can give my any tip?
Beta Was this translation helpful? Give feedback.
All reactions