<?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>Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/106477/soft-device-scan-parms-not-being-set-correctly-from-struct</link><description>I set my scan params in the following init code. 
 
 
 The interval and scan window are both set to 100. However, when I watch the variables in debug mode, the variables are as follows. 
 
 
 
 Any idea how they are being set so wrong? No other references</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Dec 2023 16:04:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/106477/soft-device-scan-parms-not-being-set-correctly-from-struct" /><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/461488?ContentTypeID=1</link><pubDate>Thu, 21 Dec 2023 16:04:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:457b64aa-9331-4365-99f6-00540ed74f09</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry for revisiting this so close to x-mas, but when you write &amp;quot;I then removed it&amp;quot;, what do you refer to as &amp;quot;it&amp;quot;? It sounds like you added the packed attribute, built the project, removed the packed attribute and then built the project again, and this time it worked?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460442?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2023 22:20:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63b7a2d2-f110-4053-9e47-c774218a4f73</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp;And now it is working. I was able to set the parameters correctly by using the attribute packed onto the struct. I then removed it and was not running into the breakpoint in the soft device anymore. Thanks for the help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460435?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2023 18:47:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17b8e1ff-a267-4e23-8369-c5727db961e2</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp; I made this change to nrf_ble_scan.h line 289 - 306 by adding __attribute__((packed))&lt;/p&gt;
