<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to set GATT&amp;#39;s write response after a write request?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16922/how-to-set-gatt-s-write-response-after-a-write-request</link><description>Hello, 
 Consider this scenario:
The client successfully writes to a characteristic by the application code can&amp;#39;t use the data sent so it would be usefull to signal the client that the data is invalid, through a GATT access response 
 How can that</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 14 Oct 2016 10:39:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16922/how-to-set-gatt-s-write-response-after-a-write-request" /><item><title>RE: How to set GATT's write response after a write request?</title><link>https://devzone.nordicsemi.com/thread/64860?ContentTypeID=1</link><pubDate>Fri, 14 Oct 2016 10:39:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5144b7b4-853f-4600-8a55-d160123cd693</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;I have updated my answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set GATT's write response after a write request?</title><link>https://devzone.nordicsemi.com/thread/64859?ContentTypeID=1</link><pubDate>Wed, 12 Oct 2016 11:07:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e84bb77-0b19-422b-a93d-d55735b42657</guid><dc:creator>Mario Ribeiro</dc:creator><description>&lt;p&gt;Kristin, thanks a lot for your input!
However I still would like to understand if this is a SDK or BLE limitaton.&lt;/p&gt;
&lt;p&gt;Previously I was using a CSR1011 chip and I used to call a function named &amp;quot;GattAccessRsp&amp;quot; exactly to return/send an &amp;quot;error code&amp;quot; to the client when an invalid value was written to a characteristic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set GATT's write response after a write request?</title><link>https://devzone.nordicsemi.com/thread/64858?ContentTypeID=1</link><pubDate>Mon, 10 Oct 2016 09:43:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e496056c-11b2-41dd-921d-fad90cb46e2d</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;From what I can see, you want to do a &amp;quot;write with response&amp;quot;  (Bluetooth core specification v. 4.2, vol. 3, part G, chapter 4.9.3, see figure below from the spec). In our SDK, that is a &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v3.0.0%2Fgroup___b_l_e___g_a_t_t_c___v_a_l_u_e___w_r_i_t_e___m_s_c.html&amp;amp;cp=2_3_0_1_0_2_2_3_5"&gt;write request&lt;/a&gt;: sd_ble_gattc_write(BLE_GATT_OP_WRITE_REQ, ...).&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/write_5F00_request.PNG" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 14.10.2016:&lt;/strong&gt; Perhaps I misunderstood a little. Do I understand you correctly that what you need is a callback if a client tries to write to/read a value at the server that is not writable/readable?
If you set the property of an attribute (read/write) to &amp;quot;no access&amp;quot;, it will not be possible to read/write that property, and the device will reply with an error to the peer device that tries to read/write to that attribute. The replying with that error is handled by the softdevice.&lt;/p&gt;
&lt;p&gt;An attribute security property is set using BLE_GAP_CONN_SEC_MODE_xxx. That property is added to the attribute when adding it to the softdevice using for example sd_ble_gap_device_name_set(..) or sd_ble_gatts_characteristic_add(..).&lt;/p&gt;
&lt;p&gt;Setting the write property of the device name to no access with the following code, will result in the error code as shown in the below sniffer trace snippet.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void gap_params_init(void)
{
    uint32_t                err_code;
    ble_gap_conn_params_t   gap_conn_params;
    ble_gap_conn_sec_mode_t sec_mode;

    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&amp;amp;sec_mode); 
    err_code = sd_ble_gap_device_name_set(&amp;amp;sec_mode,
                                      (const uint8_t *)DEVICE_NAME,
                                      strlen(DEVICE_NAME));
    APP_ERROR_CHECK(err_code);
    ...
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/sniffer_5F00_snippet.PNG" alt="image description" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>