<?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>nrf52-ble-app-uart-c-multilink - second service discovery and connection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110471/nrf52-ble-app-uart-c-multilink---second-service-discovery-and-connection</link><description>Hi, 
 I have two nRF52840 devices one peripheral and one central. Both devices feature the Nordic Uart Service. They are based on ble_app_uart example and e nrf52-ble-app-uart-c-multilink example respectively ( link ). 
 The adapter device can successfully</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Apr 2024 11:53:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110471/nrf52-ble-app-uart-c-multilink---second-service-discovery-and-connection" /><item><title>RE: nrf52-ble-app-uart-c-multilink - second service discovery and connection</title><link>https://devzone.nordicsemi.com/thread/480878?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2024 11:53:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83474319-e89b-4648-87ad-5fab7efcb703</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Yes it works as expected! Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52-ble-app-uart-c-multilink - second service discovery and connection</title><link>https://devzone.nordicsemi.com/thread/480860?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2024 10:33:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85be5514-60f7-44db-b84d-b550690f060e</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;I am glad to read that you were able to identify and resolve the issue! :)&amp;nbsp;&lt;br /&gt;Does this mean that you now have everything working as intended?&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: nrf52-ble-app-uart-c-multilink - second service discovery and connection</title><link>https://devzone.nordicsemi.com/thread/480634?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2024 09:56:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddaafeee-9dca-4597-952a-fbbb35983e6a</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;I fixed it, the problem was in the custom service library where I did not include&lt;/p&gt;
&lt;p&gt;cus_c_evt.handles.cus_char_cccd_handle = p_chars[i].cccd_handle;&lt;/p&gt;
&lt;p&gt;under the case BLE_UUID_CUS_CHARACTERISTIC event&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52-ble-app-uart-c-multilink - second service discovery and connection</title><link>https://devzone.nordicsemi.com/thread/480503?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2024 15:07:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5637106-279c-46d3-981b-61485a93891f</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Hi, I faced an issue and I need your help&lt;br /&gt;First of all I will enumerate the steps I have taken so far &lt;/p&gt;
&lt;p&gt;1. Created the library for the custom service (client side) based on this service library (sdk path: components\ble\ble_services\ble_nus_c).&lt;/p&gt;
&lt;p&gt;2. Added this modified service library into a new project based on ble_app_uart_c example&lt;/p&gt;
&lt;p&gt;3. In main.c of the new project I added everything regarding the new service discovery. Specifically I added the following things&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//main.c modifications for client custom service 

//--------------------------------------
BLE_CUS_C_ARRAY_DEF(m_ble_cus_c, NRF_SDH_BLE_CENTRAL_LINK_COUNT);       //NOTE NEW FOR CUS
//--------------------------------------
/**@brief NUS UUID. */
static ble_uuid_t const m_nus_uuid =
{
    .uuid = BLE_UUID_NUS_SERVICE,
    .type = NUS_SERVICE_UUID_TYPE
};

static ble_uuid_t const m_cus_uuid =   //NOTE NEW FOR CUS
{
    .uuid = BLE_UUID_CUS_SERVICE,
    .type = BLE_UUID_TYPE_VENDOR_BEGIN+1
};
//--------------------------------------

static void db_disc_handler(ble_db_discovery_evt_t * p_evt)
{
    ble_nus_c_on_db_disc_evt(&amp;amp;m_ble_nus_c[p_evt-&amp;gt;conn_handle], p_evt);
    ble_cus_c_on_db_disc_evt(&amp;amp;m_ble_cus_c[p_evt-&amp;gt;conn_handle], p_evt);    //NOTE NEW FOR CUS
}
//---------------------------------------

