<?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>For a custom BLE service, write operation doesn&amp;#39;t seem to work</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52303/for-a-custom-ble-service-write-operation-doesn-t-seem-to-work</link><description>Hello All, 
 I created a BLE service (relay service) to be able to turn ON or OFF a relay switch. The relay switch hardware is attached to Adafruit Bluefruit Feather (nRF52832 peripheral) at one of the GPIO pins. All seems fine there because I can discover</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 19 Sep 2019 11:25:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52303/for-a-custom-ble-service-write-operation-doesn-t-seem-to-work" /><item><title>RE: For a custom BLE service, write operation doesn't seem to work</title><link>https://devzone.nordicsemi.com/thread/210686?ContentTypeID=1</link><pubDate>Thu, 19 Sep 2019 11:25:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f1a4289-e6ec-412a-a861-8c997216e2ba</guid><dc:creator>cbd</dc:creator><description>&lt;p&gt;Okay. I was just about to have a closer look.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m glad that you&amp;#39;ve sorted it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: For a custom BLE service, write operation doesn't seem to work</title><link>https://devzone.nordicsemi.com/thread/210530?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 18:50:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:509cd291-4020-4571-941a-2ca6968afed8</guid><dc:creator>tinytrex</dc:creator><description>&lt;p&gt;Never-mind. This worked after changing the permissions of the relay service characteristics in the peripheral.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: For a custom BLE service, write operation doesn't seem to work</title><link>https://devzone.nordicsemi.com/thread/210464?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 14:13:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e3c5315-7781-4ca8-be38-0beb4b4bba43</guid><dc:creator>tinytrex</dc:creator><description>&lt;p&gt;Yes. Notifications are enabled on both the central and peripheral. But notifications itself aren&amp;#39;t the issue. It&amp;#39;s the &amp;#39;write&amp;#39; that is not getting to the peripheral.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: For a custom BLE service, write operation doesn't seem to work</title><link>https://devzone.nordicsemi.com/thread/210451?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 13:53:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:551ffaf4-5654-4815-a173-ed7b04c90312</guid><dc:creator>cbd</dc:creator><description>&lt;p&gt;That&amp;#39;s a lot of code to check through.&lt;/p&gt;
&lt;p&gt;Are you relying on a notification trigger in your peripheral to detect when the characteristic has been updated or are you polling it?&lt;/p&gt;
&lt;p&gt;This is the code from my current nRF52840 based project for updating and triggering a notification, I&amp;#39;ve only included the important bits:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    ble_gatts_hvx_params_t params;

    memset(&amp;amp;params, 0, sizeof(params));
    params.type = BLE_GATT_HVX_NOTIFICATION;
    params.p_len = &amp;amp;len;

    /* update and notify for the characteristic */
    params.handle = m_LiveDriveService.lds_char_result_handles.value_handle;
    params.p_data = m_scratch_buffer;

    err_code = sd_ble_gatts_hvx(m_LiveDriveService.conn_handle, &amp;amp;params);
    if (NRF_SUCCESS != err_code)
    { /* notifications may not be enabled, attempt to update data */
        ble_gatts_value_t valueData;
        valueData.len = len;
        valueData.offset = 0;
        valueData.p_value = m_scratch_buffer;
        NRF_LOG_HEXDUMP_DEBUG(m_scratch_buffer, len);
        err_code = sd_ble_gatts_value_set(m_LiveDriveService.conn_handle,
                                          m_LiveDriveService.lds_char_result_handles.value_handle,
                                          &amp;amp;valueData);
        if (NRF_SUCCESS != err_code)
        {
            return err_code;
        }
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Oh I forgot to mention both devices central and peripheral must enable notification on any characteristic that they wish to &lt;strong&gt;receive&lt;/strong&gt; a notification even for.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: For a custom BLE service, write operation doesn't seem to work</title><link>https://devzone.nordicsemi.com/thread/210443?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 13:44:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b728d745-ac3f-4891-ac8d-3ca6073375f7</guid><dc:creator>tinytrex</dc:creator><description>&lt;p&gt;Please note that the .write_op of the write_params is&amp;nbsp;BLE_GATT_OP_WRITE_REQ and not&amp;nbsp;BLE_GATT_OP_PREP_WRITE_REQ as mentioned in the relay_client.c source. I modified it just to test and forgot to revert before posting this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>