<?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>AN36 question</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/665/an36-question</link><description>this is quote from AN36&amp;gt; 4.2 Set up 
 
 The nRF51822 Evaluation Kit is needed for this application example. However, it is possible to modify the
project to also work with the Development Kit.
4.2.1 Setting up the Evaluation board
Since the nRF51822</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 Oct 2013 13:16:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/665/an36-question" /><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3367?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2013 13:16:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:400a3a60-a550-489c-89c6-9072ed2f49e6</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;The default is for characteristic values to be kept in stack memory, in which case the value is copied from p_value and into a buffer inside the softdevice when initializing the characteristic. In this case, changing the value p_value pointed towards after init have no effect.&lt;/p&gt;
&lt;p&gt;If you want to have variable length, you must set the vlen field in the ble_gatts_attr_md_t struct. When you then use sd_ble_gatts_value_set(), the softdevice will set the correct length in its GATT table, enabling the GATT Client to read the correct length.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3366?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2013 13:11:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:594d3611-1588-4e16-85b2-1e72f91fc98b</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;BTW. If my value is a string of variable length how it this length(&amp;lt;=max_len) is handled? Another characteristic? Other means know by both sides?
Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3365?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2013 13:08:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0354632a-af20-48e6-b9a1-2c5db1c5d387</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;uint32_t sd_ble_gatts_value_set (uint16_t handle, uint16_t offset, uint16_t *const p_len, uint8_t const *const p_value);
Is there any problem to update my app value without this method except that I&amp;#39;m guessing the method provides atomic access. Isn&amp;#39;t this method just memcpy()?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3372?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2013 11:58:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e93615ff-e96b-4c6c-ba16-15f75cbbd417</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;Will certainly do.&lt;/p&gt;
&lt;p&gt;Yet let&amp;#39;s finish already published &amp;quot;unrelated&amp;quot; questions.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3371?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2013 11:54:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:958650c3-c3d0-402f-9b2c-3848f94207ec</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;No, I&amp;#39;d suggest that you create question titles that actually explains the question. In the original case here, that could for example be &amp;quot;What is the ble_app_lbs folder in nAN-36&amp;quot;?&lt;/p&gt;
&lt;p&gt;This question you added here could have been titled &amp;quot;What is written to the BAS with length = 2?&amp;quot;, and so on. If you do, that would make it much easier for us both to understand what you need to know, and to make sure that all the questions are answered. When questions are posted as replies, it often gets a little tricky to keep up with over time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3364?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2013 11:50:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1c483f9-34f8-4b51-838b-31e468a8188a</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;I don&amp;#39;t think I fully understand what you mean. Perhaps we could take a few steps back, to make it clear what you try to achieve.&lt;/p&gt;
&lt;p&gt;Anyway, what I meant was this: The structure which holds the p_value and init_len fields is the ble_gatts_attr_t struct. This struct is then passed to sd_ble_gatts_characteristic_add(), and whatever value is in at the time of this function call is the value that is used. If you try to modify the value of this structure &lt;em&gt;after&lt;/em&gt; having called sd_ble_gatts_characteristic_add(), that will cause no change. This was how I understood your reply here, since you write first &amp;quot;During init&amp;quot; and then &amp;quot;later&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3370?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2013 11:43:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06917d7b-7448-41bf-ab3c-e845f2f1b554</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;I see, copy and paste is always an issue. Sorry my mistake.&lt;/p&gt;
&lt;p&gt;Do youwant me to create a new topic &amp;quot;Yet another AN36 question&amp;quot;? I was   those questions are related.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3363?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2013 11:32:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c627845-be83-42f9-8985-908c4b674118</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;Could you please be a bit more specific about:&amp;quot;There is no use in modifying the attr_char_value after initialization, as it isn&amp;#39;t used then.&amp;quot;?&lt;/p&gt;
&lt;p&gt;If one have a value and a string describing this value how can it be no use in modifying it? I&amp;#39;m confused.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3369?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2013 07:32:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f114f7ca-f0ab-4639-89db-d2e158b65048</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;The code snippet you post here from ble_lbs.c is not correct.&lt;/p&gt;
&lt;p&gt;When you receive a write, you can check the handle of the write to see which attribute was actually written. In the snippet from ble_bas.c, you can see that it waits for a write to the CCCD, and such writes should always be two bytes (CCCD is described in the Core Specification, Volume 3, Part G, section 3.3.3.3).&lt;/p&gt;
&lt;p&gt;However, the snippet you post from ble_lbs.c is intended to catch writes to the value of the LED characteristic (i.e. you should use value_handle, not cccd_handle), which will always be one byte.&lt;/p&gt;
&lt;p&gt;One additional comment: It&amp;#39;s much easier for us to give you answers if you post unrelated questions as separate questions, instead of replies to an old question that have already been answered and resolved. It&amp;#39;s easy that such replies are lost and forgotten, as happened with your reply above.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3362?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2013 07:27:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2917fd9a-f54c-467a-903a-50f50bd4cf5f</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;There is no use in modifying the attr_char_value after initialization, as it isn&amp;#39;t used then. To change the value after init, you have to use sd_ble_gatts_value_set().&lt;/p&gt;
&lt;p&gt;However, the way of setting init_len and max_len seems reasonable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3368?ContentTypeID=1</link><pubDate>Wed, 23 Oct 2013 19:31:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3fd7f03-33ea-4e79-b353-b0ede5212384</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;ble_bas.c&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
        if (
            (p_evt_write-&amp;gt;handle == p_bas-&amp;gt;battery_level_handles.cccd_handle)
            &amp;amp;&amp;amp;
            (p_evt_write-&amp;gt;len == 2)
        )

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;ble_lbs.c&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
        if (  
              (p_evt_write-&amp;gt;handle == p_lbs-&amp;gt;led_char_handles.cccd_handle)
        &amp;amp;&amp;amp; (p_evt_write-&amp;gt;len == 1)
        &amp;amp;&amp;amp; (p_lbs-&amp;gt;led_write_handler != NULL)
        )

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My question is regarding p_evt_write-&amp;gt;len.
If this is new LED state then indeed it is defined as uint8_t and sizeof(uint8_t) is 1. What is being written to bas with length = 2?&lt;/p&gt;
&lt;p&gt;Or my assumptions are totally wrong and please explain what this length is representing.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3361?ContentTypeID=1</link><pubDate>Tue, 22 Oct 2013 23:10:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0a920de-9b61-4989-9370-ec6adbf582de</guid><dc:creator>michurin</dc:creator><description>&lt;p&gt;I&amp;#39;m assuming than when initialization of (ble_gatts_attr_t)attr_char_value.init_len and (ble_gatts_attr_t)attr_char_value.max_len takes place sizeof of the attribute characteristic value should be used: i.e. if my initial value is string&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
#define MAX_LEN 20
char first[] = &amp;quot;hello world&amp;quot;;
char last[] = &amp;quot;good bye cruel world&amp;quot;;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;During init&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
attr_char_value.p_value = first;
attr_char_value.init_len = strlen(first);
attr_char_value.max_len = MAX_LEN;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;later&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
attr_char_value.p_value = last;
attr_char_value.init_len = strlen(last);

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Am I correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AN36 question</title><link>https://devzone.nordicsemi.com/thread/3360?ContentTypeID=1</link><pubDate>Mon, 21 Oct 2013 11:30:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2a5f031-6955-4211-8e73-8df43135c53b</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;The ble_app_lbs folder that is included with the application note is a finished project, with all the code that is explained in the document. If copied to the folder explained in the document, it will work as described, but for learning, I&amp;#39;d strongly recommend you to work through the document step-by-step. When having done so, it might however be useful to compare your solution with the finished one.&lt;/p&gt;
&lt;p&gt;As for the differences between PCA10004/PCA10005 and the PCA10001, this is only the pins used for buttons and LEDs, meaning that it is sufficient to make sure those are correct depending on your board. The default ble_app_template uses the correct pins by default, so just take care not to replace them and use some other button and LED for LEDBUTTON_LED_PIN_NO and LEDBUTTON_BUTTON_PIN_NO.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>