<?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>RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20326/rtc-stops-after-disconnet-from-android</link><description>Hi,
I am using nrf51822 chip. I am using RTC to generate irq with CC. Everything works fine for IOS and old Android version. New android version makes 2 things when I disconnect: 
 
 
 change register of CC[0] value so I changed to generate IRQ from</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Mar 2017 14:39:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20326/rtc-stops-after-disconnet-from-android" /><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79203?ContentTypeID=1</link><pubDate>Mon, 20 Mar 2017 14:39:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3932050-fe38-4707-80f6-0df7755c419a</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Marcin,&lt;/p&gt;
&lt;p&gt;I made an example with RTC1 and SDK v10 S110v8.0
You can see RTC1 CC[0] is printed out continuously. Could you please check, you can use make to compile, but I attached also the .hex I compiled.&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_uart_2D00_RTC.zip"&gt;ble_app_uart-RTC.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79197?ContentTypeID=1</link><pubDate>Fri, 17 Mar 2017 10:45:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0636eb5-c84e-494c-ba67-6b4c4751c0ae</guid><dc:creator>Marcin</dc:creator><description>&lt;p&gt;It has all the time 0 value, tell me how can I wake up module from power manage every 1 min,2 min and so on? NRF_RTC1-&amp;gt;COUNTER is also 0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79202?ContentTypeID=1</link><pubDate>Thu, 16 Mar 2017 15:12:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e7dcf03-d94d-40f8-8e95-bfd83ea18d68</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Marcin,&lt;/p&gt;
&lt;p&gt;Sorry I forgot to point out. In most of our example we already use RTC1 in our app timer library. In ble_app_uart we used if for bsp to handle the button and LED and the connection parameter update.&lt;/p&gt;
&lt;p&gt;If you print out RTC1-&amp;gt;CC[0] in the main loop you may be able to check if the issue also happens on those example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79200?ContentTypeID=1</link><pubDate>Wed, 15 Mar 2017 14:49:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32980ee1-c196-4706-860d-e516abba62aa</guid><dc:creator>Marcin</dc:creator><description>&lt;p&gt;I added now this event above and it has same behaviour, but I am changing the ble_app_uart example now, so I should have soon the result.
I try to modify the ble_app_uart example, but when I add #include nrf_drv_rtc.h I am getting error that multiple definition of &lt;code&gt;RTC1_IRQHandler&amp;#39; also when I add the #include nrf_drv_clock.h I am getting that error: make[1]: *** Brak reguł do zrobienia obiektu&lt;/code&gt;_build/nrf_drv_clock.o&amp;#39;, wymaganego przez `nrf51422_xxac_s110&amp;#39;. Stop.&lt;/p&gt;
&lt;p&gt;Maybe you have an example when is used softdevice 110 where device getting IRQ by comparing CC and wake up from power_manage?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79199?ContentTypeID=1</link><pubDate>Wed, 15 Mar 2017 13:10:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67d183c1-cb75-470e-966b-53ce6f2147f2</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Marcin,
Sorry I tried to compile your project and make.exe erased BLE_NEW_mod.hex file.&lt;/p&gt;
&lt;p&gt;I tried again with the file from .zip you provided, and can see the log printing out on the screen.
Unfortunately, I don&amp;#39;t have an S7 edge for testing ( I was testing with S6) and couldn&amp;#39;t reproduce the issue.&lt;/p&gt;
&lt;p&gt;Please let me know your result when you test with the example we provided.&lt;/p&gt;
&lt;p&gt;Looking at your code I noticed that you haven&amp;#39;t initialize the CCCD value of the UART_TX characteristic.  You should handle it in BLE_GATTS_EVT_SYS_ATTR_MISSING event. Here is what we do in the uart example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;case BLE_GATTS_EVT_SYS_ATTR_MISSING:
    // No system attributes have been stored.
    err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
    APP_ERROR_CHECK(err_code);
    break; // BLE_GATTS_EVT_SYS_ATTR_MISSING
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79198?ContentTypeID=1</link><pubDate>Wed, 15 Mar 2017 07:14:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a496d402-2853-4bb9-b83b-a724705a1e32</guid><dc:creator>Marcin</dc:creator><description>&lt;p&gt;Please try to flash BLE_NEW_mod.hex from Release folder. Also I will try today to add rtc to your example. I am using sdk 10. Which example would be the best for that test in your opinion?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79196?ContentTypeID=1</link><pubDate>Tue, 14 Mar 2017 15:40:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d113d099-529b-4f2e-aea6-31e307002b86</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Marcin,&lt;/p&gt;
&lt;p&gt;I couldn&amp;#39;t build your project with gcc with the Makefile provided in the \Release folder.
I tried to flash the BLE_NEW.hex and BLE_S110_TEST_MM.hex and S110v8.0 on our DK but it didn&amp;#39;t seem to advertise.&lt;/p&gt;
&lt;p&gt;I strongly suggest you to use any of our example in the SDK and add the RTC code to test. This way we can narrow down if the issue is related to your code or not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79195?ContentTypeID=1</link><pubDate>Tue, 14 Mar 2017 09:49:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25787f3b-8aa4-4c68-a157-724fdefea7c3</guid><dc:creator>Marcin</dc:creator><description>&lt;p&gt;I put my code under the terminal logs if you can just check it, this is eclipse project. I`m sure that RTC 1 is used just for this one task. I used NRF uart on all phones but also the application wrote by myself in xamarin, I am getting the same result. This is not the application fault beacuse this is just the disconnect event. I know that you see that CC has changed at connect, but it is not true. This logs I send by uart and this is sending when event of disconnect is done. CC is changing when I click disconnect at application on my phone and then it takes time to send infromation about disconnect.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79194?ContentTypeID=1</link><pubDate>Mon, 13 Mar 2017 15:59:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5878096-73fe-46a3-b305-5b30ba0e8202</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Marcin: It would be easier if you have a Keil project so I can test here.&lt;/p&gt;
&lt;p&gt;Are you sure there is nothing else in the application that can affect RTC?
Could you try to modify the ble_app_uart to show the issue ?&lt;/p&gt;
&lt;p&gt;You can also try to sniff a sniffer trace and compare between Android 4.3 and Android 7.0 on what they do after connection and spot the different.&lt;/p&gt;
&lt;p&gt;Which app did you use on the phone ?&lt;/p&gt;
&lt;p&gt;I noticed that CC changed before disconnection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79201?ContentTypeID=1</link><pubDate>Fri, 10 Mar 2017 10:02:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72aa2e5e-f789-4fde-bba1-fa66a81c2697</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Marcin: Please provide code that reproduce the issue. From the log, doesn&amp;#39;t seem the CC changed when it&amp;#39;s disconnected but when in connection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79192?ContentTypeID=1</link><pubDate>Thu, 09 Mar 2017 15:05:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe94df3d-d278-4c6c-95ec-592f8c171d00</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Marcin,&lt;/p&gt;
&lt;p&gt;Could you make sure you don&amp;#39;t have any other code or other module that may use the RTC ?&lt;/p&gt;
&lt;p&gt;Which value the CC[0] changed to after you disconnect from the new Android phone ?&lt;/p&gt;
&lt;p&gt;Which Android version was that and which phone did you use ?&lt;/p&gt;
&lt;p&gt;Could you provide the nRF UART version with your modification that can reproduce the issue ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79193?ContentTypeID=1</link><pubDate>Thu, 09 Mar 2017 11:03:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d361b90-914b-4a74-a91f-93ed58c6397c</guid><dc:creator>Marcin</dc:creator><description>&lt;p&gt;I know it doesn&amp;#39;t have any sense. I use soft device 110, I use RTC 1 to get irq. This is my initialization code. It&amp;#39;s weird that at IOS or Android with old version everything works fine, but when I getting disconnet with new Android the register is changing and RTC stops. Main loop and other tasks works fine. It`s happens even when I am using NRF uart application.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void lfclk_config(void)
{
    ret_code_t err_code = nrf_drv_clock_init(NULL);
    APP_ERROR_CHECK(err_code);

    nrf_drv_clock_lfclk_request();
}

