<?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>require websocket and https combine example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116309/require-websocket-and-https-combine-example</link><description>Hi, 
 I am using SDK v2.6.1. 
 Is there any course available on DevAcademy for WebSockets? 
 For WebSocket i take reference of v2.6.1/zephyr/samples/net/sockets/websocket_client, 
 when i try to give wifi credential using wifi connect -s &amp;lt;ssid&amp;gt; -k 1 </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 10 Dec 2024 15:26:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116309/require-websocket-and-https-combine-example" /><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/514323?ContentTypeID=1</link><pubDate>Tue, 10 Dec 2024 15:26:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5986c066-ab7a-4924-bb65-7268de8b561e</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;I am not sure if this is what you look for, but here is the link to&amp;nbsp;&lt;a href="https://websocket.org/tools/websocket-echo-server/"&gt;websocket echo server&lt;/a&gt;&amp;nbsp;which can be used for testing websocket clients.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/513944?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2024 03:54:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40fbb332-5a90-41c2-9ed9-8fbe8e6affc0</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;can you please suggest open URL without credential for websocket so we can try with it and try to solve the problem.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/513409?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2024 12:17:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ac22ee8-5d7e-458d-9fd8-ae58f91f0613</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;We also have a course where sockets are explained. You can look at the&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/wi-fi-fundamentals/lessons/lesson-3-wifi-fundamentals/"&gt;lesson 3&lt;/a&gt;&amp;nbsp;of our&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/wi-fi-fundamentals/"&gt;Wi-Fi Fundamentals&lt;/a&gt;&amp;nbsp;DevAcademy course.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/513193?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2024 12:17:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33d21c88-5852-4b11-9044-82834cdcfc98</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Your interface seems to go into monitor mode, but NetworkManager overrirdes this configuration because it claims all network interfaces by default. As a workaround, you can manually set $DEVICE as unmanaged for the current session&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;sudo nmcli device set $DEVICE managed no&lt;/pre&gt;&lt;br /&gt;Afterwards, you need to install Wireshark and start monitor mode capture.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/513102?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2024 04:31:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2544de96-01aa-40a4-9e4a-b0fc34d1ec7c</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have received the output below. Please provide a solution as soon as possible, as we have a client delivery deadline.&lt;/p&gt;
