Write with response #507
-
Hi. If I write to characteristic using writeType set to WriteType.WithResponse, how can I observe/consume the response? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Write with response configures whether or not the link layer will handle the acknowledgement of receipt of a packet. Internally in Kable, we only have visibility into when the link layer is ready to receive the next packet. So, write with response has little to do with getting data back from your peripheral. How you get data from your peripheral is really up to you, but a common design I've seen is to have your peripheral have a characteristic dedicated to writes (we'll call it val response = B.onSubscription { A.write(request) }.first() Some considerations with the above pseudo code:
|
Beta Was this translation helpful? Give feedback.
Write with response configures whether or not the link layer will handle the acknowledgement of receipt of a packet. Internally in Kable, we only have visibility into when the link layer is ready to receive the next packet. So, write with response has little to do with getting data back from your peripheral.
How you get data from your peripheral is really up to you, but a common design I've seen is to have your peripheral have a characteristic dedicated to writes (we'll call it
A
) and a characteristic for observing "responses" (characteristic changes — we'll call itB
):Some considerations with the above pseudo code: