This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to set GATT's Error Response after a write request?

Hi,

at Bluetooth core specification v. 4.2, vol. 3, part G, chapter 4.9.3.

An Error Response shall be sent by the server in response to the Write Request if insufficient authentication, insufficient authorization, insufficient encryption key size is used by the client, or if a write operation is not permitted on the Characteristic Value. The Error Code parameter is set as specified in the Attribute Protocol. If the Characteristic Value that is written is the wrong size, or has an invalid value as defined by the profile, then the value shall not be written and an Error Response shall be sent with the Error Code set to Application Error by the server.

We want to send a error response with Application Error when the write value not in the correct range.

Do you have any example like this?

Thanks.

Parents
  • I don't think we have any examples, but you should follow the flow described here. In addition you need to configure the characteristic to require authentication, see ble_gatts_attr_t -> ble_gatts_attr_md_t -> wr_auth.

  • I still don't see how this answers the question, even though it is tagged as it does. Maybe my need is different. In my case the client is writing a command on a control point but the control point needs to be enabled for indications to receive an application response. So when I get the client WRITE event in the ble callback, and I see the control point is not enabled, I want to call some sd_gatts_* method which sends an error code to the client so the client reads MY error code. I think the error code I want to send is 0xFD.

    The message sequence diagram referenced above just shows how I can block/modify what is written into the GATT database, but there is nothing in that sequence which illustrates how to send an error code back to the client.

    How can I do that? Is that a SoftDevice limitation that wont let the application send write response errors to the client?

Reply
  • I still don't see how this answers the question, even though it is tagged as it does. Maybe my need is different. In my case the client is writing a command on a control point but the control point needs to be enabled for indications to receive an application response. So when I get the client WRITE event in the ble callback, and I see the control point is not enabled, I want to call some sd_gatts_* method which sends an error code to the client so the client reads MY error code. I think the error code I want to send is 0xFD.

    The message sequence diagram referenced above just shows how I can block/modify what is written into the GATT database, but there is nothing in that sequence which illustrates how to send an error code back to the client.

    How can I do that? Is that a SoftDevice limitation that wont let the application send write response errors to the client?

Children
Related