&lt;p&gt;We greatly appreciate your support.&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/Screenshot-from-2024_2D00_12_2D00_03-09_2D00_57_2D00_18.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/512992?ContentTypeID=1</link><pubDate>Mon, 02 Dec 2024 13:53:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:024750c7-7883-49ae-904d-e554117daa9c</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;You can enable wi-fi monitor mode by for example following this&amp;nbsp;&lt;a href="https://www.geeksforgeeks.org/how-to-put-wifi-interface-into-monitor-mode-in-linux/"&gt;link&lt;/a&gt;.&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;sudo iw dev
sudo ip link set wlp1s0 down
sudo iw wlp1s0 set monitor none
sudo ip link set wlp1s0 up
sudo iw dev wlp1s0 set channel 1
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can also look at our&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/wifi/monitor/README.html"&gt;Wi-Fi monitor sample&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/512757?ContentTypeID=1</link><pubDate>Fri, 29 Nov 2024 12:58:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfd97844-ed73-4af6-a64d-dcd75327e1da</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;HI,&lt;/p&gt;
&lt;p&gt;l am not able understand what you exactly require?&lt;/p&gt;
&lt;p&gt;Also if possible then please from your side give us suggestion so we make change in code and try to solve this problem.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/512748?ContentTypeID=1</link><pubDate>Fri, 29 Nov 2024 12:41:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdc1e981-853b-413b-80db-b093f2399a29</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;It does not seem to be any problem with wi-fi connectivity but with subsequent http request. Could you provide monitor mode capture along with your SSID/passphrase details?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/512661?ContentTypeID=1</link><pubDate>Fri, 29 Nov 2024 04:26:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad30a922-df1d-4115-a170-96ebe13c5e56</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;ok,&lt;/p&gt;
&lt;p&gt;Thank you for your support.&lt;/p&gt;
&lt;p&gt;If possible, please expedite the process as we have an upcoming client delivery.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/512628?ContentTypeID=1</link><pubDate>Thu, 28 Nov 2024 15:31:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6368af2-c622-401e-b584-20dd7e3d1a82</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;We will look into this internally. I expect to get back to you by the end of next week.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/512250?ContentTypeID=1</link><pubDate>Wed, 27 Nov 2024 03:33:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7959c305-49f4-4ac3-964f-38fdf67976ff</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;yes i have got the same&amp;nbsp;log, i am also not able to connect with the the websocket so i have got&amp;nbsp;&lt;/p&gt;
&lt;p&gt;[00:00:44.725,738] &amp;lt;err&amp;gt; sta: Cannot connect to IPv4 remote (-116)&lt;br /&gt;[00:00:44.726,165] &amp;lt;err&amp;gt; sta: Cannot connect to demos.kaazing.com:80&lt;br /&gt;[00:00:44.726,257] &amp;lt;err&amp;gt; sta: No IPv4 or IPv6 connectivity&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/512082?ContentTypeID=1</link><pubDate>Tue, 26 Nov 2024 11:18:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afcbddb3-094a-44e9-894a-815384045832</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;I have tested further your previous project HTTP.zip. There seems to be connection consistently. The change was to extend the sleep to allow for initialization of the wi-fi driver using&amp;nbsp;&lt;span&gt;k_sleep&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;K_SECONDS&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;10&lt;/span&gt;&lt;span&gt;)); instead of&amp;nbsp;&lt;/span&gt;&lt;span&gt;k_sleep&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;K_SECONDS&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;));&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:00.502,746] &amp;lt;inf&amp;gt; fs_nvs: 2 Sectors of 4096 bytes
[00:00:00.502,746] &amp;lt;inf&amp;gt; fs_nvs: alloc wra: 0, fd0
[00:00:00.502,777] &amp;lt;inf&amp;gt; fs_nvs: data wra: 0, c8
*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
[00:00:02.055,969] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:02.056,732] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Connecting to Wi-Fi
[00:00:04.606,048] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:07.159,393] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:09.713,409] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:12.267,883] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:14.834,533] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:17.400,695] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:19.947,631] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:22.501,220] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:25.055,206] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:27.609,893] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:30.181,518] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:30.264,404] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Network connected
[00:00:32.203,094] &amp;lt;inf&amp;gt; Lesson5_Exercise1: IPv4 address of HTTP server found 54.240.174.114
[00:00:33.456,909] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Connected to server
[00:00:33.456,939] &amp;lt;inf&amp;gt; Lesson5_Exercise1: HTTP POST request
[00:00:33.571,350] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Response status: Created
[00:00:33.571,380] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Successfully acquired client ID: /fb269045-2f73-4068-8064-b227e8a6cf70
[00:00:33.571,411] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Closing socket: 9
[00:00:36.434,722] &amp;lt;err&amp;gt; Lesson5_Exercise1: Cannot connect to IPv4 remote (-116)
[00:00:36.435,150] &amp;lt;err&amp;gt; Lesson5_Exercise1: Cannot connect to echo.thingy.rocks:80
[00:00:36.435,241] &amp;lt;err&amp;gt; Lesson5_Exercise1: No IPv4 or IPv6 connectivity
&lt;/pre&gt;&lt;br /&gt;I have also tested your most recent sample project sta_websocket.zip. Here is my log&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:41.839,843] &amp;lt;inf&amp;gt; sta: IPv4 address of HTTP server found 143.204.55.79
[00:00:42.560,241] &amp;lt;inf&amp;gt; sta: Connected to server
[00:00:42.560,241] &amp;lt;inf&amp;gt; sta: HTTP POST request
[00:00:42.652,740] &amp;lt;inf&amp;gt; sta: Response status: Forbidden
[00:00:42.652,801] &amp;lt;inf&amp;gt; sta: Successfully acquired client ID: /&amp;lt;!DOCTYPE HTML PUBLIC &amp;quot;-//W3C//DTD H
[00:00:42.652,801] &amp;lt;inf&amp;gt; sta: Closing socket: 9
[00:00:44.725,738] &amp;lt;err&amp;gt; sta: Cannot connect to IPv4 remote (-116)
[00:00:44.726,165] &amp;lt;err&amp;gt; sta: Cannot connect to demos.kaazing.com:80
[00:00:44.726,257] &amp;lt;err&amp;gt; sta: No IPv4 or IPv6 connectivity&lt;/pre&gt;&lt;br /&gt;Do you get the same log?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511805?ContentTypeID=1</link><pubDate>Mon, 25 Nov 2024 05:39:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b3a02cb-db82-4024-8e73-7c9a9b67e157</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;please try with attached code.&lt;/p&gt;
&lt;p&gt;Also please give me code which work with websocket so first i will take a reference of it and try to merge with https.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/sta_5F00_websocket.zip"&gt;devzone.nordicsemi.com/.../sta_5F00_websocket.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511725?ContentTypeID=1</link><pubDate>Fri, 22 Nov 2024 16:26:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d62540be-690e-4c4a-ad99-586db16f756c</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;I have managed to reproduce this issue only once. I expect for the error to be&amp;nbsp;consistently reproducible. It seems that the application on my side is not able to connect to wi-fi network most of the time.&amp;nbsp;&lt;br /&gt;Can you make a minimal sample which would show the same error (which can be replicated) for us to look into?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511467?ContentTypeID=1</link><pubDate>Thu, 21 Nov 2024 11:35:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb98ad90-3726-43b7-9ad6-dfb589b060a6</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;yes from my end i am able to reproduce this issue&amp;nbsp;&lt;span&gt;consistently,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;in your log i am able to see that you are also not able to connect with websocket&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[00:03:53.470,916] &amp;lt;err&amp;gt; Lesson5_Exercise1: Cannot connect to IPv4 remote (-116)&lt;br /&gt;[00:03:53.471,374] &amp;lt;err&amp;gt; Lesson5_Exercise1: Cannot connect to echo.thingy.rocks: 80&lt;br /&gt;[00:03:53.471,466] &amp;lt;err&amp;gt; Lesson5_Exercise1: No IPv4 or IPv6 connectivity&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If possible, please suggest changes to the code from your side so that I can implement them and try to resolve this problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511464?ContentTypeID=1</link><pubDate>Thu, 21 Nov 2024 11:26:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8917b87b-0335-4759-8089-1679f5bb73f3</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;After several tries, I was not able to consistently reproduce this issue. I was able to reproduce it only ones (after around 3 minutes of waiting). Here is my log&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
[00:00:02.047,607] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:03.627,227] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:03.627,410] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Connecting to Wi-Fi
[00:00:06.190,338] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:07.757,049] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
...
[00:03:45.629,180] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:03:47.201,538] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:03:47.286,682] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Network connected
[00:03:49.312,927] &amp;lt;inf&amp;gt; Lesson5_Exercise1: IPv4 address of HTTP server found 54.240.174.114
[00:03:49.964,233] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Connected to server
[00:03:49.964,263] &amp;lt;inf&amp;gt; Lesson5_Exercise1: HTTP POST request
[00:03:51.367,279] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Response status: Created
[00:03:51.367,370] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Successfully acquired client ID: /aa                                                                                                             313188-4331-4a72-bdfa-dacfcd1b7329
[00:03:51.367,401] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Closing socket: 9
[00:03:53.470,916] &amp;lt;err&amp;gt; Lesson5_Exercise1: Cannot connect to IPv4 remote (-116)
[00:03:53.471,374] &amp;lt;err&amp;gt; Lesson5_Exercise1: Cannot connect to echo.thingy.rocks:                                                                                                             80
[00:03:53.471,466] &amp;lt;err&amp;gt; Lesson5_Exercise1: No IPv4 or IPv6 connectivity&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Other times (more than 5 times) I got just &amp;quot;Connection requested&amp;quot; as shown below&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:05:12.783,325] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:05:14.347,320] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
...&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Are you able to consistently reproduce this issue on your end?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511324?ContentTypeID=1</link><pubDate>Wed, 20 Nov 2024 13:59:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59d924a2-694b-4be3-b6b5-f1f14f3e5997</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;We used the Ubuntu OS,&amp;nbsp;but I don&amp;#39;t think this should matter.&lt;br /&gt;Please verify the entered SSID and password using another device.&lt;br /&gt;Additionally, delete the build folder and recreate it for the &lt;code&gt;nrf7002dk_nrf5340_cpuapp&lt;/code&gt; board.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t thing so any other change necessary,&lt;br /&gt;On our side, using the same program, we&amp;nbsp;are able to connect to Wi-Fi successfully.&lt;/p&gt;
&lt;p&gt;once please try with this program&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/HTTP.zip"&gt;devzone.nordicsemi.com/.../HTTP.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;0
*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
[00:00:01.449,279] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Connecting to Wi-Fi
[00:00:04.007,598] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:06.564,605] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:09.121,124] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:11.694,519] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:11.782,257] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Network connected
[00:00:14.029,296] &amp;lt;inf&amp;gt; Lesson5_Exercise1: IPv4 address of HTTP server found 3.164.182.37
[00:00:16.490,203] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Connected to server
[00:00:16.490,203] &amp;lt;inf&amp;gt; Lesson5_Exercise1: HTTP POST request
[00:00:18.334,289] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Response status: Created
[00:00:18.334,350] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Successfully acquired client ID: /709505ae-78be-4517-a3a7-495b409cc440
[00:00:18.334,350] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Closing socket: 9
[00:00:21.110,015] &amp;lt;err&amp;gt; Lesson5_Exercise1: Cannot connect to IPv4 remote (-116)
[00:00:21.110,443] &amp;lt;err&amp;gt; Lesson5_Exercise1: Cannot connect to echo.thingy.rocks:80
[00:00:21.110,534] &amp;lt;err&amp;gt; Lesson5_Exercise1: No IPv4 or IPv6 connectivity&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511301?ContentTypeID=1</link><pubDate>Wed, 20 Nov 2024 13:22:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b800543-96e8-4e3e-94d2-ff9761755ee8</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="ChiragBhavsar"]I hope so you change ssid and password in below functon,also i used&amp;nbsp;&lt;span&gt;WIFI_SECURITY_TYPE_PSK for security&lt;/span&gt;[/quote]
&lt;p&gt;I used the same wifi security type. The only changes were for wifi_ssid and wifi_password in the set_wifi_credentials_struct(). Are any other changes necessary?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511284?ContentTypeID=1</link><pubDate>Wed, 20 Nov 2024 12:43:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf08a8e6-de5a-4188-bb6b-ff10c478651f</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;HI,&lt;/p&gt;
&lt;p&gt;I hope so you change ssid and password in below functon,also i used&amp;nbsp;&lt;span&gt;WIFI_SECURITY_TYPE_PSK for security&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;set_wifi_credentials_struct&lt;/span&gt;&lt;span&gt;() &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;char&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt;wifi_ssid&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;quot;realme&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;char&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt;wifi_password&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;quot;Chirag@1527&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;header&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;type&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;WIFI_SECURITY_TYPE_PSK&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;memset&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;header&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;bssid&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;sizeof&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;header&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;bssid&lt;/span&gt;&lt;span&gt;));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;header&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;flags&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;//wifi_cred.header.channel = WIFI_CHANNEL_ANY;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;//wifi_cred.header.timeout = 10;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;header&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ssid_len&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;strlen&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;wifi_ssid&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;memcpy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;header&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ssid&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;wifi_ssid&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;header&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ssid_len&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;password_len&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;strlen&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;wifi_password&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;memcpy&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;password&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;wifi_password&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;password_len&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;int&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;ret&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;wifi_credentials_set_personal_struct&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;wifi_cred&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ret&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;!=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;LOG_ERR&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;quot;Failed to set credentials, err: &lt;/span&gt;&lt;span&gt;%d&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;ret&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&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: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511276?ContentTypeID=1</link><pubDate>Wed, 20 Nov 2024 12:02:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92a6839a-731c-437d-8045-7ab41fd9ee8c</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;I have tried to replicate your issue, but I was unsuccessful. I have built your application on Windows 10 using nrf7002dk board and built for nrf7002dk_nrf5340_cpuapp in NCS v2.6.1. I have changed only wifi_ssid and wifi_password to reflect my ssid and password.&lt;br /&gt;Here is my log&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
[00:00:02.040,771] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:02.041,534] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Connecting to Wi-Fi
[00:00:04.604,827] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:07.173,156] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:09.741,699] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Are there any other changes to the project required for it to be built successfully?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511160?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2024 16:50:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d214f47-5595-4cd0-b041-d326bdd920c4</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;Ok,&lt;/p&gt;
&lt;p&gt;I am using SDK v2.6.1.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/HTTP_5F00_websoket.zip"&gt;devzone.nordicsemi.com/.../HTTP_5F00_websoket.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511156?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2024 16:26:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bcdeebb-1be1-4e40-8b76-f96967b149d6</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Can you send your project so that I can try to reproduce the error?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511050?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2024 10:43:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7382fb41-408e-4a6f-a55e-f45933d57372</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;In my previous reply, I shared code where I successfully connected to Wi-Fi and established internet access. I was also able to connect to the HTTP host, but I encountered issues when trying to connect to the WebSocket host.&lt;/p&gt;
&lt;p&gt;also i disable the http portion from the code and try to connect with&amp;nbsp;&lt;span&gt;WebSocket host&amp;nbsp;but i am not able to connect with it.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Could you please review my code and provide feedback to help me resolve the WebSocket connection issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/511047?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2024 10:32:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df62921b-77c1-4248-a379-08571ab07c9b</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;It seems to me that there are 2 different issues - integration of wi-fi with websocket_client and then integration of this with https_client sample. Is this correct?&lt;br /&gt;&lt;br /&gt;For wi-fi shell and websocket integration, your previous log showed &lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;inf&amp;gt; wpa_supp: Successfully initialized wpa_supplicant
&amp;lt;err&amp;gt; wpa_supp: eloop: select: Not enough space&lt;/pre&gt;&lt;br /&gt;This looks like the WPA supplicant has not started yet because of the memory issue &amp;quot;Not enough space&amp;quot;. Other issues coming after are printed due to network being down. From your previous project configuration you should remove CONFIG_NET_SOCKETS_POLL_MAX=4 because in the cases where supplicant is enabled default value is 6.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: require websocket and https combine example</title><link>https://devzone.nordicsemi.com/thread/510819?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2024 04:18:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1beded2-2eef-4368-aa1a-db7ac7a93eef</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;&lt;span&gt;Are you able to connect using only&amp;nbsp;&lt;/span&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/wifi/shell/README.html"&gt;Wi-Fi Shell&lt;/a&gt;&lt;span&gt;&amp;nbsp;sample and &amp;quot;wifi connect&amp;quot; command?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;gt;&amp;gt;yes when i separately used wifi shell sample with SDK v2.6.1&amp;nbsp;and give&amp;nbsp;wifi connect -s&amp;nbsp;&lt;em&gt;&amp;lt;ssid&amp;gt;&lt;/em&gt;&amp;nbsp;-k 1 -p&amp;nbsp;&lt;em&gt;&amp;lt;password&amp;gt;&amp;nbsp; then i am able to connect successfully,&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;Have you consider using&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/net/mqtt/doc/description.html"&gt;MQTT sample&lt;/a&gt;?&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;&amp;gt;&amp;gt;No&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I merged the HTTPS and WebSocket code, but I am still unable to connect to the WebSocket.&lt;/p&gt;
&lt;p&gt;Below is the output I received. Please review my code and provide your valuable feedback so I can resolve this issue as soon as possible.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;00:00:09.124,359] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:11.698,547] &amp;lt;inf&amp;gt; wifi_mgmt_ext: Connection requested
[00:00:11.796,875] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Network connected
[00:00:14.003,723] &amp;lt;inf&amp;gt; Lesson5_Exercise1: IPv4 address of HTTP server found 3.164.182.37
[00:00:16.464,599] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Connected to server
[00:00:16.464,630] &amp;lt;inf&amp;gt; Lesson5_Exercise1: HTTP POST request
[00:00:18.513,549] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Response status: Created
[00:00:18.513,580] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Successfully acquired client ID: /bed00a39-9547-49b6-81ac-031562f1998f
[00:00:18.513,610] &amp;lt;inf&amp;gt; Lesson5_Exercise1: Closing socket: 9
[00:00:20.928,588] &amp;lt;err&amp;gt; Lesson5_Exercise1: Cannot connect to IPv4 remote (-116)
[00:00:20.929,016] &amp;lt;err&amp;gt; Lesson5_Exercise1: Cannot connect to 192.0.2.2:9001
[00:00:20.929,107] &amp;lt;err&amp;gt; Lesson5_Exercise1: No IPv4 or IPv6 connectivity&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Below is my code,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2023 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/types.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;

