<?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>unable to enable Notifications using sd_ble_gattc_write (SDK 15.2)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40602/unable-to-enable-notifications-using-sd_ble_gattc_write-sdk-15-2</link><description>Hi there, 
 I am migrating my central project from SDK 13 to SDK 15.2, almost all the project is already migrated, but I am having an issue with sd_ble_gattc_write () it is not enabling the notifications when I start a connection and skip ble_db_discovery_start</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Nov 2018 22:31:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40602/unable-to-enable-notifications-using-sd_ble_gattc_write-sdk-15-2" /><item><title>RE: unable to enable Notifications using sd_ble_gattc_write (SDK 15.2)</title><link>https://devzone.nordicsemi.com/thread/158513?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 22:31:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59698b26-d87e-45a6-a151-b767a30c7cbc</guid><dc:creator>Arepa</dc:creator><description>&lt;p&gt;Finally, I solved my issue!&lt;/p&gt;
&lt;p&gt;I was ignoring on&amp;nbsp;on_hvx() the&amp;nbsp;peer_lbs_db which is generated&amp;nbsp;and compared with the one when a discovery service is performed, now both handles match&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error NRF_ERROR_BUSY when calling sd_ble_gattc_write (SDK 15.2)</title><link>https://devzone.nordicsemi.com/thread/158400?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 12:36:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c73b3e0-fe53-4a9b-9cc9-68c8cbcfed16</guid><dc:creator>Arepa</dc:creator><description>&lt;p&gt;Hi Andreas,&lt;/p&gt;
&lt;p&gt;I want to skip the discovey service for two reasons:&lt;/p&gt;
&lt;p&gt;1) I am going to connect to only one Peripheral wheres I know the handle for each service and I am adding it manually to the Central&lt;/p&gt;
&lt;p&gt;2) I want to save battery, each time a discovery service is performed it takes 140-200ms + connection time, skipping it my connections usually takes 40-60ms It makes a big different for a long term run.&lt;/p&gt;
&lt;p&gt;On my setup I have the sensors on the Central and it is my sleepy device, I did it configuration because it fits better to my application&lt;/p&gt;
&lt;p&gt;In the example above I am adding the handle(0), service handle(0x13) and CCCD handle(0x11) manually to the central code,&amp;nbsp; but it only enables the notifications when peforms a discovery service still the central is using the handles I added manually that does not makes sense for me&lt;/p&gt;
&lt;p&gt;I dont get why I cant do it using the SDK 15.2 if I was doing it since a while using the SDK13&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error NRF_ERROR_BUSY when calling sd_ble_gattc_write (SDK 15.2)</title><link>https://devzone.nordicsemi.com/thread/158378?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 11:40:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4e15c89-0d26-4d1c-90aa-45d926990886</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m a bit confused at why you would like to skip the discovery service?&lt;br /&gt;&lt;br /&gt;If you do not do a discovery service the CCCD will not be enabled, because the central does not know what the different services has as handles.&lt;br /&gt;&lt;br /&gt;For example:&lt;br /&gt;&lt;br /&gt;If you have a central (C1) and a peripheral (P1), and a temperature sensor (T1)&amp;nbsp; is connected to the peripheral (P1)&lt;br /&gt;&lt;br /&gt;If you do not do a discovery service and only connect to the peripheral (P1) from the central (C1), then the central (C1) is only connected. If the temperature sensor (T1) registers a new temperature to a service at the peripheral (P1) the peripheral will not notify the central (C1) because:&lt;br /&gt;&lt;br /&gt;1) The central does not know what different services that are available at the peripheral (P1)&lt;br /&gt;&lt;br /&gt;2) It does not know the service handle which relates to the temperatur sensor (T1) .&lt;br /&gt;&lt;br /&gt;3) The central (C1) has not made the peripheral (P1) aware that this particular service should do a notify when it has a change in value&lt;br /&gt;&lt;br /&gt;Hope this helps.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Best regards.&lt;br /&gt;&lt;br /&gt;- Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error NRF_ERROR_BUSY when calling sd_ble_gattc_write (SDK 15.2)</title><link>https://devzone.nordicsemi.com/thread/158068?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 20:05:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acb071d6-4eb8-45b4-ae4e-3e92e674c400</guid><dc:creator>Arepa</dc:creator><description>&lt;p&gt;Hi @AndreasF thanks for the suggestions, I double checked my CCCD set up using the custom BLE service and it seems good. l added the code you suggested above, at the moment I am using the BLE blinky&amp;nbsp;project Peripheral and Client without major modification just skipping the discovery service, but my central is not enabling the notification on the peripheral side when I am using&amp;nbsp;&lt;strong&gt;sd_ble_gattc_write, &lt;/strong&gt;it only works after performed&amp;nbsp;a discovery service, It concerns&amp;nbsp;me because I have been using the same routine almost 2 years with no issue with the SDK13, and it is not working when I am running the SDK15.2&lt;/p&gt;
&lt;p&gt;note: I am using the RTT output with J-Link RTT Viewer instead of Putty or any UART terminal&lt;/p&gt;
&lt;p&gt;I have attached the project I am using blinky peripheral and central (with some modifications),&lt;/p&gt;
&lt;p&gt;Inside the central code you can find&amp;nbsp;Skip_discovery flag and&amp;nbsp;Enable_CCCD_write() I added to enable the notification to my peripheral,&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_blinky_5F00_c_5F00_Original_5F00_skiping_5F00_discovery.rar"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_blinky_5F00_c_5F00_Original_5F00_skiping_5F00_discovery.rar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_blinky_5F00_original.rar"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_blinky_5F00_original.rar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;#update:&lt;/p&gt;
&lt;p&gt;I also tried adding manually the values for &lt;strong&gt;conn handle&lt;/strong&gt; and &lt;strong&gt;button_cccd_handle&lt;/strong&gt; inside&amp;nbsp;&lt;strong&gt;ble_lbs_c_button_notif_enable()&lt;/strong&gt; commenting out the verification&amp;nbsp;if the value is null or invalid, it works fine only if the client performs a discovery service otherwise it does not enable the &lt;strong&gt;CCCD&lt;/strong&gt; (it does not return any error)&lt;/p&gt;
&lt;p&gt;The curious&amp;nbsp;about this issue is that when I am not performing a discovery service in the client, I am also receiving &lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;p_evt_write-&amp;gt;data[0],p_evt_write-&amp;gt;data[1] =&amp;nbsp;&lt;/strong&gt;0x01 0x00 on the peripheral inside &lt;strong&gt;on_write()&lt;/strong&gt; event, but the notification is not being enabled&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error NRF_ERROR_BUSY when calling sd_ble_gattc_write (SDK 15.2)</title><link>https://devzone.nordicsemi.com/thread/157881?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 08:33:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5531fc51-bc3e-4ddc-9256-b39c8f32c440</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi Arepa.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]so, the first thing I do in my central when it has&amp;nbsp;established a connection with a peripheral is enable the CCCD using&amp;nbsp;&lt;strong&gt;sd_ble_gattc_write(),&lt;/strong&gt; I do it to avoid extra consumption discovering every time the same attribute table for the same Peripheral that already known&amp;nbsp;[/quote]
&lt;p&gt;Could you try this code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case BLE_GAP_EVT_CONNECTED:
		{
			NRF_LOG_INFO(&amp;quot;Connected\r\n&amp;quot;);
			
			(void) sd_ble_gap_scan_stop();

			uint32_t err_code;
			
			ble_gattc_write_params_t write_params;
		    memset(&amp;amp;write_params, 0, sizeof(write_params));
		    
			uint8_t	EnableNotification[2] = {LSB_16(0x01), MSB_16(0x00)};

			write_params.write_op = BLE_GATT_OP_WRITE_REQ;						
			write_params.handle   = 0x0015;  			
			write_params.offset   = 0;															
			write_params.len      = 2;																
			write_params.p_value  = EnableNotification;
			write_params.flags    = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE;
			
			err_code = sd_ble_gattc_write(0x0000 , &amp;amp;write_params);
			APP_ERROR_CHECK(err_code);

            if (err_code != NRF_SUCCESS)
            {
                NRF_LOG_INFO(&amp;quot;wrong characteristic UUID or the CCCD descriptor has not been found yet\r\n&amp;quot;);
            }


			bsp_board_led_on(LED_CONNECTED);
		} break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve looked at the function&amp;nbsp;&lt;strong&gt;static void cccd_set(nrf_cli_t const * p_cli, uint16_t cccd, char * p_addr, char * p_uuid)&lt;/strong&gt;, in &lt;strong&gt;nRF5_SDK_15.2.0_9412b96\examples\ble_central_and_peripheral\experimental\ble_app_interactive\cli_m.c&lt;/strong&gt;, which is used to enable CCCD.&lt;/p&gt;
