<?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>dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10777/dfu-with-is_srvc_changed_charact_present-set-to-0</link><description>Hi,
I am develop a project with dfu and bond features. I found that in dfu project, IS_SRVC_CHANGED_CHARACT_PRESENT is always set to 1. In my understanding, if set this to 1, each time phone connect to my device, it will read the services, then slow</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Sep 2018 08:01:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10777/dfu-with-is_srvc_changed_charact_present-set-to-0" /><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/148336?ContentTypeID=1</link><pubDate>Wed, 12 Sep 2018 08:01:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:697335eb-bb44-4797-aeaa-f2b24d9f0d53</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I&amp;#39;m glad that you found the issue.&amp;nbsp;&lt;span&gt;NRF_ERROR_NOT_FOUND&amp;nbsp; will return if you don&amp;#39;t have any system characteristic with CCCD (of GAP and GATT services not your application&amp;#39;s service) , when you call&amp;nbsp;sd_ble_gatts_sys_attr_get(). &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In this case you removed service changed characteristic (which has CCCD).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So if you check the return code and ignore&amp;nbsp;NRF_ERROR_NOT_FOUND, you should be fine.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/148115?ContentTypeID=1</link><pubDate>Tue, 11 Sep 2018 02:43:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa3ec004-fc5f-4618-b30f-7366fc1a9552</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Thanks &lt;a href="https://devzone.nordicsemi.com/members/hungbui"&gt;Hung Bui&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;That the reason my bootloader and my application project have the same&lt;span&gt;&amp;nbsp;attribute table.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Finally i found where my code go wrong.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Function for the Application&amp;#39;s S110 SoftDevice event handler.
 *
 * @param[in] p_ble_evt S110 SoftDevice event.
 */
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
    uint32_t                              err_code;
    ble_gatts_rw_authorize_reply_params_t auth_reply;

    switch (p_ble_evt-&amp;gt;header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:

            m_conn_handle    = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
            m_is_advertising = false;
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            {
                uint8_t  sys_attr[128];
                uint16_t sys_attr_len = 128;

                m_direct_adv_cnt = APP_DIRECTED_ADV_TIMEOUT;

                err_code = sd_ble_gatts_sys_attr_get(m_conn_handle,
                                                     sys_attr,
                                                     &amp;amp;sys_attr_len,
                                                     BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
                APP_ERROR_CHECK(err_code);

            }
            if (!m_tear_down_in_progress)
            {
                // The Disconnected event is because of an external event. (Link loss or
                // disconnect triggered by the DFU Controller before the firmware update was
                // complete).
                // Restart advertising so that the DFU Controller can reconnect if possible.
                advertising_start();
            }

            m_conn_handle = BLE_CONN_HANDLE_INVALID;

            break;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In above function, when we get&amp;nbsp;&lt;/span&gt;BLE_GAP_EVT_DISCONNECTED,&lt;/p&gt;
&lt;p&gt;we also call&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;                err_code = sd_ble_gatts_sys_attr_get(m_conn_handle,
                                                     sys_attr,
                                                     &amp;amp;sys_attr_len,
                                                     BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
                APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know why we call that function, but it will return an&amp;nbsp;NRF_ERROR_NOT_FOUND and make system reboot. I think that removing service change characteristic make my Generic Attribute Service empty and make that error. So my current solution is remove&amp;nbsp;APP_ERROR_CHECK(err_code); line and use the original&amp;nbsp;bootloader_settings_save method.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/147982?ContentTypeID=1</link><pubDate>Mon, 10 Sep 2018 10:35:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f99399f3-1f41-4493-9017-d88d09cbd080</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Hoai,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry, the issue happenned when you change&amp;nbsp;&lt;span&gt;IS_SRVC_CHANGED_CHARACT_PRESENT = 0 , right&amp;nbsp; ? Then if you test with the unmodified bootloader, there would be an problem because the phone will cache the attribute table and wouldn&amp;#39;t see the DFU service.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I assume you would need to modify the bootloader to have your application&amp;#39;s service as well ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I would suggest you to create a private case that you can share with us your firmware. You can create a dummy version of your application that only do the buttonless DFU (but has all the service of your application). And the bootloader that you modified to have the services of your application as well.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please mention my name in the case so the system knows to assign to me.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/147750?ContentTypeID=1</link><pubDate>Fri, 07 Sep 2018 09:45:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8076043-050f-49a5-b3b7-bf205bc78995</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Thanks for your suggestion. I have test&amp;nbsp;the unmodified bootloader with nRF-Toolbox and see the same result. If you are working with some kind of bootloader project, can you test and confirm my issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/147713?ContentTypeID=1</link><pubDate>Fri, 07 Sep 2018 07:26:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0834febc-49bb-4460-917c-b68e6b3cb0db</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;If you test with the unmodified bootloader, do you see the same thing ? I would suggest you to create a new case for your issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/147518?ContentTypeID=1</link><pubDate>Thu, 06 Sep 2018 09:03:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64219701-06fe-4617-9f13-d55159053132</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;I use SDK 12.2.0.&lt;/p&gt;
&lt;p&gt;I agree that r&lt;span&gt;emoving&amp;nbsp;pstorage_clear() is not a good idea but when i call&amp;nbsp;pstorage_clear() i not received any&amp;nbsp;&lt;/span&gt;pstorage callback, it make the dfu process timeout. My problem here is i don&amp;#39;t understand why disabling service change characteristic is make that error. When i enable&amp;nbsp;&lt;span&gt;service change characteristic, everything work fine, i can received the&amp;nbsp;pstorage callback, the dfu process completed successfully.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/146755?ContentTypeID=1</link><pubDate>Fri, 31 Aug 2018 12:00:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:563e4b45-418d-4392-80f7-e7083e35d621</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Which SDK are you using ? SDK v11 ?&amp;nbsp;&lt;br /&gt;I don&amp;#39;t see these has anything to do with&amp;nbsp;&lt;span&gt;IS_SRVC_CHANGED_CHARACT_PRESENT.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Removing&amp;nbsp;pstorage_clear() is not a good idea. Without clearing the flash how can you store new data in it ?&amp;nbsp;&lt;br /&gt;What kind of modification you did ? Or only to disable Service changed characteristic?&amp;nbsp;&lt;br /&gt;I would suggest you to continue on the other case.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/146604?ContentTypeID=1</link><pubDate>Fri, 31 Aug 2018 03:52:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f03b03fd-b3c5-41f6-aaf4-deac89f08a3d</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Thanks for your reply Hung Bui,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This is&amp;nbsp;my old code. When dfu process completed, we call&amp;nbsp;bootloader_settings_save method to clear and save the boot loader setting. And we will not received&amp;nbsp;&lt;/span&gt;&lt;span class="s1"&gt;callbacks&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;from&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="s1"&gt;pstorage&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;module, it&amp;#39;s mean we can not save the bootloader_setting and can not jump to application.&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void bootloader_settings_save(bootloader_settings_t * p_settings)
{
    uint32_t err_code = pstorage_clear(&amp;amp;m_bootsettings_handle, sizeof(bootloader_settings_t));
    APP_ERROR_CHECK(err_code);

    err_code = pstorage_store(&amp;amp;m_bootsettings_handle,
                              (uint8_t *)p_settings,
                              sizeof(bootloader_settings_t),
                              0);
    APP_ERROR_CHECK(err_code);
}

void bootloader_dfu_update_process(dfu_update_status_t update_status)
{
    static bootloader_settings_t  settings;
    const bootloader_settings_t * p_bootloader_settings;

    bootloader_util_settings_get(&amp;amp;p_bootloader_settings);

    if (update_status.status_code == DFU_UPDATE_APP_COMPLETE)
    {
        settings.bank_0_crc  = update_status.app_crc;
        settings.bank_0_size = update_status.app_size;
        settings.bank_0      = BANK_VALID_APP;
        settings.bank_1      = BANK_INVALID_APP;

        m_update_status      = BOOTLOADER_SETTINGS_SAVING;
        bootloader_settings_save(&amp;amp;settings);
    }
    
    ....&lt;/pre&gt;&lt;/span&gt;&lt;span class="s1"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;In my new code. I remove the line call pstorage_clear and the dfu process was successful and boot loader can jump in to application.&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void bootloader_settings_save_completed(bootloader_settings_t * p_settings)
{
    uint32_t err_code = pstorage_store(&amp;amp;m_bootsettings_handle,
                              (uint8_t *)p_settings,
                              sizeof(bootloader_settings_t),
                              0);
    APP_ERROR_CHECK(err_code);
}


void bootloader_dfu_update_process(dfu_update_status_t update_status)
{
    static bootloader_settings_t  settings;
    const bootloader_settings_t * p_bootloader_settings;

    bootloader_util_settings_get(&amp;amp;p_bootloader_settings);

    if (update_status.status_code == DFU_UPDATE_APP_COMPLETE)
    {
        settings.bank_0_crc  = update_status.app_crc;
        settings.bank_0_size = update_status.app_size;
        settings.bank_0      = BANK_VALID_APP;
        settings.bank_1      = BANK_INVALID_APP;

        m_update_status      = BOOTLOADER_SETTINGS_SAVING;
        bootloader_settings_save_completed(&amp;amp;settings);
    }
    
    ...&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;So i think the reason for my problem is calling&lt;/span&gt;&lt;/p&gt;
&lt;p class="p1"&gt;pstorage_clear(&amp;amp;m_bootsettings_handle,&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="s1"&gt;sizeof&lt;/span&gt;(&lt;span class="s2"&gt;bootloader_settings_t&lt;/span&gt;));&lt;/p&gt;
&lt;p class="p1"&gt;But i can not understand why calling that method is making error?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/146122?ContentTypeID=1</link><pubDate>Tue, 28 Aug 2018 12:55:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:095fcd72-5fbd-493c-99db-a782105c98fe</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Hoai,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you check what the error it was when calling bootloader_settings_save() ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t see any relation between the service changed characteristic and bootloader setting. Have you made sure the code to send service changed indication has been disabled as well ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/146084?ContentTypeID=1</link><pubDate>Tue, 28 Aug 2018 11:14:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9165d9c-e945-48f6-943d-7d4b44f41a05</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi Hung Bui, my application and my bootloader have the same&amp;nbsp;&lt;span&gt;attribute table (same Service, same Chacteristics). But&amp;nbsp; when i set IS_SRVC_CHANGED_CHARACT_PRESENT to 0, the dfu process can not be done. My question is here&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/36977/can-not-save-boot-loader-setting-bootloader_settings_t-when-disable-is_srvc_changed_charact_present-0-in-bootloader" rel="noopener noreferrer" target="_blank"&gt;Can not save boot loader setting&lt;/a&gt;&amp;nbsp;.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with IS_SRVC_CHANGED_CHARACT_PRESENT set to 0</title><link>https://devzone.nordicsemi.com/thread/40273?ContentTypeID=1</link><pubDate>Thu, 10 Dec 2015 12:40:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f6549f2-5094-4270-bae4-1b45ae4cea62</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Loste,&lt;/p&gt;
&lt;p&gt;We set IS_SRVC_CHANGED_CHARACT_PRESENT to 1 is that when we switch from application to bootloader and vice versa, the attributable may change and we need to send service changed indication to tell the central to redo the service discovery.&lt;/p&gt;
&lt;p&gt;You were correct that it may take longer to discover the service if we have service changed characteristic. But I don&amp;#39;t think it will increase the discovery time significantly. And note that the central don&amp;#39;t do service discovery every time it connects to a bonded device. Only the first time and when receiving service changed indication.&lt;/p&gt;
&lt;p&gt;If your application and the bootloader has the same attribute table, it&amp;#39;s true that you can set
IS_SRVC_CHANGED_CHARACT_PRESENT to 0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>