Hi all,
I started play with BLE API. I have analyzed some examples and I have a general problem to solve.
In all examples, characteristics are static (mapped to some memory area; integer, boolean, strings variables). And what about a more complicated case? Let's assume that a standard example with LED control is a bit more complicated. We do not want to store current LED status in variable, we want to read LED state at the moment when the read characteristic request arrive. This is general problem with fully “virtual” (dynamic) characteristics. Suppose that my characteristic is state of complicate machine controlled by BLE commands and its state is reported by dynamically created reports. I know that we have “onDataWritten” callback function and its easy to start special process to change state of my “engine”. But what about using 'onDataRead' callback function? In this (callback) function I can run some procedure to create report, but I can't put result into the callback function parameters because it is of type "const". How to send the newly created report in response to read characteristic request? Some ideas (or examples:)?
TIA
Hi all, I started play with BLE API. I have analyzed some examples and I have a general problem to solve.
In all examples, characteristics are static (mapped to some memory area; integer, boolean, strings variables). And what about a more complicated case? Let's assume that a standard example with LED control is a bit more complicated. We do not want to store current LED status in variable, we want to read LED state at the moment when the read characteristic request arrive. This is general problem with fully “virtual” (dynamic) characteristics. Suppose that my characteristic is state of complicate machine controlled by BLE commands and its state is reported by dynamically created reports. I know that we have “onDataWritten” callback function and its easy to start special process to change state of my “engine”. But what about using 'onDataRead' callback function? In this (callback) function I can run some procedure to create report, but I can't put result into the callback function parameters because it is of type "const". How to send the newly created report in response to read characteristic request? Some ideas (or examples:)?
TIA