&lt;p&gt;There is a good tutorial on &lt;a href="https://github.com/bjornspockeli/custom_ble_service_example"&gt;custom BLE service&lt;/a&gt; which also sets up CCCD.&lt;/p&gt;
&lt;p&gt;- Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error NRF_ERROR_BUSY when calling sd_ble_gattc_write (SDK 15.2)</title><link>https://devzone.nordicsemi.com/thread/157873?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 07:59:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ba33164-571c-4b14-8141-6a2e48359ccd</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi Arepa.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]so, the first thing I do in my central when it has&amp;nbsp;established a connection with a peripheral is enable the CCCD using&amp;nbsp;&lt;strong&gt;sd_ble_gattc_write(),&lt;/strong&gt; I do it to avoid extra consumption discovering every time the same attribute table for the same Peripheral that already known&amp;nbsp;[/quote]
&lt;p&gt;&amp;nbsp;You could take a look at &lt;strong&gt;nRF5_SDK_15.2.0_9412b96\examples\ble_central_and_peripheral\experimental\ble_app_interactive\cli_m.c &lt;/strong&gt;and the function &lt;strong&gt;static void cccd_set(nrf_cli_t const * p_cli, uint16_t cccd, char * p_addr, char * p_uuid)&lt;/strong&gt;, and make sure that you set up &lt;strong&gt;CCCD&lt;/strong&gt; correct.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Function for setting the CCCD Descriptor value.
 *
 * @param[in] p_cli          Instance of the command line.
 * @param[in] cccd           New CCCD value.
 * @param[in] addr           Device address in string format.
 * @param[in] uuid           Characteristic UUID in string format.
 */
