<?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>Longer BLE Device name</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72943/longer-ble-device-name</link><description>I&amp;#39;m using NCS v1.5.0 to create a BLE peripheral using nRF5340-DK. 
 I set the device name in the prj.conf file using CONFIG_BT_DEVICE_NAME and the name shows up when BLE advertising starts (using LightBlue to monitor). 
 But the device name seems to be</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 19 Mar 2021 08:02:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72943/longer-ble-device-name" /><item><title>RE: Longer BLE Device name</title><link>https://devzone.nordicsemi.com/thread/300828?ContentTypeID=1</link><pubDate>Fri, 19 Mar 2021 08:02:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b55c0c9-7a2d-419b-9d2e-885b69a32fe8</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi again&lt;/p&gt;
&lt;p&gt;I see, I didn&amp;#39;t realize this was the case in NCS, so&amp;nbsp; I should thank you for sharing this detailed explanation. I agree that this makes sense upon a closer look at the hci_core.c. Your advertising data seems to be correct as well! Great work!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Longer BLE Device name</title><link>https://devzone.nordicsemi.com/thread/300769?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 17:23:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b74babf-1574-4676-870b-93004c21ba19</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&lt;/p&gt;
&lt;p&gt;I think my advertising data is less than 24 bytes.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
static const struct bt_data ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
#if 1
        BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
#endif
#if 0
	BT_DATA_BYTES(BT_DATA_UUID16_ALL,
		      BT_UUID_16_ENCODE(BT_UUID_HRS_VAL),
		      BT_UUID_16_ENCODE(BT_UUID_BAS_VAL),
		      BT_UUID_16_ENCODE(BT_UUID_DIS_VAL)
                     )
#endif
};

static const struct bt_data sd[] = {
	BT_DATA_BYTES(BT_DATA_UUID128_ALL, UUID_DXTER_BASE, UUID_DXTER_STETH_SERVICE),
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Discounting the lines removed by #if 0, The advertising data should only be the FLAGS and the device name.&amp;nbsp; &amp;nbsp;The device name length is 21 bytes.&lt;/p&gt;
&lt;p&gt;I send the 128-bit UUID as scan data.&lt;/p&gt;
&lt;p&gt;Here is the call to start advertising:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	err = bt_le_adv_start(BT_LE_ADV_CONN_NAME,
                                 ad, ARRAY_SIZE(ad),
                                 sd, ARRAY_SIZE(sd));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Stepping through the code, the advertising data is &amp;quot;updated&amp;quot; in hci_core.c&amp;nbsp; at the call to le_adv_update() (line 7880).&amp;nbsp; If &amp;quot;use_name&amp;quot; is true (and it is),&amp;nbsp; the ad[] array is checked (via ad_has_name) to see if a name parameter has been sent in.&amp;nbsp; Since it has (via the BT_DATA_NAME_COMPLETE in the ad[1] item, it returns true, which causes the error.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It seemed that the very data that should be being copied into the advertising data (around line 7899 of hci_core.c), is causing the error that aborts the advertising update.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I then realized that &amp;quot;use_name&amp;quot; doesn&amp;#39;t mean to use the name in the ad[] array...&amp;nbsp; &amp;nbsp; &amp;nbsp;So I changed the Flag in the bt_le_adv_start call to BT_LE_ADV_CONN and the full name appears.&lt;/p&gt;
&lt;p&gt;So it looks like if you use BT_LE_ADV_CONN_NAME with another name in ad[], an error&amp;nbsp; occurs, and if you use BT_LE_ADV_CONN with a name in ad[], it uses the full name (assume BT_DATA_NAME_COMPLETE),&amp;nbsp; &amp;nbsp;But it also appears that if you use BT_LE_ADV_CONN with no name in ad[], the full name also appears (extracted from CONFIG_BT_DEVICE_NAME) and if you use BT_LE_ADV_CONN_NAME with no name in ad[] a truncated name appears.&lt;/p&gt;
&lt;p&gt;A bit confusing, but seems to make sense after reading through the actual hci_core.c code...&lt;/p&gt;
&lt;p&gt;Thanks...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Longer BLE Device name</title><link>https://devzone.nordicsemi.com/thread/300662?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 12:37:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5cae906-b97f-4e6a-8e8b-da2b236031f3</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;What else is included in your advertisements? Please note that the BLE spec. only allows up to a total of 31 bytes per advertisements, where 2 bytes are overhead. If you have I.E. a UUID and/or TX power in your advertisement packet as well that usually causes the advertising name to be shortened. How many bytes does your advertisement packet include if you exclude the device name? If the advertisement exceeds 31 bytes I&amp;nbsp;would suggest putting either device name or the UUID (or similar) in a scan response packet instead, which is done in t&lt;a href="https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/ncs-ble-tutorial-part-1-custom-service-in-peripheral-role"&gt;he guide by Håkon&lt;/a&gt; as well.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>