<?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 implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13793/how-to-implement-512-bytes-characteristic-in-peripheral</link><description>Do we have any example for implementing a characteristic with more than 20 bytes?
Thanks.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 22 Jan 2017 07:10:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13793/how-to-implement-512-bytes-characteristic-in-peripheral" /><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52721?ContentTypeID=1</link><pubDate>Sun, 22 Jan 2017 07:10:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db599430-73e8-4049-acf7-e5419be26120</guid><dc:creator>Duoran Li</dc:creator><description>&lt;p&gt;what do you change？It reads more data than what one data packet can hold.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52720?ContentTypeID=1</link><pubDate>Fri, 27 May 2016 16:15:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:218a457a-43ca-4b03-9d32-b04913646d55</guid><dc:creator>Paul</dc:creator><description>&lt;p&gt;OK, I figured it out. Now I know what does &amp;quot;read long&amp;quot; do.
It reads more data than what one data packet can hold. It will send AttReadBlob requests.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52719?ContentTypeID=1</link><pubDate>Fri, 27 May 2016 16:05:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a4ceb56-c9d8-42df-9b2f-09824ca442df</guid><dc:creator>Paul</dc:creator><description>&lt;p&gt;I am doing some test to verify this now. I have a characteristic set to init_len to 40, and max_len = 40. But on Master Control Panel, it only reads the first 20 bytes when I press &amp;quot;discover services&amp;quot; button. When I press &amp;quot;Read&amp;quot; button in the log window it only shows 20 bytes too.
I want to verify I can put more than 20 bytes out before I test my device with Apple devices.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52718?ContentTypeID=1</link><pubDate>Sat, 14 May 2016 01:39:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15566c50-d9bb-4218-9699-55ec5c6647de</guid><dc:creator>Paul</dc:creator><description>&lt;p&gt;Thanks guys, now I &amp;quot;almost totally&amp;quot; understand how it works by your answers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52717?ContentTypeID=1</link><pubDate>Sat, 14 May 2016 00:38:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:177d17aa-da2b-4195-ae64-b8b498a4466c</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;No the central is handling the multi byte packet and offsetting logic by sending repeated ATT calls with different offsets in them. The softdevice just sends back the bytes at that offset, up to the max MTU, or an error message if the characteristic doesn&amp;#39;t have bytes past that offset.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52713?ContentTypeID=1</link><pubDate>Fri, 13 May 2016 15:42:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d92f1fa-e4ea-4775-9a8a-77c09f394442</guid><dc:creator>Paul</dc:creator><description>&lt;p&gt;Sweet, I thought I saw your similar comment somewhere else. LoL. So the softdevice is handling this multiple packet and offsetting logic?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52716?ContentTypeID=1</link><pubDate>Fri, 13 May 2016 12:29:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67bc4673-1aa0-41b0-a569-465916cd2d2a</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Central doesn&amp;#39;t know nor care whether the property is fixed or variable length, it&amp;#39;s not something reported as a property of the characteristic. The central, when reading, will just read at ever larger offsets until it gets a shorter than MTU packet or a response saying there is no data at that offset.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52715?ContentTypeID=1</link><pubDate>Fri, 13 May 2016 12:18:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a55a9abe-731b-4fc1-a8ef-ba319cef39a0</guid><dc:creator>Paul</dc:creator><description>&lt;p&gt;Thanks Martin. Is attribute length to be variable or fixed defined in the central? The spec I have for the peripheral only says length up to 512 bytes. Basically I have to use variable attribute length. But does central care? Or central is going to detect this vlen bit to decide what to do.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52714?ContentTypeID=1</link><pubDate>Fri, 13 May 2016 07:30:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b40ae13c-e634-47cc-8e86-3bb1998be64b</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;When you initialize your characteristic then write:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;attr_md.vlen       = 1; // &amp;lt;- variable attribute length
attr_md.vlen       = 0; // &amp;lt;- fixed attribute length
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v0.9.0/structble__gatts__attr__md__t.html?resultof=%22%62%6c%65%5f%67%61%74%74%73%5f%61%74%74%72%5f%6d%64%5f%74%22%20"&gt;ble_gatts_attr_md_t Struct Reference&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52712?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 13:25:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:327435af-c173-41d1-88cf-3bbeb82b9039</guid><dc:creator>Paul</dc:creator><description>&lt;p&gt;I am testing the code right now. How do I define the attribute value to be fixed or variable? Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52709?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 11:37:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc5010df-c9ea-4c89-b772-2f2fda8ca1f5</guid><dc:creator>Paul</dc:creator><description>&lt;p&gt;Thanks RK! I am writing a peripheral.
You made my day :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52711?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 03:08:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2442875-000f-4cd9-8184-37e2d40f0fc0</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;The 20 byte limitation is for notifications and indications. Characteristics can be as long as the stack supports. If you&amp;#39;re writing the peripheral side (which I assumed without asking, sorry if you&amp;#39;re not), you have nothing to do, central implementations (eg iOS, android) do the necessary repeated reads to get the whole characteristic, if what they read is a full MTU, they just read the next bit until they get something less than a full MTU.&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re writing the central side then yes you have to do the repeated reads. There&amp;#39;s a message sequence chart for that but I don&amp;#39;t think there&amp;#39;s an example, I can&amp;#39;t find one in which the gattc read function is called with anything other than 0 offset, because all the examples use services which have characteristics with fixed lengths shorter than MTU.&lt;/p&gt;
&lt;p&gt;Is this peripheral or central code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52710?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 02:57:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa953e88-8445-4a10-ab57-bded202e0e4f</guid><dc:creator>Paul</dc:creator><description>&lt;p&gt;I thought there is a limitation every packet is only 20 bytes and you need to write your own code to use offsets to let all 512 bytes be read.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement 512 bytes characteristic in peripheral</title><link>https://devzone.nordicsemi.com/thread/52708?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 02:33:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b506bac-13c9-4603-80f6-4b6922473c3f</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Example? Just set the length of the characteristic to what you want when you add it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ble_gatts_attr_t.max_len
ble_gatts_attr_t.init_len
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and note the defines&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define BLE_GATTS_FIX_ATTR_LEN_MAX (510)  /**&amp;lt; Maximum length for fixed length Attribute Values. */
#define BLE_GATTS_VAR_ATTR_LEN_MAX (512)  /**&amp;lt; Maximum length for variable length Attribute Values. */
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>