<?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>What does the &amp;#39;vloc&amp;#39; mean in ble_gatts_attr_md_t ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48818/what-does-the-vloc-mean-in-ble_gatts_attr_md_t</link><description>Hi there, 
 
 I&amp;#39;m confused with the meaning of the &amp;#39;vloc&amp;#39; variable in the attribute meta data. In the example code ble_bps.c of &amp;quot;ble_app_bps_pca10040_s132&amp;quot; , in the function bps_measurement_char_add(), as below: 
 / **@brief Function for adding Blood</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 24 Jun 2019 11:49:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48818/what-does-the-vloc-mean-in-ble_gatts_attr_md_t" /><item><title>RE: What does the 'vloc' mean in ble_gatts_attr_md_t ?</title><link>https://devzone.nordicsemi.com/thread/194331?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 11:49:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eaa776b5-3a4d-4d89-9891-98b8b5c64d95</guid><dc:creator>jj8431</dc:creator><description>&lt;p&gt;Thanks Edvin, I didn&amp;#39;t have particular reason to think about using user memory, just a bit worried about the memory size as the softdevice memory size was defined in the linker file, if I add one or many large attribute value size later in application code then if it will run out of memory. Anyway that&amp;#39;s not a situation I&amp;#39;m facing right now, so I&amp;#39;ll just use the stack memory as you suggested. Thanks a lot.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Jian&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What does the 'vloc' mean in ble_gatts_attr_md_t ?</title><link>https://devzone.nordicsemi.com/thread/194230?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 07:40:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cebecbd4-a61a-41ae-8cfc-188760b6a6f6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I wouldn&amp;#39;t recommend to use the USER region unless you have a very specific reason to do so. The BLE_GATTS_VLOC_STACK is easier to use, as the softdevice handles all the updates and memory update for you. I haven&amp;#39;t really looked into what you would need to do to use the USER, but it seems like a bit more work handling the lengths and so on. You can check my colleague, run_ar&amp;#39;s, answer here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/30040/ble_gatts_vloc_user-and-volatile-variable"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/30040/ble_gatts_vloc_user-and-volatile-variable&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="jj8431"]I found the BLE_GATTS_FIX_ATTR_LEN_MAX is defined 510 and BLE_GATTS_FIX_ATTR_LEN_MAX is 512, does it mean if the value length is less than this value then we can use the stack memory, if I need more than that then I should use the user memory?[/quote]
&lt;p&gt;&amp;nbsp;That is not really the use case. The maximum length of a characteristic is not dependent on whether it is in the user memory or in the stack. The use case for the user memory area is if you are really restricted on memory, and you can manage the characteristics manually, knowing that you will never exceed the total limit. This is typically not the use case.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My tip to you is to use the BLE_GATTS_VLOCK_STACK, and use the get and set functions to manage them.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What does the 'vloc' mean in ble_gatts_attr_md_t ?</title><link>https://devzone.nordicsemi.com/thread/194179?ContentTypeID=1</link><pubDate>Sat, 22 Jun 2019 15:41:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b4a9ca2-4c0c-4340-90bc-3122f01b6909</guid><dc:creator>jj8431</dc:creator><description>&lt;p&gt;Thank you Paul and Edvin, that explained clearly. Now I have a further question about this, is there a guideline about when to use the stack memory and when to use the user memory? I guess if the value length is large then we should use the user memory? I found the BLE_GATTS_FIX_ATTR_LEN_MAX is defined 510 and BLE_GATTS_FIX_ATTR_LEN_MAX is 512, does it mean if the value length is less than this value then we can use the stack memory, if I need more than that then I should use the user memory? Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What does the 'vloc' mean in ble_gatts_attr_md_t ?</title><link>https://devzone.nordicsemi.com/thread/194021?ContentTypeID=1</link><pubDate>Fri, 21 Jun 2019 08:14:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bef37e8f-8cf4-41b5-b987-1f35edcc5a10</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;As&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/paul"&gt;Paul&lt;/a&gt;&amp;nbsp;says, the vloc is short for value location, and&amp;nbsp;&lt;span&gt;BLE_GATTS_VLOC_STACK means that it is stored in the Bluetooth stack.&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]the attribute value is apparently in the user memory&amp;nbsp; ( encoded_bpm[] ), then why the &amp;#39;vloc&amp;#39; is set to BLE_GATTS_VLOC_STACK ?[/quote]
&lt;p&gt;&amp;nbsp;The value is fetched from the user memory, but it is stored in the SoftDevice (bluetooth stack). So the encoded_bpm is only used to initialize the value. Similarly, the value can be updated by passing a pointer with a new value to the softdevice (the softdevice call depends on whether you use notifications or not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I can recommend &lt;a href="https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-characteristics-a-beginners-tutorial"&gt;this tutorial&lt;/a&gt; if you want an introduction to BLE characteristics. There are some other tutorials on BLE &lt;a href="https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy" rel="noopener noreferrer" target="_blank"&gt;here&lt;/a&gt; as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What does the 'vloc' mean in ble_gatts_attr_md_t ?</title><link>https://devzone.nordicsemi.com/thread/193982?ContentTypeID=1</link><pubDate>Fri, 21 Jun 2019 05:00:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d39664d-a4e9-41e7-b30b-c544d3901892</guid><dc:creator>paul</dc:creator><description>&lt;p&gt;Hi JJ,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; the GATT characteristic table can be stored in two places: on the stack as above or in user memory. I think vloc is short for value location. The stack location is the softdevice stack I believe. Your stuff gets copied in. Stack is better but you can easily run out of space. Vlen is completely different in specifying whether there are any variable length characteristics.&lt;/p&gt;
&lt;p&gt;Cheers Paul&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>