Open MaxAnderson95 opened 10 months ago
My first attempt at this worked but was a naive approach. It will cause a re-connection on every call to _read_value()
. I moved the connection logic to its own method, and then we call that method in _discover()
or if _client
is none, or if _client.is_connected
is False
.
I also threw in some additional error messaging into the logging call.
When instantiating the
Aranet4
client class, there is the option to specify amac_address
in the constructor. This means the class will connect to this address rather than running auto-disovery to find the aranet4 device.This currently doesn't work, because the
_client
property is never instantiated when specifying the address manually. You simply receive an error that says_client of None type does not have a method read_gatt_char()
.Digging into this, it looks like a simple fix. In the
_read_value()
method, simply always callself._discover()
regardless of ifself.address
is specified or not. The_discover()
method already has logic to check for the presence ofself.address
and will skip auto discovery accordingly. It then properly instantiates theBleakClient
and callsconnect()
.I've tested this and it works perfect for me.