<?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>Create BLE characteristic with notifications active on queued write service</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/36886/create-ble-characteristic-with-notifications-active-on-queued-write-service</link><description>I&amp;#39;m developing an application to communicate with a smartphone. I have the need of writing characteristics with the size bigger than the negotiated MTU, so I&amp;#39;m exploring Queued write example. So far, I&amp;#39;m able to write to the characteristic, however, I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 17 Aug 2018 09:05:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/36886/create-ble-characteristic-with-notifications-active-on-queued-write-service" /><item><title>RE: Create BLE characteristic with notifications active on queued write service</title><link>https://devzone.nordicsemi.com/thread/144661?ContentTypeID=1</link><pubDate>Fri, 17 Aug 2018 09:05:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1dbd5e99-d890-4259-be08-b2e25734ac25</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;The only property I see in the attached code from August 2nd is&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; add_char_params.char_props.write&amp;nbsp; &amp;nbsp;= true;&lt;/p&gt;
&lt;p&gt;However; I do&amp;nbsp;got&amp;nbsp;the same result and you need to add an additional line setting the cccd write access, i.e.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;add_char_params.char_props.notify= true;&lt;br /&gt; add_char_params.char_props.read = true;&lt;br /&gt; add_char_params.cccd_write_access= true;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Create BLE characteristic with notifications active on queued write service</title><link>https://devzone.nordicsemi.com/thread/144644?ContentTypeID=1</link><pubDate>Fri, 17 Aug 2018 08:24:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:981829f8-12a8-4e41-a33a-a2089cf11e58</guid><dc:creator>naf18</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi&amp;nbsp;&lt;/span&gt;&lt;span&gt;Bj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If you take a look at my code at the beginning&amp;nbsp;of this thread, that&amp;#39;s exactly what I have done, however, after that change the function&amp;nbsp;characteristic_add() returned&amp;nbsp;NRF_INVALID_PARAM.&amp;nbsp;Could I be forgetting something?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Nuno Ferreira&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Create BLE characteristic with notifications active on queued write service</title><link>https://devzone.nordicsemi.com/thread/144640?ContentTypeID=1</link><pubDate>Fri, 17 Aug 2018 08:14:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b5851fd-474c-4746-af65-b0a049824095</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Nuno.&lt;/p&gt;
&lt;p&gt;I took a look at the&amp;nbsp;characteristic_add() function that is used in the&amp;nbsp;nrf_ble_qwrs_init() function. The&amp;nbsp;characteristic_add() function is a utility function that sets a lot of the parameters automatically, as opposed to setting them manually as I do in my tutorial. If you want the QWRS characteristic to have Read and Notify properties in addition to Write, then I think you simply need to add&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;add_char_params.char_props.notify= true;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:inherit;"&gt;add_char_params.char_props.read = true;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;when the ble_add_char_params_t struct is populated. The&amp;nbsp;characteristic_add() function will examine the properties and then set the appropriate permissions for the notification property, i.e.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;memset(&amp;amp;char_md, 0, sizeof(ble_gatts_char_md_t));
if ((p_char_props-&amp;gt;char_props.notify == 1)||(p_char_props-&amp;gt;char_props.indicate == 1))
{

    memset(&amp;amp;cccd_md, 0, sizeof(cccd_md));
    set_security_req(p_char_props-&amp;gt;cccd_write_access, &amp;amp;cccd_md.write_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.read_perm);

    cccd_md.vloc       = BLE_GATTS_VLOC_STACK;

    char_md.p_cccd_md  = &amp;amp;cccd_md;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Create BLE characteristic with notifications active on queued write service</title><link>https://devzone.nordicsemi.com/thread/144586?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2018 15:20:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f553361-2107-4f4a-a4b9-8a8326b6d28d</guid><dc:creator>naf18</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi&amp;nbsp;&lt;/span&gt;&lt;span&gt;Bj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I will repeat the tests and send you a log of the nRF&amp;nbsp;connect.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, I don&amp;#39;t understand yet why I can&amp;#39;t add a characteristic with those permissions using my code. in your first comment you told &amp;quot;I think that you&amp;#39;re missing the pointer to the ble_gatts_attr_md_t cccd_md struct in the charachteristic metadata( char_md).&amp;quot;. Where did I forgot the pointer? What do I need to change to put it working?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Create BLE characteristic with notifications active on queued write service</title><link>https://devzone.nordicsemi.com/thread/144478?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2018 09:38:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c35316b-01c3-4abb-8e80-a6d3d04cbe7f</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Could you be a bit more specific than &amp;quot;when I tried to read something it failed and I was again unable to use that characteristic&amp;quot;? Did you get en error message with an error code when you tried to write to it in nRF connect?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Create BLE characteristic with notifications active on queued write service</title><link>https://devzone.nordicsemi.com/thread/144217?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 14:34:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a32ca14b-5882-4f03-828e-aa547257da76</guid><dc:creator>naf18</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Bj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for your answer. I was trying that example and I was able to create a characteristic&amp;nbsp;with reading and notifications permissions. It&amp;nbsp;appeared at nordic&amp;nbsp;nrf&amp;nbsp;connect application, but when I tried to read something it failed and I was again unable to use that characteristic.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Nuno Ferreira&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Create BLE characteristic with notifications active on queued write service</title><link>https://devzone.nordicsemi.com/thread/143583?ContentTypeID=1</link><pubDate>Thu, 09 Aug 2018 13:21:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78b77898-0552-43ed-a2aa-d1da932db4fd</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Nuno,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I apologize for the late reply.&lt;/p&gt;
&lt;p&gt;I suggest that you take a look at&amp;nbsp;custom_value_char_add() in ble_cus.c in the GitHub repo link below.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/bjornspockeli/custom_ble_service_example/blob/master/ble_cus.c"&gt;https://github.com/bjornspockeli/custom_ble_service_example/blob/master/ble_cus.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It adds a characteristic that has write/read/notification properties.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Bjørn&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Create BLE characteristic with notifications active on queued write service</title><link>https://devzone.nordicsemi.com/thread/142689?ContentTypeID=1</link><pubDate>Thu, 02 Aug 2018 16:40:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b28a2591-53be-466d-87e7-3cd017ff3c80</guid><dc:creator>naf18</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/bjorn_2d00_spockeli"&gt;bjorn-spockeli&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;thanks for your answer.&lt;/p&gt;
&lt;p&gt;Below you can check the functions I&amp;#39;m running to configure this service:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;retval_t initQWRSService()
{
    uint32_t          err_code = 0;
    nrf_ble_qwr_init_t  qwr_init;
    nrf_ble_qwrs_init_t qwrs_init;

    // Initialize Queued Write Module
    qwr_init.mem_buffer.len   = MEM_BUFF_SIZE;
    qwr_init.mem_buffer.p_mem = umdc_qwrs_service.m_buffer;
    qwr_init.error_handler    = NULL;
    qwr_init.callback         = queuedWriteHandlerWrapper;

    err_code += nrf_ble_qwr_init(&amp;amp;umdc_qwrs_service.m_qwr, &amp;amp;qwr_init);

    //initialize the Queued Writes Example Service
    memset(&amp;amp;qwrs_init, 0, sizeof(qwrs_init));

    qwrs_init.evt_handler   = queuedWriteServiceEvtHandlerWrapper;
    qwrs_init.error_handler = NULL;
    qwrs_init.p_qwr_ctx     = &amp;amp;umdc_qwrs_service.m_qwr;

    err_code += nrfBleQWRSInit(&amp;amp;qwrs_init, &amp;amp;umdc_qwrs_service.m_qwrs);

    if (0 == err_code) {
        return SUCCESS;
    }

    return ERROR;
}


retval_t nrfBleQWRSInit(nrf_ble_qwrs_init_t *p_qwrs_init, nrf_ble_qwrs_t *p_qwrs)
{
    ret_code_t    err_code = 0;
    ble_uuid_t    ble_uuid;

    // Initialize service structure.
    p_qwrs-&amp;gt;evt_handler   = p_qwrs_init-&amp;gt;evt_handler;
    p_qwrs-&amp;gt;error_handler = p_qwrs_init-&amp;gt;error_handler;
    p_qwrs-&amp;gt;conn_handle   = BLE_CONN_HANDLE_INVALID;

    // Add service.
    ble_uuid128_t base_uuid = QWRS_BASE_UUID;
    err_code += sd_ble_uuid_vs_add(&amp;amp;base_uuid, &amp;amp;p_qwrs-&amp;gt;uuid_type);

    ble_uuid.type = p_qwrs-&amp;gt;uuid_type;
    ble_uuid.uuid = BLE_UUID_QWRS_SERVICE;

    err_code += sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                        &amp;amp;ble_uuid,
                                        &amp;amp;p_qwrs-&amp;gt;service_handle);

    //Add Long characteristic
    ble_add_char_params_t add_char_params;

    memset(&amp;amp;add_char_params, 0, sizeof(add_char_params));
    add_char_params.uuid               = BLE_UUID_QWRS_LONG_CHARACTERISTIC;
    add_char_params.max_len            = BLE_QWRS_MAX_LONG_CHAR_LEN;
    add_char_params.init_len           = 0;
    add_char_params.char_props.write   = true;
    add_char_params.write_access       = SEC_OPEN;
    add_char_params.is_defered_write   = true;

    err_code += characteristic_add(p_qwrs-&amp;gt;service_handle,
                                  &amp;amp;add_char_params,
                                  &amp;amp;p_qwrs-&amp;gt;long_charact_handles);

    if (p_qwrs_init-&amp;gt;p_qwr_ctx != NULL)
    {
        err_code += nrf_ble_qwr_attr_register(p_qwrs_init-&amp;gt;p_qwr_ctx,
                                             p_qwrs-&amp;gt;long_charact_handles.value_handle);
    }

    if (0 == err_code) {
        return SUCCESS;
    }

    return ERROR;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The next step I need is to add a characteristic with read and notifications properties active. Can you tell what I need to do?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Nuno Ferreira&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Create BLE characteristic with notifications active on queued write service</title><link>https://devzone.nordicsemi.com/thread/142673?ContentTypeID=1</link><pubDate>Thu, 02 Aug 2018 15:39:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc3ddd83-a93b-4343-b385-729010617d62</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;HI Naf18,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;could you post the entire .c file where you&amp;#39;re adding the characteristics? I think that you&amp;#39;re missing the pointer to the ble_gatts_attr_md_t cccd_md struct in the charachteristic metadata( char_md).&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>