From ca8d2d38d63be638d5cb68d5798eb00da9b8ad81 Mon Sep 17 00:00:00 2001 From: josesimoes Date: Fri, 26 Jul 2024 17:14:20 +0100 Subject: [PATCH] Improvements in TLS samples - Improve code for Wi-Fi client so it doesn't unnoticeably replace existing Wi-Fi config. - Remove private properties from nfproj files. --- samples/SSL/SecureClient/SecureClient.nfproj | 5 +---- samples/SSL/SecureClient_WiFi/Program.cs | 13 +++++++------ .../SSL/SecureClient_WiFi/SecureClient_WiFi.nfproj | 10 +--------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/samples/SSL/SecureClient/SecureClient.nfproj b/samples/SSL/SecureClient/SecureClient.nfproj index f95f78c7..c8e348c2 100644 --- a/samples/SSL/SecureClient/SecureClient.nfproj +++ b/samples/SSL/SecureClient/SecureClient.nfproj @@ -43,18 +43,15 @@ ..\packages\nanoFramework.Runtime.Events.1.11.18\lib\nanoFramework.Runtime.Events.dll - True ..\packages\nanoFramework.System.Text.1.2.54\lib\nanoFramework.System.Text.dll ..\packages\nanoFramework.System.IO.Streams.1.1.59\lib\System.IO.Streams.dll - True ..\packages\nanoFramework.System.Net.1.10.79\lib\System.Net.dll - True ..\packages\nanoFramework.System.Threading.1.1.32\lib\System.Threading.dll @@ -66,4 +63,4 @@ - \ No newline at end of file + diff --git a/samples/SSL/SecureClient_WiFi/Program.cs b/samples/SSL/SecureClient_WiFi/Program.cs index 2e9b968e..c517cce3 100644 --- a/samples/SSL/SecureClient_WiFi/Program.cs +++ b/samples/SSL/SecureClient_WiFi/Program.cs @@ -22,11 +22,6 @@ namespace SecureClient { public class Program { -#if HAS_WIFI - private static string MySsid = "ssid"; - private static string MyPassword = "password"; -#endif - public static void Main() { Debug.WriteLine("Waiting for network up and IP address..."); @@ -36,7 +31,13 @@ public static void Main() CancellationTokenSource cs = new(60000); #if HAS_WIFI - success = WifiNetworkHelper.ConnectDhcp(MySsid, MyPassword, requiresDateTime: true, token: cs.Token); + + Debug.WriteLine("This expectes that there is already a previously configured WiFi connection."); + success = WifiNetworkHelper.Reconnect(requiresDateTime: true, token: cs.Token); + + // If that's not the case, then uncomment the code snippet below to setup the WiFi connection + // Make sure to comment the line above + // success = WifiNetworkHelper.ConnectDhcp("", "", requiresDateTime: true, token: cs.Token); #else success = NetworkHelper.SetupAndConnectNetwork(requiresDateTime: true, token: cs.Token); #endif diff --git a/samples/SSL/SecureClient_WiFi/SecureClient_WiFi.nfproj b/samples/SSL/SecureClient_WiFi/SecureClient_WiFi.nfproj index e6585d8e..430ece80 100644 --- a/samples/SSL/SecureClient_WiFi/SecureClient_WiFi.nfproj +++ b/samples/SSL/SecureClient_WiFi/SecureClient_WiFi.nfproj @@ -41,35 +41,27 @@ ..\packages\nanoFramework.CoreLibrary.1.15.5\lib\mscorlib.dll - True ..\packages\nanoFramework.ResourceManager.1.2.19\lib\nanoFramework.ResourceManager.dll - True ..\packages\nanoFramework.Runtime.Events.1.11.18\lib\nanoFramework.Runtime.Events.dll - True ..\packages\nanoFramework.System.Text.1.2.54\lib\nanoFramework.System.Text.dll - True ..\packages\nanoFramework.System.Device.Wifi.1.5.85\lib\System.Device.Wifi.dll - True ..\packages\nanoFramework.System.IO.Streams.1.1.59\lib\System.IO.Streams.dll - True ..\packages\nanoFramework.System.Net.1.10.79\lib\System.Net.dll - True ..\packages\nanoFramework.System.Threading.1.1.32\lib\System.Threading.dll - True @@ -78,4 +70,4 @@ - \ No newline at end of file +