#include &amp;lt;dk_buttons_and_leds.h&amp;gt;

/* STEP 3 - Include the necessary header files */
#include &amp;lt;zephyr/net/wifi.h&amp;gt;
#include &amp;lt;zephyr/net/wifi_mgmt.h&amp;gt;
#include &amp;lt;zephyr/net/net_mgmt.h&amp;gt;
#include &amp;lt;net/wifi_mgmt_ext.h&amp;gt;

/* STEP 12.4 - Include the header file for the Wi-FI credentials library */
#include &amp;lt;net/wifi_credentials.h&amp;gt;
#include &amp;lt;zephyr/net/socket.h&amp;gt;

#include &amp;lt;zephyr/net/net_if.h&amp;gt;
#include &amp;lt;zephyr/sys/printk.h&amp;gt;

#include &amp;lt;zephyr/net/websocket.h&amp;gt;

// #define SERVER_IP_ADDR &amp;quot;192.168.1.10&amp;quot; // Replace with your server&amp;#39;s IP
// #define SERVER_PORT 8080

// LOG_MODULE_REGISTER(Lesson2_Exercise2, LOG_LEVEL_INF);

/* STEP 4 - Define a macro for the relevant network events */
// #define EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED)

/* STEP 1.2 - Include the header file of the HTTP client library */
#include &amp;lt;zephyr/net/http/client.h&amp;gt;
/* STEP 1.4 - Include the header file for the TLS credentials library */
#include &amp;lt;zephyr/net/tls_credentials.h&amp;gt;

