kopia lustrzana https://github.com/micropython/micropython-lib
aioble/client.py: Fix default for the `response` arg to char.write().
- `_FLAG_WRITE` was incorrectly `_FLAGS_WRITE` - `response` should be defaulted to `None` rather than `False` in order to detect that when it is unspecified. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>pull/570/head
rodzic
82f6b18b88
commit
50b7aca171
|
@ -269,16 +269,13 @@ class BaseClientCharacteristic:
|
||||||
characteristic._read_status = status
|
characteristic._read_status = status
|
||||||
characteristic._read_event.set()
|
characteristic._read_event.set()
|
||||||
|
|
||||||
async def write(self, data, response=False, timeout_ms=1000):
|
async def write(self, data, response=None, timeout_ms=1000):
|
||||||
self._check(_FLAG_WRITE | _FLAG_WRITE_NO_RESPONSE)
|
self._check(_FLAG_WRITE | _FLAG_WRITE_NO_RESPONSE)
|
||||||
|
|
||||||
# If we only support write-with-response, then force sensible default.
|
# If the response arg is unset, then default it to true if we only support write-with-response.
|
||||||
if (
|
if response is None:
|
||||||
response is None
|
p = self.properties
|
||||||
and (self.properties & _FLAGS_WRITE)
|
response = (p & _FLAG_WRITE) and not (p & _FLAG_WRITE_NO_RESPONSE)
|
||||||
and not (self.properties & _FLAG_WRITE_NO_RESPONSE)
|
|
||||||
):
|
|
||||||
response = True
|
|
||||||
|
|
||||||
if response:
|
if response:
|
||||||
# Same as read.
|
# Same as read.
|
||||||
|
|
Ładowanie…
Reference in New Issue