<?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>Wi-Fi Fundamentals Course - Lesson 2, Exercise 2 fix for BSSID</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112899/wi-fi-fundamentals-course---lesson-2-exercise-2-fix-for-bssid</link><description>In the Wi-Fi Fundamentals Course, Lesson 2, Exercise 2 (step 7.2) I found that it is necessary to clear the bssid parameter in the wifi_connect_req_params structure. If it is not cleared and happens to have a non-zero value, then the Wi-Fi stack will</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Jul 2024 11:31:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112899/wi-fi-fundamentals-course---lesson-2-exercise-2-fix-for-bssid" /><item><title>RE: Wi-Fi Fundamentals Course - Lesson 2, Exercise 2 fix for BSSID</title><link>https://devzone.nordicsemi.com/thread/494332?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2024 11:31:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a51a639-b0c5-4b21-a3f3-d0f7f8ef959a</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Ah yes. Thanks for the feedback! &lt;a href="https://github.com/NordicDeveloperAcademy/wifi-fund/commit/b1870d2dc7648a26cb1e0fcbf85f2f9619154b70"&gt;This has now been fixed here&lt;/a&gt;, and in the&amp;nbsp;&lt;span&gt;&lt;span dir="ltr"&gt;exercise steps.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&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/pastedimage1721215879799v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Regards,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Elfving&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wi-Fi Fundamentals Course - Lesson 2, Exercise 2 fix for BSSID</title><link>https://devzone.nordicsemi.com/thread/493691?ContentTypeID=1</link><pubDate>Fri, 12 Jul 2024 15:53:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ee8a1b4-3f50-4b31-9f8f-47b2e220caf1</guid><dc:creator>Saxman58</dc:creator><description>&lt;p&gt;Agreed.&amp;nbsp;&amp;nbsp;And that is the problem.&amp;nbsp; From my understanding of C initialization, only static and global structs are guaranteed to get initialized to zero automatically.&amp;nbsp; But the `cnx_params` structure in the main() function is not static or global, so it can have random trash in it unless explicitly initialized.&amp;nbsp; So since the code in the lesson didn&amp;#39;t set the bssid&amp;nbsp;member, it might not be zero, as I saw in my application.&amp;nbsp; So then the network stack thinks you want to only connect to that random BSSID, and it will fail.&lt;br /&gt;&lt;br /&gt;So to prevent problems, either the bssid structure member needs to be explicitly set to 0, or the whole structure can be initialized to zero in main() with:&lt;br /&gt;&lt;br /&gt;&lt;span class="token keyword"&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="token class-name"&gt;wifi_connect_req_params&lt;/span&gt;&lt;span&gt; cnx_params = { 0 }&lt;/span&gt;&lt;span class="token punctuation"&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="token punctuation"&gt;These code examples make it more clear.&amp;nbsp; The first shows what is in the uninitialized cnx_params as written in the course.&amp;nbsp; As you can see, the cnx_struct is filled with whatever random stuff is in RAM, and the bssid has a non-zero value, meaning that the lesson code can fail to connect to this random BSSID:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
	struct wifi_connect_req_params cnx_params;
	LOG_HEXDUMP_WRN(&amp;amp;cnx_params, sizeof(cnx_params), &amp;quot;Uninitialized cnx_params in main():&amp;quot;);
	LOG_HEXDUMP_INF(&amp;amp;cnx_params.bssid, sizeof(cnx_params.bssid), &amp;quot;cnx_params.bssid:&amp;quot;);
&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="token punctuation"&gt;This gives the following output:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="token punctuation"&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:00.657,226] &amp;lt;wrn&amp;gt; coex: Uninitialized wifi_connect_req_params in main():
                               a9 0b 00 00 68 d1 01 20  33 f1 01 00 e7 03 00 00 |....h..  3.......
                               00 00 00 00 90 1c 00 20  68 a3 00 20 00 10 00 00 |.......  h.. ....
                               7b 71 04 00                                      |{q..             
[00:00:00.657,226] &amp;lt;inf&amp;gt; coex: cnx_params.bssid:
                               a3 00 20 00 10 00                                |.. ...           
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="token punctuation"&gt;But if the code explicitly fills the struct with 0&amp;#39;s, then the bssid and all other members will be guaranteed to be 0 to start:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="token punctuation"&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
	struct wifi_connect_req_params cnx_params2 = {0};
	LOG_HEXDUMP_WRN(&amp;amp;cnx_params2, sizeof(cnx_params2), &amp;quot;Initialized cnx_params2 in main():&amp;quot;);
	LOG_HEXDUMP_INF(&amp;amp;cnx_params2.bssid, sizeof(cnx_params2.bssid), &amp;quot;cnx_params2.bssid:&amp;quot;);
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="token punctuation"&gt;...as you can see below:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="token punctuation"&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:00.660,339] &amp;lt;wrn&amp;gt; coex: Initialized cnx_params2 in main():
                               00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |........ ........
                               00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |........ ........
                               00 00 00 00                                      |....             
[00:00:00.660,369] &amp;lt;inf&amp;gt; coex: cnx_params2.bssid:
                               00 00 00 00 00 00                                |......           
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wi-Fi Fundamentals Course - Lesson 2, Exercise 2 fix for BSSID</title><link>https://devzone.nordicsemi.com/thread/493665?ContentTypeID=1</link><pubDate>Fri, 12 Jul 2024 14:15:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:267d8550-a445-4a69-8011-c3fd5dd35dac</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;I&amp;#39;ve had a talk with the team responsible now and they say that the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span dir="ltr"&gt;solution is correct. If BSSID is specified, then only that network is chosen.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Regards,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Elfving&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wi-Fi Fundamentals Course - Lesson 2, Exercise 2 fix for BSSID</title><link>https://devzone.nordicsemi.com/thread/493506?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2024 17:57:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58189e42-312e-4015-bd14-582b3840062a</guid><dc:creator>Saxman58</dc:creator><description>&lt;p&gt;HI Elfving.&lt;br /&gt;&lt;br /&gt;I am using NCS v2.6.1.&lt;br /&gt;&lt;br /&gt;I went through the library code and found the point where it checks if the bssid is non-zero, and then uses that as criteria for finding a matching Access Point.&lt;br /&gt;&lt;br /&gt;I don&amp;#39;t know if this matters, but I have four AP&amp;#39;s on my network (two dual channel APs) so the library code finds the list from the scan and then has additional logic to pick which one to connect to.&amp;nbsp; But it looked to me like the code uses the&amp;nbsp;BSSID as an additional filter, so whether there were several or just one APs that had the right SSID, a non-zero BSSID makes it only match to an AP with that MAC address.&amp;nbsp; So if the passed bssid is just random uninitialized bits then it will not match anything.&lt;/p&gt;
&lt;p&gt;Glen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wi-Fi Fundamentals Course - Lesson 2, Exercise 2 fix for BSSID</title><link>https://devzone.nordicsemi.com/thread/493425?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2024 12:45:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:552f2821-a732-43bb-ac9b-ec0a03ddc17a</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hi Glen,&lt;/p&gt;
&lt;p&gt;Thanks for the suggestion. I&amp;#39;ve forwarded this to the team responsible for this course.&lt;/p&gt;
&lt;p&gt;What NCS version are you using when seeing this issue btw?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>