/* STEP 2.3 - Include the certificate */
static const char ca_certificate[] = {
#include &amp;quot;certificate.h&amp;quot;
};

LOG_MODULE_REGISTER(Lesson5_Exercise1);

#define EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED)

/* STEP 5 - Declare the callback structure for Wi-Fi events */
static struct net_mgmt_event_callback mgmt_cb;

/* STEP 6.1 - Define the boolean connected and the semaphore run_app */
static bool connected = 0;
static bool firsttime = 1;
static K_SEM_DEFINE(run_app, 0, 1);

/* STEP 4.1 - Define a macro for the credential security tag */
#define HTTP_TLS_SEC_TAG 1

/* STEP 2 - Define the macros for the HTTP server hostname and port */
#define HTTP_HOSTNAME  &amp;quot;echo.thingy.rocks&amp;quot; //staging.api.nexkey.com
#define HTTP_PORT     443

/* STEP 3 - Declare the necessary buffers for receiving messages */
#define RECV_BUF_SIZE  2048
#define CLIENT_ID_SIZE 36

static char recv_buf[RECV_BUF_SIZE];
static char client_id_buf[CLIENT_ID_SIZE + 2];

/* STEP 4 - Define the variable for the counter as 0 */
static int counter = 0;

static int sock;
static struct sockaddr_storage server;

//static struct net_mgmt_event_callback mgmt_cb;
//static bool connected;
//static K_SEM_DEFINE(run_app, 0, 1);



static int server_resolve(void)
{
	int err;
	struct addrinfo *result;
	struct addrinfo hints = {.ai_family = AF_INET, .ai_socktype = SOCK_STREAM};

	err = getaddrinfo(HTTP_HOSTNAME, STRINGIFY(HTTP_PORT), &amp;amp;hints, &amp;amp;result);
	if (err != 0) {
		LOG_ERR(&amp;quot;getaddrinfo failed, err: %d, %s&amp;quot;, err, gai_strerror(err));
		return -EIO;
	}

	if (result == NULL) {
		LOG_ERR(&amp;quot;Error, address not found&amp;quot;);
		return -ENOENT;
	}

	struct sockaddr_in *server4 = ((struct sockaddr_in *)&amp;amp;server);
	server4-&amp;gt;sin_addr.s_addr = ((struct sockaddr_in *)result-&amp;gt;ai_addr)-&amp;gt;sin_addr.s_addr;
	server4-&amp;gt;sin_family = AF_INET;
	server4-&amp;gt;sin_port = ((struct sockaddr_in *)result-&amp;gt;ai_addr)-&amp;gt;sin_port;

	char ipv4_addr[NET_IPV4_ADDR_LEN];
	inet_ntop(AF_INET, &amp;amp;server4-&amp;gt;sin_addr.s_addr, ipv4_addr, sizeof(ipv4_addr));
	LOG_INF(&amp;quot;IPv4 address of HTTP server found %s&amp;quot;, ipv4_addr);

	freeaddrinfo(result);

	return 0;
}

static int setup_credentials(void)
{
	
	/* STEP 4.2 - Add the credential to the device */
	int err = tls_credential_add(HTTP_TLS_SEC_TAG, TLS_CREDENTIAL_CA_CERTIFICATE, ca_certificate,
				 sizeof(ca_certificate));
	if (err &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to add TLS credentials, err: %d&amp;quot;, err);
		return err;
	}

	return 0;
}

