<?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>Zephyr BLE example advertise not working.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/97497/zephyr-ble-example-advertise-not-working</link><description>Hi, 
 
 I am working on creating an example for BLE application where I try to start the advertising of BLE device. I have seen other example in the folder bluetooth/peripharal which works fine and device can advertise itself. The following is the code</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Mar 2023 03:04:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/97497/zephyr-ble-example-advertise-not-working" /><item><title>RE: Zephyr BLE example advertise not working.</title><link>https://devzone.nordicsemi.com/thread/415352?ContentTypeID=1</link><pubDate>Wed, 15 Mar 2023 03:04:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f0de1a9-c1e2-437f-8fde-1605aa483ecd</guid><dc:creator>SvenDufva</dc:creator><description>&lt;p&gt;This issue might solve the issue for you&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/72943/longer-ble-device-name"&gt;Longer BLE Device name&lt;/a&gt;&amp;nbsp;. I was fighting with similar (or the same issue) and by changing&amp;nbsp;&amp;nbsp;BT_LE_ADV_CONN_NAME into&amp;nbsp;BT_LE_ADV_CONN allowed me to add the name into advertisement. Before that I would only be able to add GUID in there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr BLE example advertise not working.</title><link>https://devzone.nordicsemi.com/thread/415211?ContentTypeID=1</link><pubDate>Tue, 14 Mar 2023 12:52:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e8179d8-99f0-4d65-b110-af6fa6d8c9f6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;You can look up most error codes in errno.h (zephyr\lib\libc\armstdc\include\errno.h). -22 refers to EINVAL&amp;nbsp; - Invalid argument.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know what your &amp;quot;ad&amp;quot; parameter looks like, but I see that the advertising name that you are trying to use is very (!) long. 34 characters. Since the length of the advertising packet is 31 bytes, that will not work. Try something a lot shorter. Perhaps &amp;quot;test_name&amp;quot; for testing purposes. You can experiment with the length of the name that you can use. Actually, the length that you can fit depends on what else you have in your advertising packet, and how many bytes that is.&amp;nbsp;&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: Zephyr BLE example advertise not working.</title><link>https://devzone.nordicsemi.com/thread/415153?ContentTypeID=1</link><pubDate>Tue, 14 Mar 2023 11:42:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6af9c1c-e7d4-4cbc-b5dd-b628cb87064b</guid><dc:creator>ujur007</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The error code is -22 which means &amp;quot;Zero on success or (negative) error code otherwise&amp;quot; according to documentation.&lt;/p&gt;
&lt;p&gt;Yes, I am using the nRF5340-DK board. I have not tested peripheral-uart sample but I have tested some other peripheral samples which works fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr BLE example advertise not working.</title><link>https://devzone.nordicsemi.com/thread/414852?ContentTypeID=1</link><pubDate>Mon, 13 Mar 2023 10:18:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76dfadf2-a69f-4a7b-9448-e878c35cb7d7</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Try to replace your log about advertising not starting with this:&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));

    if(err) {
    printk(&amp;quot;Advertise did not start. bt_le_adv_start returned %d \n&amp;quot;, err);
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;What does the log say then?&lt;/p&gt;
&lt;p&gt;Are you using an nRF5340 DK, or is it a custom board? Do the standard samples, such as peripheral_uart work?&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: Zephyr BLE example advertise not working.</title><link>https://devzone.nordicsemi.com/thread/414725?ContentTypeID=1</link><pubDate>Fri, 10 Mar 2023 17:05:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5bab91c-3f75-4a3f-9e2c-190eee9a1e69</guid><dc:creator>ujur007</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The calls are all executed. I can see that in log.&lt;/p&gt;
&lt;p&gt;And also that it prints.&lt;/p&gt;
&lt;p&gt;&amp;quot;Advertise did not start..&amp;quot; So the problem must be in advertising call. &lt;/p&gt;
&lt;p&gt;Here is other part of my code.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static const struct bt_data ad[] ={
    BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
	BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN)
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void connected(struct bt_conn *connected, uint8_t err)
{
	if (err) {
		//LOG_ERR(&amp;quot;Connection failed (err %u)&amp;quot;, err);
	} else {
		
		if (!conn) {
			conn = bt_conn_ref(connected);
		}
	}
}

static void disconnected(struct bt_conn *disconn, uint8_t reason)
{
	if (conn) {
		bt_conn_unref(conn);
		conn = NULL;
	}	
}

/* Set Scan Response data */

static const struct bt_data sd[] = {

	BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),

};



BT_CONN_CB_DEFINE(conn_callbacks) = {
	.connected = connected,
	.disconnected = disconnected,
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tried to remove the GPIO interrupt related things completely to see weather that can help but it did not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr BLE example advertise not working.</title><link>https://devzone.nordicsemi.com/thread/414697?ContentTypeID=1</link><pubDate>Fri, 10 Mar 2023 14:51:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84adfaaa-74fd-433e-85db-95782d314625</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Do you see the log output? What does it say? And perhaps try to add a line of logging after bt_ready() so that you know that this is reached, and that you didn&amp;#39;t encounter any errors before that.&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>