2023-01-23 08:44 AM
I am currently trying to read the value from a characteristic after detecting that the user has written to it.
I am calling aci_gatt_read_char_value() which is returning 0 (BLE success). From here I am expecting an event which triggers the aci_att_read_resp_event() function but I am not seeing that get called.
However, I am seeing that the Custom_STM_Event_Handler(void *Event) gets called directly after I call this function and the event code is:
I'm not sure what the issue here exactly. Should I be setting a flag and then calling the read function elsewhere? Or is there some other issue with my setup?
Thanks very much
Maks
Solved! Go to Solution.
2023-02-01 06:50 AM
Hello,
Yes, with the modification you don't have to send the write response. So, when you received the write on server side the ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE event is generated and you can perform your action according to the write value received. You can look BLE_p2pServer example available in STM32CubeWB package, to see how manage the write (see PeerToPeer_Event_Handler function p2p_stm.c file).
Best Regards
2023-01-30 08:28 AM
Hello,
When you received the ACI_GATT_ERROR_RESP_EVENT event, which error code do you have?
Best Regards
2023-01-31 01:52 AM
Hi Remy,
The ACI_GATT_ERROR_RESP_EVENT seems to have cleared up by itself. I'm not sure i'm going about this the write way at all. Is there a correct way to access the value that has just been written by the client?
When the client writes to the variable the ACI_GATT_WRITE_PERMIT_REQ_VSEVT_CODE is triggered. Is it correct that I am calling the read function here? Or is there just some variable I can read to see what new value has been written to the characteristic?
Thanks very much,
Maks
2023-02-01 03:02 AM
Hello,
Before calling the read function, you should respond to the write permit request with the write response command. When ACI_GATT_WRITE_PERMIT_REQ_EVENT is received, the application has to check whether the value being requested for write can be allowed to be written and respond with the command ACI_GATT_WRITE_RESP. You can refer to STM32WB_BLE_Wireless_Interface.html documentation to have more detail about ACI_GATT_WRITE_PERMIT_REQ_EVENT and ACI_GATT_WRITE_RESP.
Best Regards
2023-02-01 03:15 AM
Hi,
I've removed these from the GATT attributes now:
I want the client to write without me having to give any sort of response and I want to be able to read what they wrote immediately.
I've removed the "wait for response" GATT attributes.
I assume this removes the necessity for me to send any sort of "ACI_GATT_WRITE_RESP"?
What is the step after this to access the newly written value?
Thanks again
2023-02-01 06:50 AM
Hello,
Yes, with the modification you don't have to send the write response. So, when you received the write on server side the ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE event is generated and you can perform your action according to the write value received. You can look BLE_p2pServer example available in STM32CubeWB package, to see how manage the write (see PeerToPeer_Event_Handler function p2p_stm.c file).
Best Regards
2023-02-02 02:20 AM
This explanation and example have fixed my issue. Thanks very much Remy, much appreciated :)