<?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>RTT repeats output that is meant to be sent only once</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6939/rtt-repeats-output-that-is-meant-to-be-sent-only-once</link><description>Well not my best title. But I hope you can follow this explanation: 
 I added RTT to my project to replace UART. It works so far. But there is a strange behaviour...
Code goes something like this: 
 int main(void)
{
SEGGER_RTT_WriteString(0, &amp;quot;Hallo</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 May 2015 13:47:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6939/rtt-repeats-output-that-is-meant-to-be-sent-only-once" /><item><title>RE: RTT repeats output that is meant to be sent only once</title><link>https://devzone.nordicsemi.com/thread/24473?ContentTypeID=1</link><pubDate>Thu, 07 May 2015 13:47:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e879a32-6c26-4247-a04e-c1c11a49c76e</guid><dc:creator>muhkuhns</dc:creator><description>&lt;p&gt;Looks like&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void on_ble_evt(ble_evt_t * p_ble_evt)
{
    switch (p_ble_evt-&amp;gt;header.evt_id)
    {       
        case BLE_GAP_EVT_DISCONNECTED:
            m_conn_handle = BLE_CONN_HANDLE_INVALID;
	    app_timer_stop(m_test_timer_id);
            advertising_start();		&amp;lt;- THIS		
            break;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;is causing the reset. Maybe because&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static uint32_t device_manager_evt_handler(dm_handle_t const * p_handle,
                                           dm_event_t const  * p_event,
                                           ret_code_t        event_result)
{

    switch(p_event-&amp;gt;event_id)
    {
        case DM_EVT_DISCONNECTION:
            m_conn_handle = BLE_CONN_HANDLE_INVALID;
            advertising_start();         &amp;lt;- It is here also.
            break;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But this is both from the example?&lt;/p&gt;
&lt;p&gt;If it outcomment one everything works as expected... but which one and why?&lt;/p&gt;
&lt;p&gt;When I connect and disconnect from MCP it seems like DM is called before GAP on both actions. (Doesn&amp;#39;t matter If I delete bond before or not). Of course I looked them up in the DOC but I don&amp;#39;t get why the &lt;code&gt;advertising_start()&lt;/code&gt; and also the  &lt;code&gt;m_conn_handle = BLE_CONN_HANDLE_INVALID;&lt;/code&gt; were duplicated from the beginning?&lt;/p&gt;
&lt;p&gt;In the unchanged multilink_peripheral example of course no systemreset is caused. But I only removed the LED stuff... Maybe it now calls the advertising_start()-function too quickly and it is in defect a mistake? I will edit this answer if someone points it out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTT repeats output that is meant to be sent only once</title><link>https://devzone.nordicsemi.com/thread/24472?ContentTypeID=1</link><pubDate>Thu, 07 May 2015 13:09:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db9bda61-d662-4870-a0f3-e6cbef6ea30b</guid><dc:creator>muhkuhns</dc:creator><description>&lt;p&gt;Thanks for your answer, it helped me a lot finding the problem! See my answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTT repeats output that is meant to be sent only once</title><link>https://devzone.nordicsemi.com/thread/24471?ContentTypeID=1</link><pubDate>Thu, 07 May 2015 12:43:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:661c31fa-0eff-4ab7-accb-e6c8eaa0eb03</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;When you said you tried to debug in the error handler, which error handler did you mean?
After Disconnection, it seems that one of your APP_ERROR_CHECK has failed.
check component\libraries\util\app_error.c -&amp;gt;app_error_handler&lt;/p&gt;
&lt;p&gt;I think RK has explained you once in depth, if my memory serves me well. I would recommend you to overwrite app_error_handler function now so that we can rule out this problem in the future references.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>