<?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>Error in NUS Peripheral and central</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49149/error-in-nus-peripheral-and-central</link><description>Hello, 
 i’m using NRF52832 with SoftDevice S132 and Sdk 15.3 to develop a NUS peripheral and central. The system is tested as follows: 
 I have two NUS peripherals , a NUS Central-Peripheral device that echoes the data received from the peripherals and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 06 Aug 2019 09:44:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49149/error-in-nus-peripheral-and-central" /><item><title>RE: Error in NUS Peripheral and central</title><link>https://devzone.nordicsemi.com/thread/202561?ContentTypeID=1</link><pubDate>Tue, 06 Aug 2019 09:44:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b21f7606-4a4a-44b8-8ac4-ce7ca1a20afd</guid><dc:creator>arditdv</dc:creator><description>&lt;p&gt;Sorry for the late response. I&amp;#39;m already separating between the peripheral and central roles. The problem was not there. I already found a workaround and got it working. Thank you for your help.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error in NUS Peripheral and central</title><link>https://devzone.nordicsemi.com/thread/195992?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2019 12:42:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0265164-3acd-42b5-a0fe-464247da9bc3</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;There could be that when you get connected, event&amp;nbsp;BLE_GAP_EVT_CONNECTED will arrive. And&amp;nbsp;ble_nus_on_ble_evt() in ble_nus.c will be called (because it&amp;#39;s observing those events) and on_connect() will be executed. Please use a check for&amp;nbsp;p_ble_evt-&amp;gt;evt.gap_evt.params.connected.role==BLE_GAP_ROLE_PERIPH before you proceed in that function. Similar to what we have in on_connect() inside ble_conn_params.c&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error in NUS Peripheral and central</title><link>https://devzone.nordicsemi.com/thread/195755?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2019 18:17:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0215f26-9209-454d-87c0-50edaf71ce96</guid><dc:creator>arditdv</dc:creator><description>&lt;p&gt;Hello Hung Bui,&lt;/p&gt;
&lt;p&gt;Thanks for your reply. Yes, I&amp;#39;m creating my own relay example by combining central and peripheral ble_app_uart examples. I know that there should not be a call to on_connect() from ble_nus_c, but I&amp;#39;m positive that when a peripheral is connecting, the on_connect() is called.&amp;nbsp; I dont understand why.&lt;/p&gt;
&lt;p&gt;The one thing that im not sure about is the definition of the instances. As i&amp;#39;m using c++ for coding, i had to expand some of the Makros, as they were not compatible with c++. See following code snippet.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;RF_BLE_GATT_DEF(m_gatt);                                           /**&amp;lt; GATT module instance. */
NRF_BLE_QWRS_DEF(m_qwr, NRF_SDH_BLE_TOTAL_LINK_COUNT);              /**&amp;lt; Context for the Queued Write module.*/
BLE_NUS_C_ARRAY_DEF(m_ble_nus_c, NRF_SDH_BLE_CENTRAL_LINK_COUNT);
BLE_ADVERTISING_DEF(m_advertising);                                 /**&amp;lt; Advertising module instance. */
NRF_BLE_SCAN_DEF(m_scan);
/**&amp;lt; Scanning module instance. */

static uint32_t m_nus_link_ctx_storage_ctx_data_pool[((1))*(((sizeof(ble_nus_client_context_t)) + 3) &amp;gt;&amp;gt; 2)];
static blcm_link_ctx_storage_t m_nus_link_ctx_storage =                                                          \
{
	.p_ctx_data_pool = m_nus_link_ctx_storage_ctx_data_pool,
	.max_links_cnt   = ((NRF_SDH_BLE_TOTAL_LINK_COUNT)),
	.link_ctx_size   = sizeof(m_nus_link_ctx_storage_ctx_data_pool)
};
static ble_nus_t m_nus =
{
	.uuid_type = 0,
	.service_handle = 0,
	.tx_handles = {0},
	.rx_handles = {0},
	.p_link_ctx_storage = &amp;amp;m_nus_link_ctx_storage,
};

NRF_SECTION_ITEM_REGISTER(sdh_ble_observers5, static nrf_sdh_ble_evt_observer_t m_nus_obs) =
{
    .handler   = ble_nus_on_ble_evt,
    .p_context = &amp;amp;m_nus,
};

