We have a problem with the type IPAddress:
-
without “using System.Net;”
Code:networkInterfaceSetting.Address = new System.Net.IPAddress (new byte[] { 192, 168, 0, 201 });
Error: Cannot implicitly convert type ‘GHIElectronics.TinyCLR.Drivers.BasicNet.IPAddress’ to ‘System.Net.IPAddress’ -
with “using System.Net;”
Code:networkInterfaceSetting.Address = new System.Net.IPAddress (new byte[] { 192, 168, 0, 201 });
error: ‘IPAddress’ is an ambiguous reference between ‘GHIElectronics.TinyCLR.Drivers.BasicNet.IPAddress’ and ‘System.Net.IPAddress’ -
Test
Code:using TinyCLRIPAddress = System.Net.IPAddress;
Error: The type ‘IPAddress’ exists in both ‘GHIElectronics.TinyCLR.Networking, Version=2.3.0.1000, Culture=neutral, PublicKeyToken=null’ and ‘System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ -
Test
Code:networkInterfaceSetting.Address = new GHIElectronics.TinyCLR.Networking.IPAddress (new byte[] { 192, 168, 0, 201 });
Error: The type or namespace name ‘IPAddress’ does not exist in the namespace ‘GHIElectronics.TinyCLR.Networking’ (are you missing an assembly reference?)
Our goal is to create an Access Point that we can connect to with a web server in order to configure a Wi-Fi network that the Feather should connect to. After that, another web server will start. The biggest issue right now is the Access Point.
If you want here is the whole code.
using System;
using System.Net;
//using System.Net;
using System.Threading;
using GHIElectronics.TinyCLR.Devices.Gpio;
using GHIElectronics.TinyCLR.Devices.Network;
using GHIElectronics.TinyCLR.Devices.Spi;
using GHIElectronics.TinyCLR.Drivers.BasicNet;
using GHIElectronics.TinyCLR.Pins;
using TinyCLRIPAddress = System.Net.IPAddress; //System.Net.IPAddress;
public class Program
{
public static void Main()
{
// Initialize Wi-Fi and start Access Point
InitializeWifi();
}
// Initialize Wi-Fi settings and start Access Point
public static void InitializeWifi()
{
var networkController = NetworkController.FromName(SC20100.NetworkController.ATWinc15x0);
//Setup Pins
var enablePinNumber = FEZBit.GpioPin.WiFiEnable;
var chipSelectPinNumber = FEZBit.GpioPin.WiFiChipselect;
var irqPinNumber = FEZBit.GpioPin.WiFiInterrupt;
var resetPinNumber = FEZBit.GpioPin.WiFiReset;
var spiControllerName = FEZBit.SpiBus.WiFi;
var gpio = GpioController.GetDefault();
var enablePin = gpio.OpenPin(enablePinNumber);
enablePin.SetDriveMode(GpioPinDriveMode.Output);
enablePin.Write(GpioPinValue.High);
SpiNetworkCommunicationInterfaceSettings networkCommunicationInterfaceSettings = new SpiNetworkCommunicationInterfaceSettings();
var settings = new SpiConnectionSettings()
{
ChipSelectLine = gpio.OpenPin(chipSelectPinNumber),
ClockFrequency = 4000000,
Mode = SpiMode.Mode0,
ChipSelectType = SpiChipSelectType.Gpio,
ChipSelectHoldTime = TimeSpan.FromTicks(10),
ChipSelectSetupTime = TimeSpan.FromTicks(10)
};
networkCommunicationInterfaceSettings.SpiApiName = spiControllerName;
networkCommunicationInterfaceSettings.GpioApiName = SC20260.GpioPin.Id;
networkCommunicationInterfaceSettings.SpiSettings = settings;
networkCommunicationInterfaceSettings.InterruptPin = gpio.OpenPin(irqPinNumber);
networkCommunicationInterfaceSettings.InterruptEdge = GpioPinEdge.FallingEdge;
networkCommunicationInterfaceSettings.InterruptDriveMode = GpioPinDriveMode.InputPullUp;
networkCommunicationInterfaceSettings.ResetPin = gpio.OpenPin(resetPinNumber);
networkCommunicationInterfaceSettings.ResetActiveState = GpioPinValue.Low;
networkController.SetCommunicationInterfaceSettings(networkCommunicationInterfaceSettings);
WiFiNetworkInterfaceSettings networkInterfaceSetting = new WiFiNetworkInterfaceSettings()
{
Ssid = "StableSwitch Net",
Password = "0123456789",
Mode = WiFiMode.AccessPoint,
Channel = 6
};
networkInterfaceSetting.Address = new GHIElectronics.TinyCLR.Networking.IPAddress (new byte[] { 192, 168, 0, 201 }); ;
networkInterfaceSetting.SubnetMask = new TinyCLRIPAddress(new byte[] { 255, 255, 255, 0 });
networkInterfaceSetting.GatewayAddress = new TinyCLRIPAddress(new byte[] { 192, 168, 0, 1 });
networkInterfaceSetting.DnsAddresses = new TinyCLRIPAddress[] { new TinyCLRIPAddress(new byte[] { 75, 75, 75, 75 }), new TinyCLRIPAddress(new byte[] { 75, 75, 75, 76 }) };
networkInterfaceSetting.DhcpEnable = true;
networkInterfaceSetting.DynamicDnsEnable = true;
networkController.SetCommunicationInterfaceSettings(networkCommunicationInterfaceSettings);
networkController.SetInterfaceSettings(networkInterfaceSetting);
networkController.SetAsDefaultController();
//networkInterfaceSetting.AccessPointClientConnectionChanged += NetworkInterfaceSetting_AccessPointClientConnectionChanged;
//networkController.NetworkAddressChanged += NetController_NetworkAddressChanged;
//networkController.NetworkLinkConnectedChanged += NetController_NetworkLinkConnectedChanged;
networkController.Enable();
Thread.Sleep(-1);
// Warten bis das Access Point aktiv ist
while (true)
{
System.Threading.Thread.Sleep(1000); // Der Access Point bleibt aktiv
}
}
}
Help would be greatly appreciated.
Best regards