static int server_connect(void)
{
	int err;
	sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TLS_1_2);
	if (sock &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to create socket, err: %d, %s&amp;quot;, errno, strerror(errno));
		return -errno;
	}

	/* STEP 5.1 - Configure the socket with the security tag for the certificate */
	sec_tag_t sec_tag_opt[] = {
		HTTP_TLS_SEC_TAG,
	};
	err = setsockopt(sock, SOL_TLS, TLS_SEC_TAG_LIST, sec_tag_opt, sizeof(sec_tag_opt));
	if (err &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to set TLS security TAG list, err: %d&amp;quot;, errno);
		(void)close(sock);
		return -errno;
	}
	/* STEP 5.2 - Configure the socket with the hostname of the HTTP server */
	err = setsockopt(sock, SOL_TLS, TLS_HOSTNAME, HTTP_HOSTNAME, sizeof(HTTP_HOSTNAME));
	if (err &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to set TLS_HOSTNAME option. Err: %d&amp;quot;, errno);
		(void)close(sock);
		return -errno;
	}

	err = connect(sock, (struct sockaddr *)&amp;amp;server, sizeof(struct sockaddr_in));
	if (err &amp;lt; 0) {
		LOG_ERR(&amp;quot;Connecting to server failed, err: %d, %s&amp;quot;, errno, strerror(errno));
		return -errno;
	}

	LOG_INF(&amp;quot;Connected to server&amp;quot;);
	return 0;
}

static void response_cb(struct http_response *rsp, enum http_final_call final_data, void *user_data)
{
	/* STEP 9 - Define the callback function to print the body */
	LOG_INF(&amp;quot;Response status: %s&amp;quot;, rsp-&amp;gt;http_status);

	if (rsp-&amp;gt;body_frag_len &amp;gt; 0) {
		char body_buf[rsp-&amp;gt;body_frag_len];
		strncpy(body_buf, rsp-&amp;gt;body_frag_start, rsp-&amp;gt;body_frag_len);
		body_buf[rsp-&amp;gt;body_frag_len] = &amp;#39;\0&amp;#39;;
		LOG_INF(&amp;quot;Received: %s&amp;quot;, body_buf);
	}

	LOG_INF(&amp;quot;Closing socket: %d&amp;quot;, sock);
	close(sock);
}

static void client_id_cb(struct http_response *rsp, enum http_final_call final_data,
			 void *user_data)
{
	/* STEP 6.1 - Log the HTTP response status */
	LOG_INF(&amp;quot;Response status: %s&amp;quot;, rsp-&amp;gt;http_status);

	/* STEP 6.2 - Retrieve and format the client ID */
	char client_id_buf_tmp[CLIENT_ID_SIZE + 1];
	strncpy(client_id_buf_tmp, rsp-&amp;gt;body_frag_start, CLIENT_ID_SIZE);
	client_id_buf_tmp[CLIENT_ID_SIZE] = &amp;#39;\0&amp;#39;;
	client_id_buf[0] = &amp;#39;/&amp;#39;;
	strcat(client_id_buf, client_id_buf_tmp);

	LOG_INF(&amp;quot;Successfully acquired client ID: %s&amp;quot;, client_id_buf);

	/* STEP 6.3 - Close the socket */
	LOG_INF(&amp;quot;Closing socket: %d&amp;quot;, sock);
	close(sock);
}

static int client_http_put(void)
{
	/* STEP 7 - Define the function to send a PUT request to the HTTP server */
	int err = 0;
	int bytes_written;
	const char *headers[] = {&amp;quot;Connection: close\r\n&amp;quot;, NULL};

	struct http_request req;
	memset(&amp;amp;req, 0, sizeof(req));

	char buffer[12] = {0};
	bytes_written = snprintf(buffer, 12, &amp;quot;%d&amp;quot;, counter);
	if (bytes_written &amp;lt; 0) {
		LOG_INF(&amp;quot;Unable to write to buffer, err: %d&amp;quot;, bytes_written);
		return bytes_written;
	}

	req.header_fields = headers;
	req.method = HTTP_PUT;
	req.url = client_id_buf;
	req.host = HTTP_HOSTNAME;
	req.protocol = &amp;quot;HTTP/1.1&amp;quot;;
	req.payload = buffer;
	req.payload_len = bytes_written;
	req.response = response_cb;
	req.recv_buf = recv_buf;
	req.recv_buf_len = sizeof(recv_buf);

	LOG_INF(&amp;quot;HTTP PUT request: %s&amp;quot;, buffer);
	err = http_client_req(sock, &amp;amp;req, 5000, NULL);
	if (err &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to send HTTP PUT request %s, err: %d&amp;quot;, buffer, err);
	}

	return err;
}

static int client_http_get(void)
{
	/* STEP 8 - Define the function to send a GET request to the HTTP server */
	int err = 0;
	const char *headers[] = {&amp;quot;Connection: close\r\n&amp;quot;, NULL};
	
	struct http_request req;
	memset(&amp;amp;req, 0, sizeof(req));

	req.header_fields = headers;
	req.method = HTTP_GET;
	req.url = client_id_buf;
	req.host = HTTP_HOSTNAME;
	req.protocol = &amp;quot;HTTP/1.1&amp;quot;;
	req.response = response_cb;
	req.recv_buf = recv_buf;
	req.recv_buf_len = sizeof(recv_buf);

	LOG_INF(&amp;quot;HTTP GET request&amp;quot;);
	err = http_client_req(sock, &amp;amp;req, 5000, NULL);
	if (err &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to send HTTP GET request, err: %d&amp;quot;, err);
	}

	return err;
}

static int client_get_new_id(void)
{
	int err = 0;

	/* STEP 5.1 - Define the structure http_request and fill the block of memory */
	struct http_request req;
	memset(&amp;amp;req, 0, sizeof(req));

	/* STEP 5.2 - Populate the http_request structure */
	const char *headers[] = {&amp;quot;Connection: close\r\n&amp;quot;, NULL};
	req.header_fields = headers;
	req.method = HTTP_POST;
	req.url =  &amp;quot;/new&amp;quot;;&amp;quot;https://api.nexkey.com&amp;quot;;
	req.host = HTTP_HOSTNAME;
	req.protocol = &amp;quot;HTTP/1.1&amp;quot;;
	req.response = client_id_cb;
	req.recv_buf = recv_buf;
	req.recv_buf_len = sizeof(recv_buf);

	/* STEP 5.3 - Send the request to the HTTP server */
	LOG_INF(&amp;quot;HTTP POST request&amp;quot;);
	err = http_client_req(sock, &amp;amp;req, 5000, NULL);
	if (err &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to send HTTP POST request, err: %d&amp;quot;, err);
	}
	return err;
}