static void cccd_set(nrf_cli_t const * p_cli, uint16_t cccd, char * p_addr, char * p_uuid)
{
    uint16_t                 conn_handle;
    uint16_t                 desc_handle;
    ret_code_t               err_code;
    ble_gattc_write_params_t write_params;

    // Search for connection handle.
    conn_handle = addr_string_to_conn_handle(p_addr);

    if(!conn_handle_is_valid(conn_handle, p_cli))
    {
        return;
    }

    memset(&amp;amp;write_params, 0, sizeof(write_params));

    desc_handle = cccd_descriptors_handle_get(p_uuid);

    if (desc_handle == BLE_GATT_HANDLE_INVALID)
    {
        nrf_cli_fprintf(p_cli,
                        NRF_CLI_ERROR,
                        &amp;quot;Wrong characteristic UUID or the CCCD descriptor has not been found yet\r\n&amp;quot;);
        return;
    }

    uint16_t cccd_val    = cccd;
    uint8_t  data_buf[2] = {LSB_16(cccd_val), MSB_16(cccd_val)};
    uint8_t  data_len    = sizeof(data_buf);

    write_params.write_op = BLE_GATT_OP_WRITE_REQ;
    write_params.handle   = desc_handle;
    write_params.len      = data_len;
    write_params.p_value  = data_buf;
    write_params.offset   = 0;
    write_params.flags    = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE;

    // Set CCCD descriptor value.
    err_code = sd_ble_gattc_write(conn_handle, &amp;amp;write_params);

    if (err_code != NRF_SUCCESS)
    {
        nrf_cli_fprintf(p_cli,
                        NRF_CLI_ERROR,
                        &amp;quot;wrong characteristic UUID or the CCCD descriptor has not been found yet\r\n&amp;quot;);
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;- Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>