//NOTE NEW FOR CUS
static void ble_cus_c_evt_handler(ble_cus_c_t * p_ble_cus_c, ble_cus_c_evt_t const * p_ble_cus_evt)
{
   ret_code_t err_code;

   switch (p_ble_cus_evt-&amp;gt;evt_type)
   {
      case BLE_CUS_C_EVT_DISCOVERY_COMPLETE:
        NRF_LOG_INFO(&amp;quot;CUS Discovery complete.&amp;quot;);
        err_code = ble_cus_c_handles_assign(p_ble_cus_c, p_ble_cus_evt-&amp;gt;conn_handle, &amp;amp;p_ble_cus_evt-&amp;gt;handles);
        APP_ERROR_CHECK(err_code);

        err_code = ble_cus_c_char_notif_enable(p_ble_cus_c);
        APP_ERROR_CHECK(err_code);
        NRF_LOG_INFO(&amp;quot;Connected to device with Custom Service.&amp;quot;);
        break;

      case BLE_CUS_C_EVT_CUS_TX_EVT:      // NOTE The central received data from a peer
       
       
        //NRF_LOG_INFO(&amp;quot;conHandle: 0x%02X&amp;quot;, p_ble_nus_c-&amp;gt;conn_handle);
        connectionHandle = (uint8_t) p_ble_cus_c-&amp;gt;conn_handle;
        connectionLength = (uint8_t) p_ble_cus_evt-&amp;gt;data_len;
        memcpy(connectionData, &amp;amp;p_ble_cus_evt-&amp;gt;p_data[0], (uint8_t) p_ble_cus_evt-&amp;gt;data_len);  

        NRF_LOG_INFO(&amp;quot;DATA RECEIVED: 0x%.2X&amp;quot;, p_ble_cus_evt-&amp;gt;p_data[1]);
        break;

      case BLE_CUS_C_EVT_DISCONNECTED:
        NRF_LOG_INFO(&amp;quot;Disconnected.&amp;quot;);
        scan_start();
        break;
   }
}
//------------------------------------------------------

static void cus_c_init(void)
{
    ret_code_t   err_code;
    ble_cus_c_init_t init;

    init.evt_handler   = ble_cus_c_evt_handler;
    init.error_handler = cus_error_handler;
    init.p_gatt_queue  = &amp;amp;m_ble_gatt_queue;
    for(int c = 0; c &amp;lt; NRF_SDH_BLE_CENTRAL_LINK_COUNT; c++)
    {
        err_code = ble_cus_c_init(&amp;amp;m_ble_cus_c[c], &amp;amp;init);
        APP_ERROR_CHECK(err_code);
    }
}
//--------------------------------------------------------------
    nus_c_init();
    cus_c_init();               //NOTE NEW FOR CUS

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;After both devices are connected I get the following messages from the debugger( central side)&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1713970906777v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;The CUS is discovered by the client which is good but, &lt;/p&gt;
&lt;p&gt;1. In ble_cus_c_handles_assign(), I don&amp;#39;t understand why peer_handles are null&lt;/p&gt;
&lt;p&gt;2. Error 8 is returned from err_code = ble_cus_c_char_notif_enable(p_ble_cus_c); that is called inside the ble_cus_c_evt_handler()&lt;/p&gt;
&lt;p&gt;Any ideas?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52-ble-app-uart-c-multilink - second service discovery and connection</title><link>https://devzone.nordicsemi.com/thread/480159?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 10:40:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53814a9f-b433-4a1a-9364-ce63c1c6667a</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;Alright, great! I am glad to hear that you&amp;#39;re already progressing towards this - dont hesitate to ask if there&amp;#39;s anything! :)&amp;nbsp;&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: nrf52-ble-app-uart-c-multilink - second service discovery and connection</title><link>https://devzone.nordicsemi.com/thread/480142?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 09:10:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41592bbc-31b8-4ece-8923-d51516a4ff5f</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Hi, yes I have already started doing that so I will let you know if I don&amp;#39;t understand something (very likely). So I will leave this ticket open &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52-ble-app-uart-c-multilink - second service discovery and connection</title><link>https://devzone.nordicsemi.com/thread/480139?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 09:05:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1401bfae-db58-41db-8b45-76ddc3866321</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]Now I want my nRF52840 central device to be able to connect to that custom service along with NUS and receive notifications, data etc. Is there some tutorial or guide on how to do that or what additions/changes to perform to the code?[/quote]
&lt;p&gt;Your central device will be able to discover the custom service and characteristic as usual during the discovery, but it will need to know how to interact with the service and characteristic, and as such you must make a file similar to ble_nus_c.c/.h at the&amp;nbsp;&lt;em&gt;nRF5_SDK_17.1.0_ddde560\components\ble\ble_services\ble_nus_c&lt;/em&gt; location to implement this.&lt;br /&gt;Please have a look through these to see how the central side is set up for the NUS service, and use this as a reference for your own customer service central implementation.&lt;br /&gt;Please do not hesitate to ask if you should encounter any issues or questions while working with 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></channel></rss>