<?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>ble app uart</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80061/ble-app-uart</link><description>Hi： 
 I use nrf52832 to connect to the sensor module through uart. When the sensor device is turned off, I can repeat the pairing and unpairing of the Ble module through the nRF Connect app. But after the Ble module pairing is completed and the sensor</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 Oct 2021 13:43:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80061/ble-app-uart" /><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/333544?ContentTypeID=1</link><pubDate>Mon, 11 Oct 2021 13:43:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63748a50-2353-4dc4-84b8-e1115ad93f5d</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;Thank you for your patience with this.&lt;/p&gt;
&lt;p&gt;To elaborate a little on what I said earlier; error&amp;nbsp; 13313=0x3401 corresponds to&amp;nbsp;BLE_ERROR_GATTS_SYS_ATTR_MISSING and is likely returned by&amp;nbsp; ble_nus_data_send() because it&amp;#39;s called before the system attribute table has been updated in the Softdevice, similar to the&amp;nbsp;NRF_ERROR_INVALID_STATE error you get if you try to send notifications before notifications has been enabled by the GATT client .&lt;/p&gt;
&lt;p&gt;The attribute table (contain CCCD configurations) is restored on connection if you use the Peer manager module. Maybe ble_nus_data_send() is called before the Peer manager has had time to restore the attributes, or similar.&lt;/p&gt;
[quote user="nicky_liu"]I hope it can run correctly without stopping Uart RX, but I still can&amp;#39;t achieve it at the moment.[/quote]
&lt;p&gt;If it is important not to stop the UART RX then perhaps we should redirect the messages received on the UART to RAM or Flash storage (depending on the amount of data received in the time that a connection is broken), as a fix to this.&lt;br /&gt;Could this be an option?&lt;br /&gt;If this issue only is present when re-pairing, then you could add a specific error handling for this error, which is to store the data for later transfer, and then try again sometimes later. This error should disappear as soon as the Peer Manager has had enough time to update the attribute table, as mentioned above.&lt;br /&gt;Could you try this, and see if it resolves your issue? I.e implement specific error handling for the 13313 error that stores the data you attempted to queue for later transfer, so that the peer manager has enough time to populate the attribute table.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332970?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2021 09:57:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd3526c5-d30e-4368-8f69-de3c729a7682</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi Karl：&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;1.Are you seeing this 13313 error frequently, or only at a given time in your program?&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;Ans : Currently the 13313 error only appears when I want to re-pair the device.&lt;/p&gt;
&lt;p&gt;2.Could you check whether you are receiving this event in your PM event handler or not?&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Ans : I have added the following LOG_INFO in the PM event, but it seems not to be executed.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        case PM_EVT_CONN_SEC_CONFIG_REQ:
        {
            // Allow or reject pairing request from an already bonded peer.
            pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};
            pm_conn_sec_config_reply(p_evt-&amp;gt;conn_handle, &amp;amp;conn_sec_config);
            NRF_LOG_INFO(&amp;quot;device re-pair/n&amp;quot;)　　
        }
            break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;3.&lt;span&gt;Does the applications UART RX callback include a call to queue a notification with the received data? Could it be that the function attempts to queue data for a recently disconnected / unpaired device?&lt;/span&gt;&lt;br /&gt;&lt;span&gt;If so, you may handle this error by stopping the UART RX and storing the data you attempted to queue for transfer later, or discard the data entirely if it is not relevant later. How does this work with your application&amp;#39;s constraints and requirements?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;Ans :&amp;nbsp;I hope it can run correctly without stopping Uart RX, but I still can&amp;#39;t achieve it at the moment.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332873?ContentTypeID=1</link><pubDate>Wed, 06 Oct 2021 14:37:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2c61da0-146d-4015-acf6-7dad281dd9c4</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="nicky_liu"]Yes, line 617 in main.c is the APP_ERROR_CHECK following the call to ble_nus_data_send.[/quote]