/* STEP 6.2 - Define the callback function for network events */
static void net_mgmt_event_handler(struct net_mgmt_event_callback *cb,
			  uint32_t mgmt_event, struct net_if *iface)
{
	if ((mgmt_event &amp;amp; EVENT_MASK) != mgmt_event) {
		return;
	}
	if (mgmt_event == NET_EVENT_L4_CONNECTED) {
		LOG_INF(&amp;quot;Network connected&amp;quot;);
		connected = true;
		dk_set_led_on(DK_LED1);
		//k_sem_give(&amp;amp;run_app);
		return;
	}
	if (mgmt_event == NET_EVENT_L4_DISCONNECTED) {
		if (connected == false) {
			LOG_INF(&amp;quot;Waiting for network to be connected&amp;quot;);
		} else {
			dk_set_led_off(DK_LED1);
			LOG_INF(&amp;quot;Network disconnected&amp;quot;);
			connected = false;
		}
		//k_sem_reset(&amp;amp;run_app);
		return;
	}
}

/* STEP 7 - Define the function to populate the Wi-Fi credential parameters */
//static int wifi_args_to_params(struct wifi_connect_req_params *params)
//{

	/* STEP 7.1 Populate the SSID and password */
	//params-&amp;gt;ssid = CONFIG_WIFI_CREDENTIALS_STATIC_SSID;
	//params-&amp;gt;ssid_length = strlen(params-&amp;gt;ssid);

	//params-&amp;gt;psk = CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD;
	//params-&amp;gt;psk_length = strlen(params-&amp;gt;psk);

	/* STEP 7.2 - Populate the rest of the relevant members */
	//params-&amp;gt;channel = WIFI_CHANNEL_ANY;
	//params-&amp;gt;security = WIFI_SECURITY_TYPE_PSK;
	//params-&amp;gt;mfp = WIFI_MFP_OPTIONAL;
	//params-&amp;gt;timeout = SYS_FOREVER_MS;
	//params-&amp;gt;band = WIFI_FREQ_BAND_UNKNOWN;
	//#if NCS_VERSION_NUMBER &amp;gt; 0x20600
	//memset(params-&amp;gt;bssid, 0, sizeof(params-&amp;gt;bssid));
	//#endif
	//return 0;
//}

static struct wifi_credentials_personal wifi_cred;
void set_wifi_credentials_struct() 
{

	char *wifi_ssid = &amp;quot;realme&amp;quot;;
	char *wifi_password = &amp;quot;Chirag@1527&amp;quot;;

	wifi_cred.header.type = WIFI_SECURITY_TYPE_PSK;
	memset(wifi_cred.header.bssid, 0, sizeof(wifi_cred.header.bssid));
	wifi_cred.header.flags = 0;
	//wifi_cred.header.channel = WIFI_CHANNEL_ANY;
	//wifi_cred.header.timeout = 10;

	wifi_cred.header.ssid_len = strlen(wifi_ssid);
	memcpy(wifi_cred.header.ssid, wifi_ssid, wifi_cred.header.ssid_len);
	
	wifi_cred.password_len = strlen(wifi_password);
	memcpy(wifi_cred.password, wifi_password, wifi_cred.password_len);

	int ret = wifi_credentials_set_personal_struct(&amp;amp;wifi_cred);

	if (ret != 0) {
		LOG_ERR(&amp;quot;Failed to set credentials, err: %d&amp;quot;, ret);
	}
}
static void button_handler(uint32_t button_state, uint32_t has_changed)
{
	/* STEP 10 - Define the button handler to send requests upon button triggers */
	if (has_changed &amp;amp; DK_BTN1_MSK &amp;amp;&amp;amp; button_state &amp;amp; DK_BTN1_MSK) {
		if (server_connect() &amp;gt;= 0) {
			client_http_put();
			counter++;
		}
	} else if (has_changed &amp;amp; DK_BTN2_MSK &amp;amp;&amp;amp; button_state &amp;amp; DK_BTN2_MSK) {
		if (server_connect() &amp;gt;= 0) {
			client_http_get();
		}
	}
}
static const char lorem_ipsum[] =
	&amp;quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. &amp;quot;
	&amp;quot;Vestibulum ultricies sapien tellus, ac viverra dolor bibendum &amp;quot;
	&amp;quot;lacinia. Vestibulum et nisl tristique tellus finibus gravida &amp;quot;
	&amp;quot;vitae sit amet nunc. Suspendisse maximus justo mi, vitae porta &amp;quot;
	&amp;quot;risus suscipit vitae. Curabitur ut fringilla velit. Donec ac nisi &amp;quot;
	&amp;quot;in dui semper lobortis sed nec ante. Sed nec luctus dui. Sed ut &amp;quot;
	&amp;quot;ante nisi. Mauris congue euismod felis, et maximus ex pellentesque &amp;quot;
	&amp;quot;nec. Proin nibh nisl, semper at nunc in, mattis pharetra metus. Nam &amp;quot;
	&amp;quot;turpis risus, pulvinar sit amet varius ac, pellentesque quis purus.&amp;quot;
	&amp;quot; &amp;quot;
	&amp;quot;Nam consequat purus in lacinia fringilla. Morbi volutpat, tellus &amp;quot;
	&amp;quot;nec tempus dapibus, ante sem aliquam dui, eu feugiat libero diam &amp;quot;
	&amp;quot;at leo. Sed suscipit egestas orci in ultrices. Integer in elementum &amp;quot;
	&amp;quot;ligula, vel sollicitudin velit. Nullam sit amet eleifend libero. &amp;quot;
	&amp;quot;Proin sit amet consequat tellus, vel vulputate arcu. Curabitur quis &amp;quot;
	&amp;quot;lobortis lacus. Sed faucibus vestibulum enim vel elementum. Vivamus &amp;quot;
	&amp;quot;enim nunc, auctor in purus at, aliquet pulvinar eros. Cras dapibus &amp;quot;
	&amp;quot;nec quam laoreet sagittis. Quisque dictum ante odio, at imperdiet &amp;quot;
	&amp;quot;est convallis a. Morbi mattis ut orci vitae volutpat.&amp;quot;
	&amp;quot;\n&amp;quot;;
#define SERVER_ADDR4 &amp;quot;192.0.2.2&amp;quot;
#define SERVER_PORT 9001
#define MAX_RECV_BUF_LEN (sizeof(lorem_ipsum) - 1)
#define EXTRA_BUF_SPACE 30
static uint8_t temp_recv_buf_ipv4[MAX_RECV_BUF_LEN + EXTRA_BUF_SPACE];