&lt;p&gt;/**@brief Scan module instance. Options for the different scanning modes.&lt;br /&gt; *&lt;br /&gt; * @details This structure stores all module settings. It is used to enable or disable scanning modes&lt;br /&gt; * and to configure filters.&lt;br /&gt; */&lt;br /&gt;typedef struct&lt;br /&gt;{&lt;br /&gt;#if (NRF_BLE_SCAN_FILTER_ENABLE == 1)&lt;br /&gt; nrf_ble_scan_filters_t scan_filters; /**&amp;lt; Filter data. */&lt;br /&gt;#endif&lt;br /&gt; bool connect_if_match; /**&amp;lt; If set to true, the module automatically connects after a filter match or successful identification of a device from the whitelist. */&lt;br /&gt; ble_gap_conn_params_t conn_params; /**&amp;lt; Connection parameters. */&lt;br /&gt; uint8_t conn_cfg_tag; /**&amp;lt; Variable to keep track of what connection settings will be used if a filer match or a whitelist match results in a connection. */&lt;br /&gt; ble_gap_scan_params_t scan_params; /**&amp;lt; GAP scanning parameters. */&lt;br /&gt; nrf_ble_scan_evt_handler_t evt_handler; /**&amp;lt; Handler for the scanning events. Can be initialized as NULL if no handling is implemented in the main application. */&lt;br /&gt; uint8_t scan_buffer_data[NRF_BLE_SCAN_BUFFER]; /**&amp;lt; Buffer where advertising reports will be stored by the SoftDevice. */&lt;br /&gt; ble_data_t scan_buffer; /**&amp;lt; Structure-stored pointer to the buffer where advertising reports will be stored by the SoftDevice. */&lt;br /&gt;} __attribute__((__packed__)) nrf_ble_scan_t;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This allowed the parameters to be set correctly. Now when I call&amp;nbsp;&amp;nbsp;my scan start function&lt;/p&gt;
&lt;p&gt;err_code = nrf_ble_scan_start(&amp;amp;my_scanner);&lt;br /&gt; APP_ERROR_CHECK(err_code);&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The program stops running at an unknown function at 0x00004AAA (which I assume lies somewhere in the Soft Device binary, hence why it is unknown).&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460406?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2023 15:07:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3126c64-6b51-4136-874c-532fde32abb5</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;They are not. Thank you for the current help though! I will continue to work through this today and see if I find any solution &lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460405?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2023 15:05:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:174cce6e-490b-445e-b10b-6febbae12daa</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;And the pointers are now all aligned to four bytes?&lt;/p&gt;
&lt;p&gt;I am afraid there isn&amp;#39;t more time today to look into this, but I will have a closer look at the project tomorrow.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460403?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2023 15:03:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:457d8f69-9366-4dd1-b154-59bd78adf8d7</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That did not work. I am imaging it has to be with addressing. I have it set as such now.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;__ALIGN(4) static ble_gap_scan_params_t const scan_param =&lt;br /&gt;{&lt;br /&gt; .active = 0x01,&lt;br /&gt; .interval = NRF_BLE_SCAN_SCAN_INTERVAL, //=200&lt;br /&gt; .window = NRF_BLE_SCAN_SCAN_WINDOW, // =50&lt;br /&gt; .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL, //BLE_GAP_SCAN_FP_WHITELIST,&lt;br /&gt; .timeout = 0,&lt;br /&gt; .scan_phys = BLE_GAP_PHY_1MBPS, // =1&lt;br /&gt;};&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460402?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2023 14:59:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd999552-9f36-468b-bb85-9787c2c7e49b</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am starting to think this may be a memory alignment issue. Can you try replacing the line with the following?&lt;/p&gt;
&lt;p&gt;&lt;code&gt;__ALIGN(4) ble_gap_scan_params_t const m_scan_param =&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;That is, prefix the line with the &lt;code&gt;__ALIGN(4)&lt;/code&gt; macro. Possibly also for the &lt;code&gt;nrf_ble_scan_init_t init_scan;&lt;/code&gt; line.&lt;/p&gt;
&lt;p&gt;It may actually be as simple as the pointer not being word aligned. I don&amp;#39;t know why this should matter, but something is definitely going on with addressing and word boundaries here, so it should be well worth experimenting with word aligning the data structures.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460229?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2023 20:48:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24dc0b38-e4f0-4bc7-aede-1016c7a935db</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp;Also, weird behavior. The pointer to the scan buffer data is constantly changing addresses.....&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/pastedimage1702500484338v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When I open up the variable to watch, the watch window crashes&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460215?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2023 18:28:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:535a9e23-dae4-4570-a19e-3cdfc3b28379</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;But the scan does not start due to Invalid Params Error being thrown in nrf_ble_scan_start.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When using the &amp;amp;init_scan to set the scan paramters, everything is offset by 2 bytes. The address of m_scan.scan_params starts at 0x20004992, but from that address to 0x20004993 is never written to which is where scan_params.extended, report incomplete, active, filter policy,&amp;nbsp;and scan_phys. The value I have for extended, report incomplete, active and filter policy (which are bits 0-3 of the first byte are 0x04) and scan_phys is 0x01. The value written to interval is 0x0104 which shows these bits getting put in the wrong address. The interval hex value is 0xc8 (Which I have set my define value to 200). This value is being written to the window address. This continues on for the window&amp;nbsp;which is set to the define value for interval and the timeout value is set as the define for the window. What could be causing those first two addresses to not being written to?&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/pastedimage1702493699395v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&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/pastedimage1702493685171v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is also causing garbage data to appear in the first 4 bytes of my scan buffer data array, making the first values to start at scan_buffer_data[4]&amp;nbsp; vs scan_buffer_data[0]. I hope you can access the project in the private case to maybe find what could be happening?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460213?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2023 18:18:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebc82923-7390-411a-b053-ba5a5f191c36</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp; If i set the scan parameters like this&amp;nbsp;&amp;nbsp; &amp;nbsp; m_scan.scan_params = scan_param; They set correctly...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460205?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2023 17:28:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cae0bd8d-47f7-4fd7-8e70-6873111e4388</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp; I have opened a private case fyi and reference this case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460202?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2023 17:06:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25aeed0b-4cbf-456b-8297-761b1f325c97</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="inspiringdev123"]I advertise with my module for 1 minute in the beginning of the program. Could this possibly be affecting the scanning parameters?[/quote]
&lt;p&gt;It could be related somehow to what you see, yes. Can you share (a minimal version of) the project for reproducing / investigating?&lt;/p&gt;
[quote user="inspiringdev123"]&amp;nbsp;I even passed in NULL for the scan parameters to set them to the default configuration and it is still setting them 0x6401 and 0x6400...[/quote]
&lt;p&gt;Something is definitely not acting right there, then. I am afraid we do need the project for reproducing this behavior. If you cannot share anything in the open then please create a new case, refer to this one, and add the project there. Preferably the project is stripped down to only containing the parts needed for reproducing the issue.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/460023?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 22:41:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:076f318c-fa66-49ae-9e25-650b5ae386a7</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp; My interval I want is being set as the window and my set window is being set as the timeout. The interval has been stuck at 0x0104 for the past two days.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/459977?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2023 15:49:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59b5d9d8-d72f-4edc-a894-bc74abb674e7</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp;I even passed in NULL for the scan parameters to set them to the default configuration and it is still setting them 0x6401 and 0x6400...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/459776?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 19:17:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c0f1619-677f-4c3c-8843-8c8d8c247533</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;Even in the example it was not a static struct..&lt;/p&gt;
&lt;p&gt;&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/pastedimage1702322257820v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But changing it does nothing different&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/459775?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 19:16:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a401ef4-c400-4355-8620-9586e826f4df</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;This is from the ble_app_multilink_central example from sdk17.0.2.&lt;/p&gt;
&lt;p&gt;&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/pastedimage1702322205426v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/459774?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 19:14:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4edc10b-3d66-4d53-b5bb-927ef4694d01</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;Here are how they are set in my sdk config file.&lt;/p&gt;
&lt;p&gt;&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/pastedimage1702322026171v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;That seemed very suspicious to me as well since they were 0x0064 in my other code.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/459773?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 19:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8f51e61-ca34-4f78-a74b-847a3ff88874</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Are you sure that you are looking at the correct struct, in the debug view?&lt;/p&gt;
&lt;p&gt;What are the values of the parameters you set? (NRF_BLE_SCAN_SCAN_INTERVAL, NRF_BLE_SCAN_SCAN_WINDOW, etc.)&lt;/p&gt;
&lt;p&gt;Interval and window of 0x6401 and 0x6400 look a bit suspicious to me, typically one would set them to the same if one wants 100 % duty cycle.&lt;/p&gt;
&lt;p&gt;Do you see the same values when using the code example from the documentation, as you did with your values earlier?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/459772?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 19:07:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d67dec9-c693-4cd6-8d5e-7b7bec514126</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp;I advertise with my module for 1 minute in the beginning of the program. Could this possibly be affecting the scanning parameters? I was able to set the parameters successfully in a standalone program, but are now having issues when merging with existing advertising code.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/459770?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 19:02:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:937c801a-9d0f-4a45-a3dd-dd845340fc11</guid><dc:creator>inspiringdev123</dc:creator><description>&lt;p&gt;I changed it to a static and still no luck. I copied over the strict from the working example.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Soft Device Scan Parms not being set correctly from struct</title><link>https://devzone.nordicsemi.com/thread/459768?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 18:59:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e023e7a8-8f82-43fe-a5d7-cc60e796a1fd</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]Any idea how they are being set so wrong? No other references to these variables in the code anywhere except here and when I start scanning following the advertising period ending (60 seconds).[/quote]
&lt;p&gt;You should use a static variable for the ble_gap_scan_params_t structure used for the p_scan_param pointer in the p_init argument to nrf_ble_scan_init().&lt;/p&gt;
&lt;p&gt;In your implementation, the variable is not static, so when your function scan_init() returns the pointer points to a location in stack memory that will later be overwritten by the local variables of other functions.&lt;/p&gt;
&lt;p&gt;For an example of working initialization with custom scan parameters, see the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Flib_ble_scan.html&amp;amp;anchor=scan_usage_advanced_init"&gt;Advanced initialization&lt;/a&gt; section of the Scanning Module documentation.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>