&lt;p&gt;Thank you for confirming this.&lt;br /&gt;The 13313 error returned from ble_nus_data_send propagates from sd_ble_gatts_hvx, and as I&amp;#39;ve understood it usually means that you&amp;#39;ve tried to queue a notification for sending for a connection handle that the SoftDevice has not been provided any system attributes for. This should then generate a BLE_GATTS_EVT_SYS_ATTR_MISSING event, if it is the case. Are you seeing this 13313 error frequently, or only at a given time in your program? Other user&amp;#39;s I&amp;#39;ve seen experience this reported that this error was only returned as a result of a call to queue a notification interrupted by a disconnected event or connected event - could this also be the case here?&lt;br /&gt;If you retry the call to ble_nus_data_send once immediately after having received the 13313 error, does it still return 13313 on the second try?&lt;br /&gt;&lt;br /&gt;When not using pairing / bonding this can be handled by adding the following into the ble_evt_handler:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case BLE_GATTS_EVT_SYS_ATTR_MISSING:
    err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0);
    APP_ERROR_CHECK(err_code);
    break;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;When using pairing / bonding this should then instead be handled by the peer manager.&lt;br /&gt;Could you check whether you are receiving this event in your PM event handler or not?&lt;/p&gt;
[quote user="nicky_liu"]&lt;span&gt;After doing some experiments, I found that the problem of not being able to re-pair seems to occur when the Uart RX listen is not stopped and the device is unpaired. When I stop Uart RX listen first, and then unpair the device, this problem will not occur.&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Is there a solution to this?&lt;/span&gt;[/quote]
&lt;p&gt;This points in the direction of the aforementioned - that CCCD (notify) is enabled on the peripheral, and when the connection is broken the device may still be trying to send a notification, and/or upon the next reconnection it may generate the BLE_GATTS_EVT_SYS_ATTR_MISSING event to see if it has stored any information about this peer and its attributes (like the CCCD already being enabled from the previous connection).&lt;/p&gt;
&lt;p&gt;Does the applications UART RX callback include a call to queue a notification with the received data? Could it be that the function attempts to queue data for a recently disconnected / unpaired device?&lt;br /&gt;If so, you may handle this error by stopping the UART RX and storing the data you attempted to queue for transfer later, or discard the data entirely if it is not relevant later. How does this work with your application&amp;#39;s constraints and requirements?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332560?ContentTypeID=1</link><pubDate>Tue, 05 Oct 2021 10:17:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a9c06f1-e217-4a1a-9547-4df98872692f</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi Karl:&lt;/span&gt;&lt;br /&gt;&lt;span&gt;After doing some experiments, I found that the problem of not being able to re-pair seems to occur when the Uart RX listen is not stopped and the device is unpaired. When I stop Uart RX listen first, and then unpair the device, this problem will not occur.&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Is there a solution to this?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Skype_5F00_Picture_5F00_2021_5F00_10_5F00_05T10_5F00_16_5F00_52_5F00_353Z.jpeg" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332546?ContentTypeID=1</link><pubDate>Tue, 05 Oct 2021 09:27:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e027d208-92ce-4102-9054-ed8eba24c2e6</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;Yes, line 617 in main.c is the APP_ERROR_CHECK following the call to ble_nus_data_send.&lt;br /&gt;What should I do?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332537?ContentTypeID=1</link><pubDate>Tue, 05 Oct 2021 09:09:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f650eb3-b55d-426b-863b-7cf96d579bd4</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;On a general note&amp;nbsp;I also notice that you have quite a long path to your SDK location.&lt;br /&gt;Please be aware of Window&amp;#39;s 260 character path limit - anything exceeding 260 characters will be truncated.&lt;br /&gt;This can cause quite a headache if not aware of it.&lt;br /&gt;I recommend that you move you SDK location to be on top of your hierarchy, like C:\nordic\ or similar.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332533?ContentTypeID=1</link><pubDate>Tue, 05 Oct 2021 09:07:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa548f7f-2918-49ae-b255-59a5563252cc</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="nicky_liu"]Do you want these messages?[/quote]
&lt;p&gt;Yes, exactly this, thank you.&lt;/p&gt;
[quote user="nicky_liu"]&lt;span style="color:rgba(0, 0, 255, 1);"&gt;&amp;lt;error&amp;gt; app: ERROR 13313 [Unknown error code] at C:\Users\user\Desktop\nordic\nRF5SDK1702d674dde\nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_uart\main.c:617&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(0, 0, 255, 1);"&gt;PC at: 0x0003230B&lt;/span&gt;&lt;br /&gt;&lt;span style="color:rgba(0, 0, 255, 1);"&gt;&amp;lt;error&amp;gt; app: End of error report&lt;/span&gt;[/quote]
&lt;p&gt;The error report states that the APP_ERROR_CHECK was triggered on line 617 of main.c&lt;br /&gt;Could you also confirm that the APP_ERROR_CHECK following the call to ble_nus_data_send in the code snippet that you have sent is in fact line 617 of your main.c?&lt;br /&gt;It seems strange to me that this could return an unknown error code such as 13313 - this is usually the case when a non-error code is passed to an APP_ERROR_CHECK, or in the case that an uninitialized error code is passed to an APP_ERROR_CHECK.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332514?ContentTypeID=1</link><pubDate>Tue, 05 Oct 2021 08:23:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fdb4a72-8d67-422c-beca-015f8f6413f4</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;Hi Karl：&lt;/p&gt;
&lt;p&gt;Do you want these messages?&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app_timer: RTC: initialized.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Debug logging for UART over RTT started.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Connected&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Data len is set to 0xF4(244)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Disconnected&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Connected&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Data len is set to 0xF4(244)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;error&amp;gt; app: ERROR 13313 [Unknown error code] at C:\Users\user\Desktop\nordic\nRF5SDK1702d674dde\nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_uart\main.c:617&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;PC at: 0x0003230B&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;error&amp;gt; app: End of error report&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
    static uint8_t index = 0;
    uint32_t       err_code;

    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
            index++;