static int setup_socket(sa_family_t family, const char *server, int port,
			int *sock, struct sockaddr *addr, socklen_t addr_len)
{
	const char *family_str = family == AF_INET ? &amp;quot;IPv4&amp;quot; : &amp;quot;IPv6&amp;quot;;
	int ret = 0;

	memset(addr, 0, addr_len);

	//if (family == AF_INET) {
		net_sin(addr)-&amp;gt;sin_family = AF_INET;
		net_sin(addr)-&amp;gt;sin_port = htons(port);
		inet_pton(family, server, &amp;amp;net_sin(addr)-&amp;gt;sin_addr);
	// } else {
	// 	net_sin6(addr)-&amp;gt;sin6_family = AF_INET6;
	// 	net_sin6(addr)-&amp;gt;sin6_port = htons(port);
	// 	inet_pton(family, server, &amp;amp;net_sin6(addr)-&amp;gt;sin6_addr);
	// }

	// if (IS_ENABLED(CONFIG_NET_SOCKETS_SOCKOPT_TLS)) {
	// 	sec_tag_t sec_tag_list[] = {
	// 		CA_CERTIFICATE_TAG,
	// 	};

	// 	*sock = socket(family, SOCK_STREAM, IPPROTO_TLS_1_2);
	// 	if (*sock &amp;gt;= 0) {
	// 		ret = setsockopt(*sock, SOL_TLS, TLS_SEC_TAG_LIST,
	// 				 sec_tag_list, sizeof(sec_tag_list));
	// 		if (ret &amp;lt; 0) {
	// 			LOG_ERR(&amp;quot;Failed to set %s secure option (%d)&amp;quot;,
	// 				family_str, -errno);
	// 			ret = -errno;
	// 			goto fail;
	// 		}

	// 		ret = setsockopt(*sock, SOL_TLS, TLS_HOSTNAME,
	// 				 TLS_PEER_HOSTNAME,
	// 				 sizeof(TLS_PEER_HOSTNAME));
	// 		if (ret &amp;lt; 0) {
	// 			LOG_ERR(&amp;quot;Failed to set %s TLS_HOSTNAME &amp;quot;
	// 				&amp;quot;option (%d)&amp;quot;, family_str, -errno);
	// 			ret = -errno;
	// 			goto fail;
	// 		}
	// 	}
	// } else {
		*sock = socket(family, SOCK_STREAM, IPPROTO_TCP);
	//}

	if (*sock &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to create %s HTTP socket (%d)&amp;quot;, family_str,
			-errno);
	}

	return ret;