const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(1);

void rtc_config(void)
{
    uint32_t err_code;

    //Initialize RTC instance
    err_code = nrf_drv_rtc_init(&amp;amp;rtc, NULL, rtc_handler);
    APP_ERROR_CHECK(err_code);

    //Enable tick event &amp;amp; interrupt
    nrf_drv_rtc_tick_enable(&amp;amp;rtc,false);

    //Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds

	err_code = nrf_drv_rtc_cc_set(&amp;amp;rtc,1,2*60*8,true);
	APP_ERROR_CHECK(err_code);

    //Power on RTC instance
    nrf_drv_rtc_enable(&amp;amp;rtc);


}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;BLE config here:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint32_t BLE_config(void)
{
	uint32_t err_code;

	APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);


	ble_stack_init();
	gap_params_init();
	services_init();
	advertising_init(APP_ADV_START_TIMEOUT_IN_SECONDS);
	conn_params_init();

	//err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
	//APP_ERROR_CHECK(err_code);

    return err_code;
}

static void ble_stack_init(void)
{
    uint32_t err_code;

    // Initialize SoftDevice.
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);

    // Enable BLE stack.
    ble_enable_params_t ble_enable_params;
    memset(&amp;amp;ble_enable_params, 0, sizeof(ble_enable_params));
