Skip to content

Commit

Permalink
Improvements in TLS samples
Browse files Browse the repository at this point in the history
- Improve code for Wi-Fi client so it doesn't unnoticeably replace existing Wi-Fi config.
- Remove private properties from nfproj files.
  • Loading branch information
josesimoes committed Jul 26, 2024
1 parent ff0c0d2 commit ca8d2d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
5 changes: 1 addition & 4 deletions samples/SSL/SecureClient/SecureClient.nfproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,15 @@
</Reference>
<Reference Include="nanoFramework.Runtime.Events, Version=1.11.18.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.Runtime.Events.1.11.18\lib\nanoFramework.Runtime.Events.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nanoFramework.System.Text, Version=1.2.54.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.Text.1.2.54\lib\nanoFramework.System.Text.dll</HintPath>
</Reference>
<Reference Include="System.IO.Streams, Version=1.1.59.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.IO.Streams.1.1.59\lib\System.IO.Streams.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net, Version=1.10.79.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.Net.1.10.79\lib\System.Net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Threading, Version=1.1.32.63105, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.Threading.1.1.32\lib\System.Threading.dll</HintPath>
Expand All @@ -66,4 +63,4 @@
<ProjectConfigurationsDeclaredAsItems />
</ProjectCapabilities>
</ProjectExtensions>
</Project>
</Project>
13 changes: 7 additions & 6 deletions samples/SSL/SecureClient_WiFi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand All @@ -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("<MY-SSIDS>", "<MY-WIFI-PASSWORD>", requiresDateTime: true, token: cs.Token);
#else
success = NetworkHelper.SetupAndConnectNetwork(requiresDateTime: true, token: cs.Token);
#endif
Expand Down
10 changes: 1 addition & 9 deletions samples/SSL/SecureClient_WiFi/SecureClient_WiFi.nfproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,27 @@
<ItemGroup>
<Reference Include="mscorlib, Version=1.15.6.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.CoreLibrary.1.15.5\lib\mscorlib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nanoFramework.ResourceManager, Version=1.2.19.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.ResourceManager.1.2.19\lib\nanoFramework.ResourceManager.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nanoFramework.Runtime.Events, Version=1.11.18.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.Runtime.Events.1.11.18\lib\nanoFramework.Runtime.Events.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nanoFramework.System.Text, Version=1.2.54.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.Text.1.2.54\lib\nanoFramework.System.Text.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Device.Wifi, Version=1.5.85.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.Device.Wifi.1.5.85\lib\System.Device.Wifi.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Streams, Version=1.1.59.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.IO.Streams.1.1.59\lib\System.IO.Streams.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net, Version=1.10.79.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.Net.1.10.79\lib\System.Net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Threading, Version=1.1.32.63105, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<HintPath>..\packages\nanoFramework.System.Threading.1.1.32\lib\System.Threading.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
Expand All @@ -78,4 +70,4 @@
<ProjectConfigurationsDeclaredAsItems />
</ProjectCapabilities>
</ProjectExtensions>
</Project>
</Project>

0 comments on commit ca8d2d3

Please sign in to comment.