<?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>Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104293/restarting-bluetooth-on-zephyr</link><description>Hello 
 I have an application that uses BT and mesh. The BT uses extended advertising set 
 At periodic intervals I need to shut down BT and mesh and start them again sometime later 
 My flow is as follows 
 Init 
 bt_enable() 
 bt_mesh_init() 
 
 bt_le_ext_adv_create</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 06 Oct 2023 14:00:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104293/restarting-bluetooth-on-zephyr" /><item><title>RE: Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/thread/449198?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2023 14:00:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ee8acb1-5cf8-4f04-b0f0-6836661a6e58</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Andy,&amp;nbsp;&lt;br /&gt;I would suggest to try measuring the current consumption&amp;nbsp;on a&amp;nbsp;Dev Kit as the reference. You may turn off extra peripheral and only focus on testing with BLE.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I don&amp;#39;t think accelerometer and temp sensor would have such a high peak current.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/thread/449190?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2023 13:42:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aeddb75e-33d9-4777-9f89-f191d2e1e035</guid><dc:creator>AndyM</dc:creator><description>&lt;p&gt;Yes, &lt;span&gt;CONFIG_SERIAL&amp;nbsp;&lt;/span&gt;is set to &amp;quot;n&amp;quot;&lt;/p&gt;
&lt;p&gt;There are a couple of peripherals on the board that I have not yet&amp;nbsp;added support for&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. Accelerometer&lt;/p&gt;
&lt;p&gt;2. Temp sensor&lt;/p&gt;
&lt;p&gt;So at the moment it&amp;#39;s not known what state those devices are in&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In active mode the device has mesh enabled and does periodic publishing on a vendor model&lt;/p&gt;
&lt;p&gt;Probably should get those devices working first, then re-measure. I&amp;#39;ll try the sample you mentioned too&lt;/p&gt;
&lt;p&gt;Thank you&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/thread/449128?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2023 08:12:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:779b7a6f-4294-41eb-9203-abf974f9b8c6</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Andy,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes I agree that closing bt stack wouldn&amp;#39;t help much in this case.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;450mA when&amp;nbsp; idle is quite high. Have you checked if you turned off serial log ? (CONFIG_SERIAL=n)&lt;/p&gt;
&lt;p&gt;Also you have peak current of 60mA, this is quite high for our chip. Is it the current draw by only the nRF52840 or also some peripherals that you are using ?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Have you tried to test some simple application to see if you can get down to a few uA&amp;nbsp; when idle ? I would suggest to try the peripheral_lbs with prj_minimal.conf configuration.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/thread/449101?ContentTypeID=1</link><pubDate>Thu, 05 Oct 2023 23:45:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4ff2292-1c8f-4f68-9964-b38f3f48ce39</guid><dc:creator>AndyM</dc:creator><description>&lt;p&gt;No I didn&amp;#39;t solve it but I think the reason.is that the mesh stack assumes that the BT is available and if the BT driver is closed and reopened it is not happy about it There is no public &amp;quot;deinit&amp;quot; function and calling bt_mesh_init multiple times will not work for the reasons outlined above. So I&amp;#39;m going to stick to mesh suspend for now and not close the BT driver. That works fine&lt;br /&gt;Here is the screenshot from the profiler with mesh suspended, and the app not doing anything&lt;br /&gt;As you can see it&amp;#39;s pretty high. Any ideas where to look for additional savings?&lt;br /&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/pastedimage1696549191630v2.png" alt=" " /&gt;&lt;br /&gt;Here is the device in active mode. It registers a callback with the mesh scanner and uses NRF DM library when active ( which I suspect is a huge current draw).&amp;nbsp;&lt;br /&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/pastedimage1696549343391v3.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/thread/449010?ContentTypeID=1</link><pubDate>Thu, 05 Oct 2023 12:51:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7eec4ca9-6d62-46bd-9051-0c3284d21d8e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Andy,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Have you solved the problem &amp;quot;mesh advertising fails to start&amp;nbsp;&amp;quot; ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;What&amp;#39;s the current consumption you are seeing after you suspend mesh ? When there is no radio activity and there is no active thread, the current consumption should be in the range of a few uA.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If you set the GPIO to high but you don&amp;#39;t draw current from there it should not cause more power consumption.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/thread/448901?ContentTypeID=1</link><pubDate>Wed, 04 Oct 2023 23:13:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1ef30d6-f8f8-47af-ba11-a32413f580bf</guid><dc:creator>AndyM</dc:creator><description>&lt;p&gt;Well I tried.&lt;/p&gt;
&lt;p&gt;Initializing mesh more than once is not possible due to the BT_MESH_INIT flag and clearing it is not possible because&amp;nbsp;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; bt_mesh_net is a private data structure and I don&amp;#39;t have access to it from the application.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I can safely suspend and resume mesh,that will have to do for now. Generally you&amp;#39;d think if mesh is suspended i.e no advertising or scanning takes place and the application is not explicitly scanning or advertising and doesn&amp;#39;t have any active threads, shouldn&amp;#39;t the MCU&amp;nbsp; enter sleep mode? My ultimate goal is to reduce current draw in idle state. My board does not have UART and RTT logging is not enabled in the build. Anything else you can think of to reduce the current draw in idle mode? I do have 2 GPIO pins set active high - perhaps they should be disabled&amp;nbsp; while in sleep mode?&amp;nbsp;&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;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/thread/448844?ContentTypeID=1</link><pubDate>Wed, 04 Oct 2023 14:01:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d697dd51-38dc-4461-91a8-2a4b99118e0b</guid><dc:creator>AndyM</dc:creator><description>&lt;p&gt;I have 2 concerns&lt;/p&gt;
&lt;p&gt;1. At the top of bt_mesh_init function is a check if it&amp;#39;s already initialized in which case it returns -EALREADY. Suppose I could find a way to clear&amp;nbsp;BT_MESH_INIT bit in&amp;nbsp;bt_mesh.flags (which is a private variable so I&amp;#39;m doubtul)&lt;/p&gt;
&lt;p&gt;2.Mesh stack allocates memory and calling bt_mesh_init and calling it repeatedly&amp;nbsp; I&amp;#39;ll eventually run out&amp;nbsp; of memory&lt;/p&gt;
&lt;p&gt;Generally since there is no &amp;quot;mesh_deinit&amp;quot; function it appears that the Zephyr mesh stack is designed to be started once and never shut down&lt;/p&gt;
&lt;div&gt;I&amp;#39;ll give it a try and let you know&lt;/div&gt;
&lt;div&gt;Thank you&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/thread/448604?ContentTypeID=1</link><pubDate>Tue, 03 Oct 2023 09:23:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:350d9c91-92ed-494e-9ea5-ab5530a211d5</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Andy,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You are right, when you call&amp;nbsp;&lt;span&gt;bt_enable() with NULL in the argument it will be a blocking function.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;m not so sure if you can call&amp;nbsp;bt_mesh_suspend() after you disable ble.&amp;nbsp;&lt;br /&gt;Have&amp;nbsp;you tried calling&amp;nbsp;&lt;/span&gt;bt_mesh_init() again ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/thread/448552?ContentTypeID=1</link><pubDate>Mon, 02 Oct 2023 14:56:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05160089-297c-439c-932d-c399e33eda82</guid><dc:creator>AndyM</dc:creator><description>&lt;p&gt;I&amp;#39;m using a synchronous variant of&amp;nbsp;&lt;/p&gt;
&lt;p&gt;bt_enable i.e bt_enable(NULL) - my understanding was that it&amp;#39;s a blocking function and only returns when the stack is ready.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Actually there was a problem in my code that led to the crash -&amp;nbsp; the ext_adv_data is a pointer but I was treating it as a structure i.e deleting the address of it. That I fixed the crash but there is another problem - mesh advertising fails to start (see below) . Any ideas why?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Here is the log after bt_enable() is called&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;SoftDevice started&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;00&amp;gt; [00:12:03.656,097] &amp;lt;inf&amp;gt; bt_sdc_hci_driver: SoftDevice Controller build revision: &lt;br /&gt;00&amp;gt; e0 7e 2e c1 5e 05 85 23 46 15 dc fa 8e 29 7d 70 |.~..^..# F....)}p&lt;br /&gt;00&amp;gt; 10 93 a5 fc |.... &lt;br /&gt;00&amp;gt; [00:12:03.658,843] &amp;lt;inf&amp;gt; bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)&lt;br /&gt;00&amp;gt; [00:12:03.658,874] &amp;lt;inf&amp;gt; bt_hci_core: HW Variant: nRF52x (0x0002)&lt;br /&gt;00&amp;gt; [00:12:03.658,905] &amp;lt;inf&amp;gt; bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 224.11902 Build 2231721665&lt;br /&gt;00&amp;gt; [00:12:03.659,393] &amp;lt;inf&amp;gt; bt_hci_core: Identity: F3:D9:70:CC:45:F4 (random)&lt;br /&gt;00&amp;gt; [00:12:03.659,423] &amp;lt;inf&amp;gt; bt_hci_core: HCI: version 5.4 (0x0d) revision 0x1077, manufacturer 0x0059&lt;br /&gt;00&amp;gt; [00:12:03.659,484] &amp;lt;inf&amp;gt; bt_hci_core: LMP: version 5.4 (0x0d) subver 0x1077&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;br /&gt;00&amp;gt; [00:12:03.659,515] &amp;lt;dbg&amp;gt; bt_utils_c: btu_bt_ready: BT enabled:OK&lt;strong&gt; &amp;lt;-- this is my function that is called when bt_enable() returns&lt;/strong&gt;&lt;br /&gt;00&amp;gt; [00:12:03.660,858] &amp;lt;dbg&amp;gt; bt_utils_c: btu_bt_ready: Mesh network resumed &lt;strong&gt;&amp;lt;--it calls bt_mesh_resume()&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;00&amp;gt; [00:12:03.661,193] &amp;lt;wrn&amp;gt; bt_hci_core: opcode 0x2037 status 0x42&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;00&amp;gt; [00:12:03.661,224] &amp;lt;err&amp;gt; bt_mesh_adv_ext: Failed setting adv data: -5&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Restarting bluetooth on Zephyr</title><link>https://devzone.nordicsemi.com/thread/448490?ContentTypeID=1</link><pubDate>Mon, 02 Oct 2023 11:18:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af1559e6-6b5d-440c-83b9-e683152558c4</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Andy,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you set a semaphore after you call&amp;nbsp;&lt;span&gt;bt_enable() to wait for the BLE stack to be ready before you call&amp;nbsp;bt_le_ext_adv_create() ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;Command opcode 0x2037 is&amp;nbsp;&lt;/span&gt;BT_HCI_OP_LE_SET_EXT_ADV_DATA. It seems that there is a timeout after calling this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>