#if (defined(S130) || defined(S132))
    ble_enable_params.gatts_enable_params.attr_tab_size   = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
#endif
    ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
    err_code = sd_ble_enable(&amp;amp;ble_enable_params);
    APP_ERROR_CHECK(err_code);

    // Subscribe for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
}

static void gap_params_init(void)
{
    uint32_t                err_code;
    ble_gap_conn_params_t   gap_conn_params;
    ble_gap_conn_sec_mode_t sec_mode;

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;sec_mode);

    err_code = sd_ble_gap_device_name_set(&amp;amp;sec_mode,
                                          (const uint8_t *) DEVICE_NAME,
                                          strlen(DEVICE_NAME));
    APP_ERROR_CHECK(err_code);

    memset(&amp;amp;gap_conn_params, 0, sizeof(gap_conn_params));

    gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
    gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
    gap_conn_params.slave_latency     = SLAVE_LATENCY;
    gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;

    err_code = sd_ble_gap_ppcp_set(&amp;amp;gap_conn_params);
    APP_ERROR_CHECK(err_code);
}

static void services_init(void)
{
    uint32_t       err_code;
    ble_nus_init_t nus_init;

    memset(&amp;amp;nus_init, 0, sizeof(nus_init));

    nus_init.data_handler = nus_data_handler;

    err_code = ble_nus_init(&amp;amp;m_nus, &amp;amp;nus_init);
    APP_ERROR_CHECK(err_code);
}

void advertising_init(uint16_t timeout)
{
    uint32_t      err_code;
    ble_advdata_t advdata;
    ble_advdata_t scanrsp;

    // Build advertising data struct to pass into @ref ble_advertising_init.
    memset(&amp;amp;advdata, 0, sizeof(advdata));
    advdata.name_type          = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance = true;
    advdata.flags=BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    advdata.uuids_complete.p_uuids  = m_adv_uuids;
    ble_adv_modes_config_t options = {0};
    options.ble_adv_fast_enabled  = BLE_ADV_FAST_ENABLED;
    options.ble_adv_fast_interval = APP_ADV_INTERVAL;
    options.ble_adv_fast_timeout  = timeout;
    options.ble_adv_slow_enabled = BLE_ADV_SLOW_ENABLED;
    options.ble_adv_slow_interval = 2056;
    options.ble_adv_slow_timeout = timeout;

    err_code = ble_advertising_init(&amp;amp;advdata, NULL, &amp;amp;options, on_adv_evt, NULL);
    APP_ERROR_CHECK(err_code);
}

static void conn_params_init(void)
{
    uint32_t               err_code;
    ble_conn_params_init_t cp_init;

    memset(&amp;amp;cp_init, 0, sizeof(cp_init));

    cp_init.p_conn_params                  = NULL;
    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
    cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
    cp_init.disconnect_on_fail             = false;
    cp_init.evt_handler                    = on_conn_params_evt;
    cp_init.error_handler                  = conn_params_error_handler;

    err_code = ble_conn_params_init(&amp;amp;cp_init);
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I post the logs from terminal from 3 phones.&lt;/p&gt;
&lt;p&gt;rtc counter CC&lt;/p&gt;
&lt;p&gt;Android 4.3 Samsung gt-i9300 with CC[0]:
&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/android4.3-gt_2D00_i9300.png" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;Iphone 6S with system 10.2.1 with CC[0]:
&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/iphone6s10.2.1.png" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;and now Android 7.0 Samsung s7 edge with CC[0]:
&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/android7.0-galaxy-s7-edge.png" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;Android 7.0 Samsung s7 edge with CC[1]:
&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/android7.0-galaxy-s7-edgeCC_5B00_1_5D00_.png" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;Here is my code, sorry for a mess but this is just a test code:
&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/BLE_5F00_NEW_5F00_mod.rar"&gt;BLE_NEW_mod.rar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now it`s working. Here is log:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0815.log.png" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;The problem was in using app_timer library.&lt;/p&gt;
&lt;p&gt;Thanks a lot for help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC stops after disconnet from Android</title><link>https://devzone.nordicsemi.com/thread/79191?ContentTypeID=1</link><pubDate>Thu, 09 Mar 2017 10:29:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e80c6cc-1d5a-42aa-a4ba-6b921e485249</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Sorry but it doesn&amp;#39;t make sense that any external BLE device by connecting influences state of nRF5x registers like this. It must be code running on nRF5x chip which causes it, e.g. Soft Device. What SD are you running? What RTC instance are you using, how you initialize it etc.?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>