fail:
	if (*sock &amp;gt;= 0) {
		close(*sock);
		*sock = -1;
	}

	return ret;
}
static int connect_cb(int sock, struct http_request *req, void *user_data)
{
	LOG_INF(&amp;quot;Websocket %d for %s connected.&amp;quot;, sock, (char *)user_data);

	return 0;
}
static int connect_socket(sa_family_t family, const char *server, int port,
			  int *sock, struct sockaddr *addr, socklen_t addr_len)
{
	int ret;

	ret = setup_socket(family, server, port, sock, addr, addr_len);
	if (ret &amp;lt; 0 || *sock &amp;lt; 0) {
		return -1;
	}

	ret = connect(*sock, addr, addr_len);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Cannot connect to %s remote (%d)&amp;quot;,
			family == AF_INET ? &amp;quot;IPv4&amp;quot; : &amp;quot;IPv6&amp;quot;,
			-errno);
		ret = -errno;
	}

	return ret;
}
int main(void)
{
	/* STEP 8.1 - Declare the variable for the network configuration parameters */
	//struct wifi_connect_req_params cnx_params;



	/* STEP 8.2 - Get the network interface */
	struct net_if *iface = net_if_get_first_wifi();
	if (iface == NULL) {
		LOG_ERR(&amp;quot;Returned network interface is NULL&amp;quot;);
		return -1;
	}

	if (dk_leds_init() != 0) {
		LOG_ERR(&amp;quot;Failed to initialize the LED library&amp;quot;);
	}

	/* Sleep to allow initialization of Wi-Fi driver */
	k_sleep(K_SECONDS(1));

	/* STEP 9 - Initialize and add the callback function for network events */
	net_mgmt_init_event_callback(&amp;amp;mgmt_cb, net_mgmt_event_handler, EVENT_MASK);
	net_mgmt_add_event_callback(&amp;amp;mgmt_cb);

	/* STEP 10 - Populate cnx_params with the network configuration */
	//wifi_args_to_params(&amp;amp;cnx_params);

    set_wifi_credentials_struct();
	/* STEP 11 - Call net_mgmt() to request the Wi-Fi connection */
	LOG_INF(&amp;quot;Connecting to Wi-Fi&amp;quot;);
	//printf(&amp;quot;try to connect with wifi&amp;quot;);
	//LOG_ERR(&amp;quot;buttons library&amp;quot;);
	//int err = net_mgmt(NET_REQUEST_WIFI_CONNECT_STORED, iface, &amp;amp;wifi_cred, sizeof(struct wifi_credentials_personal));
	//LOG_ERR(&amp;quot;buttons library&amp;quot;);
	// if (err) {
	// 	LOG_ERR(&amp;quot;Connecting to Wi-Fi failed, err: %d&amp;quot;, err);
	// 	//return ENOEXEC;
	// }

	//k_sem_take(&amp;amp;run_app, K_FOREVER);

	if (dk_buttons_init(button_handler) != 0) {
		LOG_ERR(&amp;quot;Failed to initialize the buttons library &amp;quot;);
	}
	while(1)
	{
		//LOG_ERR(&amp;quot;Failed to initialize the buttons library &amp;quot;);
		k_sleep(K_SECONDS(1));
		if(!connected)
		{
			int err = net_mgmt(NET_REQUEST_WIFI_CONNECT_STORED, iface, &amp;amp;wifi_cred, sizeof(struct wifi_credentials_personal));
		}
		if(connected &amp;amp;&amp;amp; firsttime == 1)
		{
			k_sleep(K_SECONDS(1));
			if (server_resolve() != 0) {
				LOG_ERR(&amp;quot;Failed to resolve server name&amp;quot;);
				return 0;
			}
			
			if (setup_credentials() != 0) {
		        LOG_ERR(&amp;quot;Setup credentials failed&amp;quot;);
	        }

			if (server_connect() != 0) {
				LOG_ERR(&amp;quot;Failed to initialize client&amp;quot;);
				return 0;
			}	

			/* STEP 11 - Retrieve the client ID upon connection */
			if (client_get_new_id() &amp;lt; 0) {
				LOG_ERR(&amp;quot;Failed to get client ID&amp;quot;);
				return 0;
			}
			firsttime = 0;
			//LOG_ERR(&amp;quot;buttons library&amp;quot;);
		
		const char *extra_headers[] = 
		{
			&amp;quot;Origin: http://foobar\r\n&amp;quot;,
			NULL
	    };
		int sock4 = -1, sock6 = -1;
		int websock4 = -1, websock6 = -1;
		int32_t timeout = 3 * MSEC_PER_SEC;
		struct sockaddr_in6 addr6;
		struct sockaddr_in addr4;
		size_t amount;
		int ret;

		//if (IS_ENABLED(CONFIG_NET_IPV4)) 
		{
					(void)connect_socket(AF_INET, SERVER_ADDR4, SERVER_PORT,
				     &amp;amp;sock4, (struct sockaddr *)&amp;amp;addr4,
				     sizeof(addr4));
		}
	
	if (sock4 &amp;lt; 0) {
		LOG_ERR(&amp;quot;Cannot create HTTP connection.&amp;quot;);
		k_sleep(K_FOREVER);
	}

	//if (sock4 &amp;gt;= 0 &amp;amp;&amp;amp; IS_ENABLED(CONFIG_NET_IPV4)) 
	{
		struct websocket_request req;

		memset(&amp;amp;req, 0, sizeof(req));

		req.host = SERVER_ADDR4;
		req.url = &amp;quot;/&amp;quot;;
		req.optional_headers = extra_headers;
		req.cb = connect_cb;
		req.tmp_buf = temp_recv_buf_ipv4;
		req.tmp_buf_len = sizeof(temp_recv_buf_ipv4);

		websock4 = websocket_connect(sock4, &amp;amp;req, timeout, &amp;quot;IPv4&amp;quot;);
		if (websock4 &amp;lt; 0) {
			LOG_ERR(&amp;quot;Cannot connect to %s:%d&amp;quot;, SERVER_ADDR4,
				SERVER_PORT);
			close(sock4);
		}
	}
	if (websock4 &amp;lt; 0)
	 {
		LOG_ERR(&amp;quot;No IPv4 or IPv6 connectivity&amp;quot;);
		k_sleep(K_FOREVER);
	}

	LOG_INF(&amp;quot;Websocket IPv4 %d IPv6 %d&amp;quot;, websock4, websock6);



		//return 0;
	}
  }
		
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;prj.conf file&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;# Wi-Fi
CONFIG_WIFI=y
CONFIG_WIFI_NRF700X=y
CONFIG_WPA_SUPP=y
# CONFIG_WPA_SUPP_CRYPTO_PSA=y

# Wi-Fi Credentials
CONFIG_WIFI_CREDENTIALS=y
CONFIG_WIFI_CREDENTIALS_STATIC=n

# Networking Management API
CONFIG_NET_MGMT=y
CONFIG_NET_MGMT_EVENT=y
CONFIG_NET_MGMT_EVENT_INFO=y
CONFIG_NET_MGMT_EVENT_STACK_SIZE=4096
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_WIFI_MGMT_EXT=y

# Support for shell commands
# CONFIG_SHELL=y
# CONFIG_WIFI_CREDENTIALS_SHELL=y
# CONFIG_SHELL_STACK_SIZE=4400

# Logging
CONFIG_LOG=y

# DK library
CONFIG_DK_LIBRARY=y

# System settings
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_NANO=n

# Networking
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_MAX_FDS=16

CONFIG_NET_L2_ETHERNET=y
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NET_TCP=y
CONFIG_NET_DHCPV4=y
CONFIG_DNS_RESOLVER=y

# TLS
# STEP 1.1 - Enable the TLS library and security relevant configurations
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
CONFIG_TLS_CREDENTIALS=y
CONFIG_MBEDTLS_RSA_C=y
CONFIG_MBEDTLS_DHM_C=y 

# STEP 1.2 - Enable support for server name indication (SNI)
CONFIG_MBEDTLS_SSL_SERVER_NAME_INDICATION=y

# Memory
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=153600

CONFIG_NET_TCP_WORKQ_STACK_SIZE=2048
CONFIG_NET_TX_STACK_SIZE=4096
CONFIG_NET_RX_STACK_SIZE=4096
CONFIG_NET_BUF_RX_COUNT=16
CONFIG_NET_BUF_TX_COUNT=16
CONFIG_NET_BUF_DATA_SIZE=256
CONFIG_NET_TC_TX_COUNT=0

# HTTP
CONFIG_HTTP_CLIENT=y
# For storing Wi-Fi credentials
CONFIG_WIFI_CREDENTIALS_BACKEND_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS=y

# CONFIG_NET_L2_WIFI_SHELL=y

# General
CONFIG_POSIX_CLOCK=y

# Optimize Wi-Fi stack to save some memory

CONFIG_NRF700X_MAX_TX_AGGREGATION=4

# Wi-Fi

CONFIG_WIFI_NRF700X_LOG_LEVEL_ERR=y

# WPA supplicant

CONFIG_WPA_SUPP_LOG_LEVEL_ERR=y

# Zephyr NET Connection Manager connectivity layer
CONFIG_L2_WIFI_CONNECTIVITY=y
# CONFIG_L2_WIFI_CONNECTIVITY_AUTO_DOWN=n
# CONFIG_L2_WIFI_CONNECTIVITY_AUTO_CONNECT=n

# DNS

# CONFIG_NET_SOCKETS_DNS_TIMEOUT=30000

# NET sockets

CONFIG_NET_UDP=y
# CONFIG_NET_SOCKETS_OFFLOAD=n

# CONFIG_NET_CONTEXT_SNDTIMEO=y

# TLS networking
CONFIG_NET_SOCKETS_ENABLE_DTLS=n
CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=2


# TLS credentials

# Here is the overlay I used for nrf7002dk_nrf5340_cpuapp

# CONFIG_TLS_CREDENTIALS_BACKEND_VOLATILE=y

# mbedTLS
CONFIG_NRF_SECURITY=y
CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=81920
CONFIG_PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY=y
CONFIG_PSA_WANT_RSA_KEY_SIZE_2048=y

CONFIG_MBEDTLS_TLS_LIBRARY=y

CONFIG_PM_SINGLE_IMAGE=y


CONFIG_WEBSOCKET_CLIENT=y&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>