mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
remove the use of set_disconnected_callback
This commit is contained in:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "meshcore"
|
name = "meshcore"
|
||||||
version = "2.1.0"
|
version = "2.1.1"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
||||||
{ name="Alex Wolden", email="awolden@gmail.com" },
|
{ name="Alex Wolden", email="awolden@gmail.com" },
|
||||||
|
|||||||
@@ -51,10 +51,11 @@ class BLEConnection:
|
|||||||
|
|
||||||
if self.client:
|
if self.client:
|
||||||
logger.debug("Using pre-configured BleakClient.")
|
logger.debug("Using pre-configured BleakClient.")
|
||||||
# If a client is already provided, ensure its disconnect callback is set
|
|
||||||
assert isinstance(self.client, BleakClient)
|
assert isinstance(self.client, BleakClient)
|
||||||
self.client.set_disconnected_callback(self.handle_disconnect)
|
|
||||||
self.address = self.client.address
|
self.address = self.client.address
|
||||||
|
# If a client is provided it surely does not have disconnect callback
|
||||||
|
# so recreate it as set_disconnected_callback can't be used anymore ...
|
||||||
|
self.client = BleakClient(self.address, disconnected_callback=self.handle_disconnect)
|
||||||
elif self.device:
|
elif self.device:
|
||||||
logger.debug("Directly using a passed device.")
|
logger.debug("Directly using a passed device.")
|
||||||
self.client = BleakClient(self.device, disconnected_callback=self.handle_disconnect)
|
self.client = BleakClient(self.device, disconnected_callback=self.handle_disconnect)
|
||||||
|
|||||||
Reference in New Issue
Block a user