<?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>Writing some value into a characteristic of specific UUID of a peripheral device by using a central device</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91075/writing-some-value-into-a-characteristic-of-specific-uuid-of-a-peripheral-device-by-using-a-central-device</link><description>Hey Nordic, 
 My project is based on &amp;quot;ble_app_uart&amp;quot; and &amp;quot;ble_app_uart_c&amp;quot; examples. I modified them to some extent. You can download them from here . 
 
 Normally, I can write some values into any characteristic of my custom service as shown above in nRF</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Aug 2022 12:30:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91075/writing-some-value-into-a-characteristic-of-specific-uuid-of-a-peripheral-device-by-using-a-central-device" /><item><title>RE: Writing some value into a characteristic of specific UUID of a peripheral device by using a central device</title><link>https://devzone.nordicsemi.com/thread/382921?ContentTypeID=1</link><pubDate>Tue, 23 Aug 2022 12:30:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11a69796-55d3-4cbc-9b1b-b802dc4b9c01</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Yes. It is not that obvious. I had to dig around a bit yesterday to find it. It is possible to pass a NULL into the UUID that you are looking for in order to discover all services, but you need to bypass one of the application layers used by the discovery module, because it doesn&amp;#39;t accept the UUID pointer being a null pointer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing some value into a characteristic of specific UUID of a peripheral device by using a central device</title><link>https://devzone.nordicsemi.com/thread/382722?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 14:00:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81dba110-f265-4722-bf0d-244e265f257a</guid><dc:creator>&amp;#214;mer</dc:creator><description>&lt;p&gt;Thanks Edvin,&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t know that I need to register the UUIDs that I am looking for. Now I can see my custom service logged.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Omer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing some value into a characteristic of specific UUID of a peripheral device by using a central device</title><link>https://devzone.nordicsemi.com/thread/382670?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 11:53:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:543bada8-07d2-4374-93c4-30b118f9ccc0</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;What do I do to reproduce your issue? I downloaded both projects, unzipped them in an unmodified SDK17.1.0, and programmed two pca10056 boards. They connect, but the central doesn&amp;#39;t say anything in the log after connecting, other than&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You need to register the UUID that you are looking for the same way that it is done inside ble_nus_c_init() -&amp;gt;&amp;nbsp;ble_db_discovery_evt_register() -&amp;gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing some value into a characteristic of specific UUID of a peripheral device by using a central device</title><link>https://devzone.nordicsemi.com/thread/382299?ContentTypeID=1</link><pubDate>Thu, 18 Aug 2022 13:49:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1008dd0f-14a8-4ae4-801c-cef117aa3120</guid><dc:creator>&amp;#214;mer</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t understand why the files could not be uploaded. There seems no problem on my side. But anyway I will attach them again.&lt;/p&gt;