/**&amp;lt; Database discovery module instances. */
/* As there are 2 peripherals to be discovered, two instances of ble_db_discovery_t are created. MACRO not compatible with c++ */
static ble_db_discovery_t m_db_disc[2];

NRF_SECTION_ITEM_REGISTER(sdh_ble_observers3, static nrf_sdh_ble_evt_observer_t m_db_obs1) =
{
    .handler   = ble_db_discovery_on_ble_evt,
    .p_context = &amp;amp;m_db_disc[1],
};

NRF_SECTION_ITEM_REGISTER(sdh_ble_observers4, static nrf_sdh_ble_evt_observer_t m_db_obs2) =
{
    .handler   = ble_db_discovery_on_ble_evt,
    .p_context = &amp;amp;m_db_disc[0],
};
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error in NUS Peripheral and central</title><link>https://devzone.nordicsemi.com/thread/195738?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2019 15:07:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:584b5aed-bb47-49bd-a6cf-e128c2f6ff61</guid><dc:creator>awneil</dc:creator><description>[quote userid="2121" url="~/f/nordic-q-a/49149/error-in-nus-peripheral-and-central/195731"]Please show your code where you have doubt[/quote]
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/arditdv"&gt;arditdv&lt;/a&gt; - how to post source code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/85253._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error in NUS Peripheral and central</title><link>https://devzone.nordicsemi.com/thread/195731?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2019 15:01:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f29e949-f50e-493f-8087-85c2acd3e444</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Aditdv,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please clarify, you were creating your own relay device that combine the central and peripheral ble_app_uart together ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please show your code where you have doubt.&lt;/p&gt;
&lt;p&gt;Please note that there is no call to&amp;nbsp;&lt;span&gt;on_connect() inside original ble_nus_c.c file , nor that file link to ble_nus.h, it only link to ble_nus_c.h&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please check again with the original ble_nus_c.c file.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;on_connect() is called inside ble_nus_on_ble_evt, which is belong to ble_nus.c&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error in NUS Peripheral and central</title><link>https://devzone.nordicsemi.com/thread/195459?ContentTypeID=1</link><pubDate>Sat, 29 Jun 2019 10:54:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68bad887-a72a-42a5-ac5f-b737704af76b</guid><dc:creator>arditdv</dc:creator><description>&lt;p&gt;It is not on my hand. SDK does that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error in NUS Peripheral and central</title><link>https://devzone.nordicsemi.com/thread/195457?ContentTypeID=1</link><pubDate>Sat, 29 Jun 2019 10:48:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4ae9013-3673-491d-b271-e7161729be90</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;So don&amp;#39;t do that, then!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error in NUS Peripheral and central</title><link>https://devzone.nordicsemi.com/thread/195456?ContentTypeID=1</link><pubDate>Sat, 29 Jun 2019 10:15:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea687a8f-7412-4bf4-8fd6-83ba1781da81</guid><dc:creator>arditdv</dc:creator><description>&lt;p&gt;Thanks for your reply.&lt;/p&gt;
&lt;p&gt;The problem lies in the NUS peripheral-central-device. And yes, i have a working case and a non-working case. &lt;br /&gt;As i described the problem is, that the ble_nus_c instances call on_connect() method in the ble_nus.h and that should not be the case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error in NUS Peripheral and central</title><link>https://devzone.nordicsemi.com/thread/195455?ContentTypeID=1</link><pubDate>Sat, 29 Jun 2019 10:03:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b524205-96dd-4178-9869-dd2f998a6427</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;I find it hard to follow your description - a diagram (or diagrams) would help.&lt;/p&gt;
&lt;p&gt;But it seems that you have a working case, and a non-working case - yes?&lt;/p&gt;
&lt;p&gt;So the standard approach would be to follow what happens in both cases, and see what&amp;#39;s different/missing in the non-working case...&lt;/p&gt;
&lt;p&gt;You may need to use &lt;strong&gt;Monitor Mode Debug&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/49057/issue-adding-descriptor-to-characteristic-on-nrf52810-for-custom-service/195307#195307"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/49057/issue-adding-descriptor-to-characteristic-on-nrf52810-for-custom-service/195307#195307&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>