Skip to content

Commit 7a78a02

Browse files
committed
Reorganization of samples
- Move them into a folder to improve initial page usability. - Reorganize samples list into a table and sections. Signed-off-by: José Simões <[email protected]>
1 parent 82c67b2 commit 7a78a02

File tree

212 files changed

+253
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+253
-29
lines changed

README.md

+84-29
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

samples/SSL/SecureServer/Program.cs

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using System;
2+
using System.Threading;
3+
4+
namespace SecureServer
5+
{
6+
public class Program
7+
{
8+
public static void Main()
9+
{
10+
Console.WriteLine("Setting up network and connecting...");
11+
SetupAndConnectNetwork();
12+
13+
Console.WriteLine("Setting up socket...");
14+
using (Socket mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IPv4))
15+
{
16+
// create a local IPEndPoint
17+
IPEndPoint ep = new IPEndPoint(0, 4567);
18+
19+
Console.WriteLine("Listen to connections...");
20+
21+
// bind socket to local endpoint
22+
mySocket.Bind(ep);
23+
24+
// wait for connection
25+
26+
27+
}
28+
}
29+
30+
public static void SetupAndConnectNetwork()
31+
{
32+
NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces();
33+
if (nis.Length > 0)
34+
{
35+
// get the first interface
36+
NetworkInterface ni = nis[0];
37+
38+
if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
39+
{
40+
// network interface is Wi-Fi
41+
Console.WriteLine("Network connection is: Wi-Fi");
42+
43+
Wireless80211Configuration wc = Wireless80211Configuration.GetAllWireless80211Configurations()[ni.SpecificConfigId];
44+
if (wc.Ssid != c_SSID && wc.Password != c_AP_PASSWORD)
45+
{
46+
// have to update Wi-Fi configuration
47+
wc.Ssid = c_SSID;
48+
wc.Password = c_AP_PASSWORD;
49+
wc.SaveConfiguration();
50+
}
51+
else
52+
{ // Wi-Fi configuration matches
53+
}
54+
}
55+
else
56+
{
57+
// network interface is Ethernet
58+
Console.WriteLine("Network connection is: Ethernet");
59+
60+
ni.EnableDhcp();
61+
}
62+
63+
// wait for DHCP to complete
64+
WaitIP();
65+
}
66+
else
67+
{
68+
throw new NotSupportedException("ERROR: there is no network interface configured.\r\nOpen the 'Edit Network Configuration' in Device Explorer and configure one.");
69+
}
70+
}
71+
72+
static void WaitIP()
73+
{
74+
Console.WriteLine("Wait for IP");
75+
76+
while (true)
77+
{
78+
NetworkInterface ni = NetworkInterface.GetAllNetworkInterfaces()[0];
79+
if (ni.IPv4Address != null && ni.IPv4Address.Length > 0)
80+
{
81+
if (ni.IPv4Address[0] != '0')
82+
{
83+
Console.WriteLine($"We have and IP: {ni.IPv4Address}");
84+
break;
85+
}
86+
}
87+
88+
Thread.Sleep(1000);
89+
}
90+
}
91+
}
92+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Label="Globals">
4+
<NanoFrameworkProjectSystemPath>$(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
5+
</PropertyGroup>
6+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
7+
<PropertyGroup>
8+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
9+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
10+
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
11+
<ProjectGuid>b795119d-a3f0-43fa-99aa-ae582de61ac2</ProjectGuid>
12+
<OutputType>Exe</OutputType>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<FileAlignment>512</FileAlignment>
15+
<RootNamespace>SecureServer</RootNamespace>
16+
<AssemblyName>SecureServer</AssemblyName>
17+
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
18+
</PropertyGroup>
19+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
20+
<ItemGroup>
21+
<Compile Include="Program.cs" />
22+
<Compile Include="Properties\AssemblyInfo.cs" />
23+
</ItemGroup>
24+
<ItemGroup>
25+
<Reference Include="mscorlib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
26+
<HintPath>..\packages\nanoFramework.CoreLibrary.1.0.0-preview054\lib\mscorlib.dll</HintPath>
27+
<Private>True</Private>
28+
<SpecificVersion>True</SpecificVersion>
29+
</Reference>
30+
</ItemGroup>
31+
<ItemGroup>
32+
<None Include="packages.config" />
33+
</ItemGroup>
34+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
35+
<ProjectExtensions>
36+
<ProjectCapabilities>
37+
<ProjectConfigurationsDeclaredAsItems />
38+
</ProjectCapabilities>
39+
</ProjectExtensions>
40+
</Project>
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="nanoFramework.CoreLibrary" version="1.0.0-preview054" targetFramework="netnanoframework10" />
4+
</packages>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CSharp.BlankApplication")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("CSharp.BlankApplication")]
13+
[assembly: AssemblyCopyright("Copyright © ")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// Version information for an assembly consists of the following four values:
23+
//
24+
// Major Version
25+
// Minor Version
26+
// Build Number
27+
// Revision
28+
//
29+
// You can specify all the values or you can default the Build and Revision Numbers
30+
// by using the '*' as shown below:
31+
// [assembly: AssemblyVersion("1.0.*")]
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)