Handle write of all characteristic events

4 posts / 0 new
Last post
Sam123
Offline
Last seen:5年8个月前
加入:2015-02-19 05:43
Handle write of all characteristic events

Hi Dialog Team,

Can i use sample128_val_ind_handler() to handle write of all the characteristic event indication from sample128 profile ? Or do i have to create handler functions for each characteristic?I have four characteristics and i want to control one GPIO pin from each characteristic. How should i implement this?

Device:
VesaN
Offline
Last seen:5 years 4 months ago
Guru Master
加入:2014-06-26 08:49
Yes, you can use only one

Yes, you can use only one handler function. If you want to be efficient, you can only use one characteristic. One byte in characteristic value attribute could indicate the state of IO pin

Sam123
Offline
Last seen:5年8个月前
加入:2015-02-19 05:43
Hi Vesa,

Hi Vesa,
I want to control 4 GPIO pins. One characteristic for each pin.
How does "One byte in characteristic value attribute could indicate the state of IO pin"?
I am using only one handler function but the output is correct for only the first characteristic. I am able to write in the remaining 3 characteristics but cant control the GPIO pins on this basis. Please help.

VesaN
Offline
Last seen:5 years 4 months ago
Guru Master
加入:2014-06-26 08:49
Hi Sam123,

Hi Sam123,

there are many ways to do that I suppose. You can hold the state of GPIO pins in one byte, each bit representing one pin. For example 1 could indicate HIGH and 0 is LOW. Then1101 0000would mean pins 1, 2 and 4 are HIGH and 3 is LOW. Writing to the characteristics would change the pin states correspondingly.

Unfortunately, I think it is not possible to have a separate handler function for gatt read operation for DA14580, if I remember correctly. It might be handy, but you can manage without it too.