<?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>issues with writable characteristic</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7350/issues-with-writable-characteristic</link><description>I have a service a writeable characteristic and I&amp;#39;m finding the following issues. 
 Characteristic is read/write, not variable length, size of 4, no read or write auth, no extended attributes (ie no reliable/long writes) 
 
 If I write the characteristic</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 01 Jun 2015 13:36:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7350/issues-with-writable-characteristic" /><item><title>RE: issues with writable characteristic</title><link>https://devzone.nordicsemi.com/thread/26042?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2015 13:36:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7fae04d-8ffb-455b-b4db-537eb493b193</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;thanks again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with writable characteristic</title><link>https://devzone.nordicsemi.com/thread/26041?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2015 13:26:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65731c43-9e13-4fa9-8cab-5643de6200c5</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;oops thought I had - must have misclicked - now marked properly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with writable characteristic</title><link>https://devzone.nordicsemi.com/thread/26040?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2015 11:11:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6771d777-3e02-4e07-87da-ff6504ac3618</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Sure, you&amp;#39;re welcome. Thank you for the feedback, it will contribute to a better SD in the future. Can you mark the question as answered? Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with writable characteristic</title><link>https://devzone.nordicsemi.com/thread/26039?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2015 10:56:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4cf80d9a-0beb-4e32-8de3-ca447bccc44f</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;I see looking at 2. again and see that if you have no authorised attributes and you provide user memory then the stack already has parsed out the values and committed them, I was originally confused by the phrase &amp;#39;app parses the memory it provided&amp;#39; and thought it still needed to commit the values itself, now I see it doesn&amp;#39;t. I wish I could use that, regrettably I have to validate the value on one written characteristic and provide an application error if invalid so I have to do the auth. Since I have to do it for one, I found the easiest code path is to do it for them all.&lt;/p&gt;
&lt;p&gt;Thanks for the detailed explanation - that - plus some of the reading I did after posting the original question, has cleared it up a lot and I think I can improve my implementation a bit more.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with writable characteristic</title><link>https://devzone.nordicsemi.com/thread/26038?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2015 10:40:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fe6c81e-57fa-4c48-bd31-a2440ee76663</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Yes the reason those 2 error codes you mention are not on that list is that we consider those to be only for internal stack usage. However I do agree that the INVALID_OFFSET and PREPARE_QUEUE_FULL should be made usable for the app too, since it can be handling its own queue. I have created an internal issue for that and hopefully we&amp;#39;ll evaluate it and, if applicable, fix it soon.
I understand that the application cannot know how much memory it will need, and neither can the stack, so that&amp;#39;s why we pushed the decision up to the application so that it can be tested/tuned without having to update the SD&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with writable characteristic</title><link>https://devzone.nordicsemi.com/thread/26037?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2015 10:21:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05afd7fe-97e6-40bf-898a-6a20e46423e0</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Thanks for the list of allowed error code , I was trying to figure it out. Is there a reason that neither BLE_GATT_STATUS_ATTERR_INVALID_OFFSET nor BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL are in that list? Yes in this case I am handling the prepared write myself and not returning a memory chunk, that&amp;#39;s unfortunate but necessary for this particular application for one particular characteristic. When you get the memory request you have no idea which characteristics are going to be in the prepared write (you can&amp;#39;t know) so I have to return NULL and deal with it. That means however that I can run out of memory during a Prepare Write and should send QUEUE_FULL and when I process the queue later if there&amp;#39;s an INVALID_OFFSET I&amp;#39;m supposed to return that, but can&amp;#39;t because they&amp;#39;re not on the list. I guess I&amp;#39;ll use INSUF_RESOURCES for the first and ATT_VAL_LENGTH for the second but not ideal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with writable characteristic</title><link>https://devzone.nordicsemi.com/thread/26036?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2015 10:02:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10ef4ed8-3420-412c-88bc-18af0dc479ad</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;First of all, the answer you gave yourself to the first question is correct, and we implement the spec as it&amp;#39;s written.&lt;/p&gt;
&lt;p&gt;Let me try to answer your 2 remaining questions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Characteristic properties are hints, nothing else. The stack treats those properties simply as raw data, and does not enforce any limitations based on them. They are populated by the application and they are supposed to be read/checked by the peer application, but ultimately only &lt;strong&gt;permissions&lt;/strong&gt; are enforced by the stack. This is again per specification. I know it&amp;#39;s a bit confusing, but if the stack was to enforce characteristic properties we would be violating the specification, since the only checks the ATT implementation is supposed to perform are permission-related checks.
You mention prepare write operations, but the same is true for any other one (like a write request on a characteristic that doesn&amp;#39;t have the write without response property set).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You are mixing two things here. If none of the attributes written to by the prepare writes require authorization (and you have provided memory to the stack with user_mem_reply), you will &lt;strong&gt;not&lt;/strong&gt; get any RW_AUTHORIZE_REQUEST events. And in fact if you provide memory to the stack the queued writes will execute transparently just like any other write (request or command) would without you having a chance to approve/reject the operation, just like with any other write. See &lt;a href="https://developer.nordicsemi.com/nRF51_SDK/nRF51_SDK_v8.x.x/doc/8.1.0/s110/html/a01119.html"&gt;here&lt;/a&gt; for an example of this.
If you on the other hand do not provide memory to the stack because you want to handle all prepare write operations yourself (see example &lt;a href="https://developer.nordicsemi.com/nRF51_SDK/nRF51_SDK_v8.x.x/doc/8.1.0/s110/html/a01121.html"&gt;here&lt;/a&gt;) then you can reply to each RW_AUTHORIZE_REQUEST with any of the ones allowed by the stack.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is the list of errors you can use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION
BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE
BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH
BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR
BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES
BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED
BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED
BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION
BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;along with application errors, which are the ones designed to notify the peer of application-level error conditions (like for example properties violated):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;BLE_GATT_STATUS_ATTERR_APP_BEGIN &amp;lt;= error &amp;lt;= BLE_GATT_STATUS_ATTERR_APP_END 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I understand that you need to deal with this when you&amp;#39;re not interested at all in queued writes, but you have to bear in mind that queued writes are like any other write operation and the stack cannot simply reject it autonomously, just like it can&amp;#39;t reject any other write operation unless it targets an attribute that is explicitly authorized.&lt;/p&gt;
&lt;p&gt;Carles&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>