<?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>nRF52832: How to add write protected characteristic by KEY</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42707/nrf52832-how-to-add-write-protected-characteristic-by-key</link><description>I am working on SDK-15.2, nRF52832 Dev board. My question is how to add write protected characteristic by KEY? Mean when we want to write something from peer device (smartphone) on &amp;quot;write&amp;quot; characteristic it should ask to enter KEY. 
 is there any example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 Jan 2019 10:58:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42707/nrf52832-how-to-add-write-protected-characteristic-by-key" /><item><title>RE: nRF52832: How to add write protected characteristic by KEY</title><link>https://devzone.nordicsemi.com/thread/167608?ContentTypeID=1</link><pubDate>Thu, 24 Jan 2019 10:58:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5effa0d-22d8-45a9-bf68-bfeccc29cc10</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I have attached a modified version of the ble app uart example, where I have restricted the write access for the RX Characteristics by demanding the passkey to be typed in. I have used the approach as described in my previous answer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I also changed one line of the ble_nus.c file (which you must do yourself, since the uploded example only contains the project folder)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t ble_nus_init(ble_nus_t * p_nus, ble_nus_init_t const * p_nus_init)
{
    .
    .
    .
    add_char_params.read_access  = SEC_OPEN;
    // In the line below I changed the write access to JUST WORKS 
    add_char_params.write_access = SEC_JUST_WORKS;//SEC_OPEN;

    err_code = characteristic_add(p_nus-&amp;gt;service_handle, &amp;amp;add_char_params, &amp;amp;p_nus-&amp;gt;rx_handles);
    .
    .
    &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Be aware that this file is used by other examples in the SDK, and the change will cause undesirable behaviour for those examples.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-e00cdefc12d7437481018689aeeb6997/ble_5F00_app_5F00_uart_5F00_write_5F00_prot_5F00_char.rar"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_uart_5F00_write_5F00_prot_5F00_char.rar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832: How to add write protected characteristic by KEY</title><link>https://devzone.nordicsemi.com/thread/166705?ContentTypeID=1</link><pubDate>Mon, 21 Jan 2019 06:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f58b75fb-c4de-41a3-a508-36d3cfda9795</guid><dc:creator>Rajneesh</dc:creator><description>&lt;p&gt;Thanks Simon. Could you please give me more details and also code snippets which can ask to enter key before writing any value in characteristic?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832: How to add write protected characteristic by KEY</title><link>https://devzone.nordicsemi.com/thread/166685?ContentTypeID=1</link><pubDate>Sun, 20 Jan 2019 18:46:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ccdd2315-042c-489e-bcf9-96749724fd3c</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;First you need to secure the link, this can be done using the &lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-2-0/lib_peer_manager"&gt;Peer Manager&lt;/a&gt;. Then you can set the&amp;nbsp;Security requirement for writing to the characteristic value through the field&amp;nbsp;&lt;em&gt;ble_add_char_params_t.write_access.&amp;nbsp;&lt;/em&gt;For example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ble_add_char_params_t add_char_params;
.
.
.
add_char_params.write_access = SEC_MITM;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you secure the link using static passkeys, you need to enter a 6 digit key (20 bits) in order to pair/bond the devices, and access the protected characteristics. Another choice for an even more secure protection is OOB, where an 128 bit key is transferred between the devices, using e.g. NFC.&lt;/p&gt;
&lt;p&gt;If anything is unclear, or do you want me to go more into details about anything, please tell me.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>