/*
            if(data_array[0] == 0x02 &amp;amp;&amp;amp; data_array[1] == 0x01 &amp;amp;&amp;amp; data_array[2] == 0x04 &amp;amp;&amp;amp; data_array[3] == 0x03)
            {
            
              int dataLength = data_array[8] + data_array[9] * 256;
                if (data_array[8 + dataLength] &amp;amp;&amp;amp; data_array[9 + dataLength] &amp;amp;&amp;amp; data_array[10 + dataLength] &amp;amp;&amp;amp; data_array[11 + dataLength] == 0xff )
                {
                    if (index &amp;gt; 1)
                    {
                        NRF_LOG_INFO(&amp;quot;Send_data&amp;quot;);
                        NRF_LOG_DEBUG(&amp;quot;Ready to send data over BLE NUS&amp;quot;);
                        NRF_LOG_HEXDUMP_DEBUG(data_array, index);

                        do
                        {
                            uint16_t length = (uint16_t)index;
                            err_code = ble_nus_data_send(&amp;amp;m_nus, data_array, &amp;amp;length, m_conn_handle);
                            if ((err_code != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp;
                                (err_code != NRF_ERROR_RESOURCES) &amp;amp;&amp;amp;
                                (err_code != NRF_ERROR_NOT_FOUND))
                            {
                                APP_ERROR_CHECK(err_code);
                            }
                        } while (err_code == NRF_ERROR_RESOURCES);
                    }

                    index = 0;
                }

                else if((data_array[index - 1] &amp;amp;&amp;amp; data_array[index - 2] &amp;amp;&amp;amp; data_array[index - 3] &amp;amp;&amp;amp; data_array[index - 4] == 0xff) ||
                        (index &amp;gt;= m_ble_nus_max_data_len))
                {
                    if (index &amp;gt; 1)
                    {
                        NRF_LOG_DEBUG(&amp;quot;Ready to send data over BLE NUS&amp;quot;);
                        NRF_LOG_HEXDUMP_DEBUG(data_array, index);

                        do
                        {
                            uint16_t length = (uint16_t)index;
                            err_code = ble_nus_data_send(&amp;amp;m_nus, data_array, &amp;amp;length, m_conn_handle);
                            if ((err_code != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp;
                                (err_code != NRF_ERROR_RESOURCES) &amp;amp;&amp;amp;
                                (err_code != NRF_ERROR_NOT_FOUND))
                            {
                                APP_ERROR_CHECK(err_code);
                            }
                        } while (err_code == NRF_ERROR_RESOURCES);
                    }

                    index = 0;
                }
            }
*/
           // else
           // {
               // if ((data_array[index - 1] &amp;amp;&amp;amp; data_array[index - 2] &amp;amp;&amp;amp; data_array[index - 3] &amp;amp;&amp;amp; data_array[index - 4] == 0xff) ||
               if ((data_array[index - 1] == &amp;#39;\n&amp;#39;) || 
                   (data_array[index - 1] == &amp;#39;\r&amp;#39;) ||
                   (index &amp;gt;= (m_ble_nus_max_data_len)))
                {
                    if (index &amp;gt; 1)
                    {
                        NRF_LOG_DEBUG(&amp;quot;Ready to send data over BLE NUS&amp;quot;);
                        NRF_LOG_HEXDUMP_DEBUG(data_array, index);

                        do
                        {
                            uint16_t length = (uint16_t)index;
                            err_code = ble_nus_data_send(&amp;amp;m_nus, data_array, &amp;amp;length, m_conn_handle);
                            if ((err_code != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp;
                                (err_code != NRF_ERROR_RESOURCES) &amp;amp;&amp;amp;
                                (err_code != NRF_ERROR_NOT_FOUND))
                            {
                                APP_ERROR_CHECK(err_code);
                            }
                        } while (err_code == NRF_ERROR_RESOURCES);
                    }

                    index = 0;
                }
        //    }
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        default:
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332500?ContentTypeID=1</link><pubDate>Tue, 05 Oct 2021 08:05:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f3d9eb5-906a-4be5-9b1d-e0bb3e29d109</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again,&lt;br /&gt;&lt;br /&gt;Could you show me the entire error message, preferably as a text string instead of a screenshot?&lt;br /&gt;At the very end of the error message it tells you which line that failed the APP_ERROR_CHECK. Please also show me the code section (entire function) that triggered this APP_ERROR_CHECK. Please also use the&amp;nbsp;&lt;em&gt;Insert -&amp;gt; Code&amp;nbsp;&lt;/em&gt;option when sharing code here on DevZone - this drastically increases it&amp;#39;s readability.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332474?ContentTypeID=1</link><pubDate>Tue, 05 Oct 2021 07:07:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff0ee32f-342c-40f1-b0fa-4e85e0ef0e86</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;Sorry, the wrong code should be in the red box below&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/333.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332451?ContentTypeID=1</link><pubDate>Tue, 05 Oct 2021 04:14:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9130c44-8696-4c6f-b543-856662a79749</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;Hi Karl:&lt;/p&gt;
&lt;p&gt;The following is the message I received from debug Treminal. It seems to be caused by APP_UART_COMMUNICATION_ERROR in main.c&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/3426.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332266?ContentTypeID=1</link><pubDate>Mon, 04 Oct 2021 09:01:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80167b16-c84a-4798-9ab2-2946801897de</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Aha, now I understand - I was under the impression that you were still talking about the sdk_config issue.&lt;br /&gt;&lt;br /&gt;I do not immediately see anything wrong with this event handler, no.&lt;br /&gt;Could you place a breakpoint in the&amp;nbsp;&lt;em&gt;PM_EVT_CONN_CONFIG_REQ&lt;/em&gt;&lt;span&gt;&amp;nbsp; section, to confirm that you receive this event when a new connection is made?&lt;br /&gt;&lt;/span&gt;Are you able to pair, but not re-pair?&lt;br /&gt;Which error are you getting when you attempt to re-pair?&lt;br /&gt;What does you log say when this happens?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332188?ContentTypeID=1</link><pubDate>Fri, 01 Oct 2021 16:02:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7b219a5-9308-4790-832a-0fed93bf660a</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;Sorry, I didn&amp;#39;t express it clearly. After modifying sdk_config.h according to your suggestion, the program can work, but the device still cannot be re-paired. Can you help me confirm the modified part of the main.c file?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332107?ContentTypeID=1</link><pubDate>Fri, 01 Oct 2021 10:38:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a643110-f5b8-4fcc-b9f6-f5293fe7183c</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;Could you confirm for me that you have defined PEER_MANAGER_ENABLED 1 in your sdk_config.h file? Every driver or module that is not enabled in the sdk_config will be excluded from compilation.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332102?ContentTypeID=1</link><pubDate>Fri, 01 Oct 2021 10:24:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5c1d14f-f188-438d-95a7-e9ab19c2c823</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;I modified the code according to your suggestion, but the problem still exists. Can you check the modified part for me?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**@brief Function for handling Peer Manager events.
 *
 * @param[in] p_evt  Peer Manager event.
 */
static void pm_evt_handler(pm_evt_t const * p_evt)
{
    ret_code_t err_code;
    bool       is_indication_enabled;

    pm_handler_on_pm_evt(p_evt);
    pm_handler_flash_clean(p_evt);

    switch (p_evt-&amp;gt;evt_id)
    {
        case PM_EVT_CONN_SEC_CONFIG_REQ:
        {
            // Allow or reject pairing request from an already bonded peer.
            pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};
            pm_conn_sec_config_reply(p_evt-&amp;gt;conn_handle, &amp;amp;conn_sec_config);
        }
            break;

        case PM_EVT_PEERS_DELETE_SUCCEEDED:
        {
            advertising_start();
        }
            break;

        default:
            break;
    }
}


/**@brief Function for the Peer Manager initialization.
 */
static void peer_manager_init(void)
{
    ble_gap_sec_params_t sec_param;
    ret_code_t           err_code;

    err_code = pm_init();
    APP_ERROR_CHECK(err_code);

    memset(&amp;amp;sec_param, 0, sizeof(ble_gap_sec_params_t));

    // Security parameters to be used for all security procedures.
    sec_param.bond           = SEC_PARAM_BOND;
    sec_param.mitm           = SEC_PARAM_MITM;
    sec_param.lesc           = SEC_PARAM_LESC;
    sec_param.keypress       = SEC_PARAM_KEYPRESS;
    sec_param.io_caps        = SEC_PARAM_IO_CAPABILITIES;
    sec_param.oob            = SEC_PARAM_OOB;
    sec_param.min_key_size   = SEC_PARAM_MIN_KEY_SIZE;
    sec_param.max_key_size   = SEC_PARAM_MAX_KEY_SIZE;
    sec_param.kdist_own.enc  = 1;
    sec_param.kdist_own.id   = 1;
    sec_param.kdist_peer.enc = 1;
    sec_param.kdist_peer.id  = 1;

    err_code = pm_sec_params_set(&amp;amp;sec_param);
    APP_ERROR_CHECK(err_code);

    err_code = pm_register(pm_evt_handler);
    APP_ERROR_CHECK(err_code);
}



/**@brief Application main function.
 */
int main(void)
{
    bool erase_bonds;

    // Initialize.
    uart_init();
    log_init();
    timers_init();
    buttons_leds_init(&amp;amp;erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    peer_manager_init();

    // Start execution.
    printf(&amp;quot;\r\nUART started.\r\n&amp;quot;);
    NRF_LOG_INFO(&amp;quot;Debug logging for UART over RTT started.&amp;quot;);
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}


/**
 * @}
 */&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332094?ContentTypeID=1</link><pubDate>Fri, 01 Oct 2021 09:33:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ab6ee18-2e1d-4b9a-9808-abb85851ce8b</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;It seems like you have not enabled the peer manager module in your sdk_config.&lt;br /&gt;Please check the sdk_config of the ble hrs example to see how this could be done.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/332081?ContentTypeID=1</link><pubDate>Fri, 01 Oct 2021 08:57:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d94b44d-582c-44ac-9936-fdcf4762bd06</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;Hi Karl：&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;I am trying to modify the project file, but there seems to be some problems with the header, how can I solve it?&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/4666._2A677D540D54_.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/6523._2A677D540D54_1.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/331918?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2021 12:12:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40163453-3cd7-441f-a3ef-211ef104fc99</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="nicky_liu"]Thank you for your reply[/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;/p&gt;
[quote user="nicky_liu"]Is there any relevant example?[/quote]
&lt;p&gt;You will need to add the peer manager to your application if you intend to support pairing, re-pairing and/or bonding. By default the ble_app_uart does not actually use any encryption / security as it is mainly meant as a demonstration of how to set up the most generic custom service.&lt;br /&gt;There is indeed a couple of examples demonstrating the use of the peer manager, such as the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/ble_sdk_app_bps.html"&gt;Blood pressure example&lt;/a&gt;&amp;nbsp;and &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/ble_sdk_app_hrs.html"&gt;heart rate example&lt;/a&gt;&amp;nbsp;- both of which require a higher security level for their services.&lt;br /&gt;You can also &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_peer_manager.html"&gt;read more about the peer manager in general in its library documentation&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Please do not hesitate to ask if any part of this still should be unclear, or if you have any other questions about this!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/331885?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2021 10:44:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9261b217-adbe-48e1-9999-136b01adaf42</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;Thank you for your reply, but I can&amp;#39;t find pm_evt_handler() in the ble app uart example. Is it set by ble_evt_handler (SDK 17.0.2)? Is there any relevant example?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/331875?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2021 10:01:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8b3807a-a349-4c01-9033-82bd538d1d70</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again,&lt;/p&gt;
[quote user="nicky_liu"]I restarted an unmodified uart_app_ble project and used bebug Treminal. The information I received when I want to re-pair the device is as follows[/quote]
&lt;p&gt;Thank you for testing this again with an unmodified version of the ble_app_uart example. My apologies for misunderstanding what you were seeking to achieve earlier, I now understand that you wish to allow for re-pairing of the connection specifically.&lt;br /&gt;Re-pairing is by default not enabled in any of our examples, since this reduces the security of the connection. Please have a look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/67406/nrf52840---sdk16---bonding"&gt;the answer by my colleague Einar in this ticket for additional detail&lt;/a&gt;, it also includes the necessary code to allow re-pairing in your application.&lt;br /&gt;&lt;br /&gt;For future reference, please make sure to have DEBUG defined in your preprocessor defines like shown in the included image:&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/6355.enabling_5F00_debug_5F00_SES.PNG" /&gt;&lt;br /&gt;This will make a detailed error message be printed to your logger whenever a non-NRF_SUCCESS error is passed to an APP_ERROR_CHECK, instead of the shortform error message.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/331818?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2021 05:25:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:648b8b01-99ae-4388-893a-f7d5274bc901</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;Hi Karl：&lt;/p&gt;
&lt;p&gt;&amp;nbsp; I restarted an unmodified uart_app_ble project and used bebug Treminal. The information I received when I want to re-pair the device is as follows&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app_timer: RTC: initialized.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Debug logging for UART over RTT started.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Connected&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Data len is set to 0xB6(182)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Disconnected&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Connected&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#000000;"&gt;&amp;nbsp;&lt;span style="color:#ff0000;"&gt;&amp;lt;========When I want to re-pair&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;info&amp;gt; app: Data len is set to 0xB6(182)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;error&amp;gt; app: Fatal error&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/331670?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2021 10:28:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b484a79a-402f-4163-996f-84e849279ea4</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;No, I would like to see the loggers output from the nRF52832 that is connected to your sensor device.&lt;br /&gt;Are you using Segger Embedded studios to do your programming?&lt;br /&gt;If so, start a debugging session and click to view the&amp;nbsp;&lt;em&gt;debug terminal&amp;nbsp;&lt;/em&gt;before you start the program - there should be a message reading &amp;quot;Debug logging for UART over RTT started.&amp;quot; at the very start of the program, for instance.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/331662?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2021 09:51:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b4c6ce6-8571-4446-855f-859774da73f5</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;Do you want to confirm the operation of the sensor device?&lt;br /&gt;When the Ble is unpaired, the sensor will continue to send data to the BLE module through uart&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/_2A677D540D54_.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/331653?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2021 09:14:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4af85683-54b8-4ecc-b33b-6dd632042e9a</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Oh, my apologies - I meant to say that I would like to see the peripheral&amp;#39;s side log.&lt;br /&gt;The UART example by default logs using the RTT backend, which you can see either in the&amp;nbsp;&lt;em&gt;debug terminal&amp;nbsp;&lt;/em&gt;in Segger Embedded Studios, or in the standalone&amp;nbsp;&lt;em&gt;RTT Viewer&amp;nbsp;&lt;/em&gt;application by SEGGER.&lt;br /&gt;Please instead show me this log for the scenario in which this behavior occurs.&lt;/p&gt;
[quote user="nicky_liu"]In the example of ble app uart, the code I modified is as follows:[/quote]
&lt;p&gt;Thank you for specifying.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble app uart</title><link>https://devzone.nordicsemi.com/thread/331640?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2021 08:48:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d917b8bb-b144-4531-94a4-7b60e3ae0fcb</guid><dc:creator>nicky_liu</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi Karl：&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This picture is the message that appeared in the nRF Connect Log when I unpaired&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Skype_5F00_Picture_5F00_2021_5F00_09_5F00_29T08_5F00_33_5F00_29_5F00_827Z.jpeg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The pictures are the screen that appears on nRF Connect when I want to re-pair again, and the message that appears in the log&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Skype_5F00_Picture_5F00_2021_5F00_09_5F00_29T08_5F00_33_5F00_53_5F00_522Z.jpeg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Skype_5F00_Picture_5F00_2021_5F00_09_5F00_29T08_5F00_34_5F00_07_5F00_996Z.jpeg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In the example of ble app uart, the code I modified is as follows:&lt;/p&gt;
&lt;p&gt;#define BLE_GATT_ATT_MTU_DEFAULT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 247&amp;nbsp; &amp;nbsp; &amp;nbsp;//23&lt;/p&gt;
&lt;p&gt;#define MIN_CONN_INTERVAL MSEC_TO_UNITS(20, UNIT_1_25_MS)&amp;nbsp; &amp;nbsp; &amp;nbsp; //20&lt;br /&gt;#define MAX_CONN_INTERVAL MSEC_TO_UNITS(30, UNIT_1_25_MS)&amp;nbsp; &amp;nbsp; &amp;nbsp;//70&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>