<?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 give response after client writes to characteristic?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3978/how-to-give-response-after-client-writes-to-characteristic</link><description>I am going to have streaming data come through a characteristic on an S110 device. When the client writes to the characteristic, my peripheral device will read the characteristic value into a buffer and then send the response/ack back to the client. This</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 05 Aug 2017 02:56:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3978/how-to-give-response-after-client-writes-to-characteristic" /><item><title>RE: How to give response after client writes to characteristic?</title><link>https://devzone.nordicsemi.com/thread/14309?ContentTypeID=1</link><pubDate>Sat, 05 Aug 2017 02:56:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:581d170d-89ae-4a90-9bc0-a0500e169651</guid><dc:creator>jay</dc:creator><description>&lt;p&gt;is there any example code for BLEnano slave talking to BLEnano central, in the same context.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to give response after client writes to characteristic?</title><link>https://devzone.nordicsemi.com/thread/14308?ContentTypeID=1</link><pubDate>Mon, 05 Sep 2016 12:53:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:407508cd-3e62-458d-a76a-bcaf5a76d6b2</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;The value is available in the authorize request struct when you get the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event. Or you can get it with sd_ble_gatts_value_get().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to give response after client writes to characteristic?</title><link>https://devzone.nordicsemi.com/thread/14307?ContentTypeID=1</link><pubDate>Sun, 15 Nov 2015 11:10:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7a931ce-e3e6-4bc7-a074-bc0b1b7cac9b</guid><dc:creator>Tanasis!</dc:creator><description>&lt;p&gt;And then, what is the function to retrieve the Characteristic Value from the ATT Table (on the server side)? Using vloc = BLE_GATTS_VLOC_STACK. Thx!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to give response after client writes to characteristic?</title><link>https://devzone.nordicsemi.com/thread/14306?ContentTypeID=1</link><pubDate>Fri, 03 Oct 2014 11:38:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3adeda9-464f-49ba-a666-cf7c4b64d0ac</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I hope you know that there are quite a few layers in BLE, see &lt;a href="https://developer.bluetooth.org/TechnologyOverview/Pages/BLE.aspx"&gt;this&lt;/a&gt; figure.&lt;/p&gt;
&lt;p&gt;In a connection, all packets will be acknowledged in the link layer.&lt;/p&gt;
&lt;p&gt;In the Generic Attribute Profile (GATT) you have several procedures for a characteristic value write. &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0552.Core_5F00_v4.1.pdf"&gt;See Bluetooth Specification 4.1, Vol. 3, Part G, Section 4.9, for details.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Write Without Response and Signed Write Without Response use the Attribute Protocol (ATT) Write Command, and are not acknowledged by the GATT server, they are simply commands.&lt;/p&gt;
&lt;p&gt;Write Characteristic Value uses ATT Write Request and the ATT Write Response. The GATT server acknowledges a write request with a write response.&lt;/p&gt;
&lt;p&gt;The GATT server can perform these procedures without the application knowing, or in terms of BLE, without the application authorizing the procedure. Authorization is a confirmation by the application to continue with the procedure. You want the application to authorize the write request. In the SDK we call this GATTS Write Request with Authorization, see &lt;a href="https://devzone.nordicsemi.com/documentation/nrf51/5.2.0/html/a00877.html"&gt;this&lt;/a&gt; message sequence chart.&lt;/p&gt;
&lt;p&gt;Which procedures that need authorization must be set on the particular characteristic value or descriptor. Read and/or write authorization can be set. One can set the write authorization on the character value like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;attr_md.rd_auth    = 0;
attr_md.wr_auth    = 1;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Whenever a authorization is required the &lt;code&gt;BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST&lt;/code&gt; event is sent to the application. This is a common event for read and write, characteristic values and descriptors.&lt;/p&gt;
&lt;p&gt;Then one would typically check if it is a read or write procedure (&lt;code&gt;p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request.type&lt;/code&gt;) and that the UUID is correct (&lt;code&gt;p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request.request.write.context.char_uuid.uuid&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;One replies to the authorization request with &lt;code&gt;sd_ble_gatts_rw_authorize_reply(...)&lt;/code&gt;, with a &lt;code&gt;ble_gatts_rw_authorize_reply_params_t&lt;/code&gt; as an argument. In it, one must set the authorization type (&lt;code&gt;BLE_GATTS_AUTHORIZE_TYPE_WRITE&lt;/code&gt;) and the GATT status for the operation. To authorize a set the GATT status to (&lt;code&gt;BLE_GATT_STATUS_SUCCESS&lt;/code&gt;), to not authorize set it to (&lt;code&gt;BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Please add a comment if anything is unclear, and I will try to modify my answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>