Skip to content

Commit 50b7aca

Browse files
jimmodpgeorge
authored andcommitted
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>
1 parent 82f6b18 commit 50b7aca

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

micropython/bluetooth/aioble/aioble/client.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,13 @@ def _read_done(conn_handle, value_handle, status):
269269
characteristic._read_status = status
270270
characteristic._read_event.set()
271271

272-
async def write(self, data, response=False, timeout_ms=1000):
272+
async def write(self, data, response=None, timeout_ms=1000):
273273
self._check(_FLAG_WRITE | _FLAG_WRITE_NO_RESPONSE)
274274

275-
# If we only support write-with-response, then force sensible default.
276-
if (
277-
response is None
278-
and (self.properties & _FLAGS_WRITE)
279-
and not (self.properties & _FLAG_WRITE_NO_RESPONSE)
280-
):
281-
response = True
275+
# If the response arg is unset, then default it to true if we only support write-with-response.
276+
if response is None:
277+
p = self.properties
278+
response = (p & _FLAG_WRITE) and not (p & _FLAG_WRITE_NO_RESPONSE)
282279

283280
if response:
284281
# Same as read.

0 commit comments

Comments
 (0)