&lt;p&gt;Based on your suggestion, I deleted all NRF_LOG_FLUSH() calls. I had used them since I had difficulty with using NRF_LOG_INFO(), that is, I can always get a limited amount of logs in J-Link RTT Viewer when I use more logs.&amp;nbsp;I was aware of the dangers but tried to solve the log issue by using it. Unfortunately, it had not worked for me. After setting NRF_LOG_DEFERRED to 0 and&amp;nbsp;NRF_LOG_BUFSIZE from 1024 to 2048, it seems to work better now.&lt;/p&gt;
&lt;p&gt;As you suggest I printed out the event types, this is the log window from J-Link RTT Viewer:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;00&amp;gt; &amp;lt;info&amp;gt; app_timer: RTC: initialized.
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: BLE UART central example started.
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: Discovery complete.
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: ************************
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: p_evt-&amp;gt;evt_type: 0x0
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: srv_uuid.uuid: 0x1
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: srv_uuid.type: 2
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: char_count: 2
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: chars[0].char.uuid.uuid: 0x2
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: chars[1].char.uuid.uuid: 0x3
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: ************************
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: p_evt-&amp;gt;evt_type: 0x3
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: srv_uuid.uuid: 0x2870
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: srv_uuid.type: 0
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: char_count: 0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Actually, this part&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    if(discover_pass &amp;gt; 0)
    {
        discover_pass--;
        return;
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;was to bypass logging of NUS, in case of maybe only the first discovered service is loggable. But I deleted it, as I said before logging seems to be working fine now. I can additionally see a service of event type&amp;nbsp;0x3 as above.&lt;/p&gt;
&lt;p&gt;I examined&amp;nbsp;&lt;span&gt;ble_nus_c_on_db_disc_evt(), and now it seems to me that it has nothing to do with service discovery. Since I can print them using p_evt struct, and it is not edited in this function. It has something to do with only NUS. It doesn&amp;#39;t affect my discovery problem whether I delete it.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_uart_5F00_char_5F00_lorem8182022.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_uart_5F00_char_5F00_lorem8182022.zip&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_uart_5F00_c_5F00_copy.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_uart_5F00_c_5F00_copy.zip&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Edit 1: Actually, what I want to do is exactly this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/44912/scan-filters-for-custom-uuid-is-not-matching/177474"&gt;RE: scan filters for custom uuid is not matching&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But somehow, custom uuid filter doesn&amp;#39;t work, it connects using UUID of NUS.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Omer&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing some value into a characteristic of specific UUID of a peripheral device by using a central device</title><link>https://devzone.nordicsemi.com/thread/382138?ContentTypeID=1</link><pubDate>Thu, 18 Aug 2022 06:49:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb09a003-8938-4cb7-8b8a-5b2a94663f5a</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Omer,&lt;/p&gt;
&lt;p&gt;Sorry, my last snippet was from another SDK. I see now that you are using the nRF5 SDK.&lt;/p&gt;
&lt;p&gt;The mechanism, however, is the same.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="Omer Kati"]I uploaded the project folders into this reply.[/quote]
&lt;p&gt;I believe it wasn&amp;#39;t uploaded.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I see from your sniffer that you have commented out a lot of calls to NRF_LOG_FLUSH(). Please be aware that you must not (!) use NRF_LOG_FLUSH() anywhere but in your main loop, as that may cause undefined behavior. If you struggle with logs being lost, you can set NRF_LOG_DEFERRED to 0 in sdk_config.h, which will process the log on the fly, or you can increase the log buffer in sdk_config.h.&lt;/p&gt;
&lt;p&gt;So regarding the discovery process:&lt;/p&gt;
&lt;p&gt;Please see this description from ble_db_discovery.h:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ble_gatt_db_srv_t   discovered_db;  /**&amp;lt; Structure containing the information about the GATT Database at the server. This will be filled when the event type is @ref BLE_DB_DISCOVERY_COMPLETE. The UUID field of this will be filled when the event type is @ref BLE_DB_DISCOVERY_SRV_NOT_FOUND. */&lt;/pre&gt;The issue is that you don&amp;#39;t check what type of event it is. So if the event type is&amp;nbsp;BLE_DB_DISCOVERY_AVAILABLE, then none of the parameters that you are printing will hold what you think it does (just random RAM data). So you need to check the event type before you start reading out the event specific parameters.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In addition, since you have at least 3 services (from your mobile screenshot), probably 4 services, you probably want to remove the part:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    if(discover_pass &amp;gt; 0)
    {
        discover_pass--;
        return;
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;because or else it will only run the first time, as long as discovery_pass is set to 1. And this is probably not even a BLE_DB_DISCOVERY_COMPLETE event.&lt;/p&gt;
&lt;p&gt;I suggest you look at how the&amp;nbsp;ble_nus_c_on_db_disc_evt() is implemented, and try to do something similar with your custom service.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing some value into a characteristic of specific UUID of a peripheral device by using a central device</title><link>https://devzone.nordicsemi.com/thread/382051?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 13:15:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f4d6c55-2184-4b1e-8df2-c13fb84bbbdd</guid><dc:creator>&amp;#214;mer</dc:creator><description>[quote userid="26071" url="~/f/nordic-q-a/91075/writing-some-value-into-a-characteristic-of-specific-uuid-of-a-peripheral-device-by-using-a-central-device/382027"]gatt_dm[/quote]
&lt;p&gt;I uploaded the project folders into this reply.&lt;/p&gt;
&lt;p&gt;Also, I&amp;nbsp;could find neither&amp;nbsp;bt_gatt_dm_start() function nor&amp;nbsp;&lt;span&gt;gatt_dm.h file in my SDK (v17.1.0).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Actually, there might be a error related to NRF_LOG_INFO() function. The reason is that when I add an if statement before the NRF_LOG_INFO() functions so that it passes the first discovered service without logging as below:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint8_t discover_pass = 1;

/**@brief Function for handling database discovery events.
 *
 * @details This function is a callback function to handle events from the database discovery module.
 *          Depending on the UUIDs that are discovered, this function forwards the events
 *          to their respective services.
 *
 * @param[in] p_event  Pointer to the database discovery event.
 */
static void db_disc_handler(ble_db_discovery_evt_t * p_evt)
{
    uint8_t index = 0;
    ble_nus_c_on_db_disc_evt(&amp;amp;m_ble_nus_c, p_evt);

    //NRF_LOG_INFO(&amp;quot;*&amp;quot;);
    //NRF_LOG_FLUSH();
    if(discover_pass &amp;gt; 0)
    {
        discover_pass--;
        return;
    }

    NRF_LOG_INFO(&amp;quot;srv_uuid.uuid: 0x%x&amp;quot;, p_evt-&amp;gt;params.discovered_db.srv_uuid.uuid);
    //NRF_LOG_FLUSH();

    NRF_LOG_INFO(&amp;quot;srv_uuid.type: %d&amp;quot;, p_evt-&amp;gt;params.discovered_db.srv_uuid.type);
    //NRF_LOG_FLUSH();

    NRF_LOG_INFO(&amp;quot;char_count: %d&amp;quot;, p_evt-&amp;gt;params.discovered_db.char_count);
    //NRF_LOG_FLUSH();

    for(index = 0; index &amp;lt; p_evt-&amp;gt;params.discovered_db.char_count; index++)
    {
        NRF_LOG_INFO(&amp;quot;chars[%d].char.uuid.uuid: 0x%x&amp;quot;, index, p_evt-&amp;gt;params.discovered_db.charateristics[index].characteristic.uuid.uuid);
        //NRF_LOG_FLUSH();
    }

    //NRF_LOG_INFO(&amp;quot;*&amp;quot;);
    //NRF_LOG_FLUSH();
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It prints out a random-like UUID of 0 type and 0 count, instead of my custom characteristics, in J-Link RTT Viewer at the central side:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;00&amp;gt; &amp;lt;info&amp;gt; app_timer: RTC: initialized.
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: BLE UART central example started.
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: Connecting to target 7F0F251956F2
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: ATT MTU exchange completed.
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: Ble NUS max data length set to 0x20(32)
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: Discovery complete.
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: Connected to device with Nordic UART Service.
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: srv_uuid.uuid: 0x2874
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: srv_uuid.type: 0
00&amp;gt; 
00&amp;gt; &amp;lt;info&amp;gt; app: char_count: 0&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks in advance,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Omer&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing some value into a characteristic of specific UUID of a peripheral device by using a central device</title><link>https://devzone.nordicsemi.com/thread/382027?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 12:18:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04b5ae67-2b24-420c-9e0f-b5755cb15afd</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I was not able to download your project through your link.&lt;/p&gt;
&lt;p&gt;Can you please upload it here (drag and drop into the editor when you are writing your reply).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If it only sees the NUS service, I guess you have told it to look for that specifically, using e.g.:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	err = bt_gatt_dm_start(conn,
			       BT_UUID_NUS_SERVICE,
			       &amp;amp;discovery_cb,
			       &amp;amp;nus_client);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Take a look at the declaration (the header file that declares bt_gatt_dm_start() in gatt_dm.h. You either need to call bt_gatt_dm_start() with svc_uuid = NULL, or you need to call it another time with the UUID that you are looking for.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>