public RealDeployerFactory(EthernetENC28J60 ethernet, StorageDevice storageDevice, BreakoutTB10 breakout,
                            CharacterDisplay characterDisplay,
                            Tunes tunes)
 {
     _ethernet = ethernet;
     _storageDevice = storageDevice;
     _breakout = breakout;
     _characterDisplay = characterDisplay;
     _tunes = tunes;
 }
Ejemplo n.º 2
0
 public RealDeployerFactory(EthernetENC28J60 ethernet, StorageDevice storageDevice, BreakoutTB10 breakout,
                            CharacterDisplay characterDisplay,
                            Tunes tunes)
 {
     _ethernet         = ethernet;
     _storageDevice    = storageDevice;
     _breakout         = breakout;
     _characterDisplay = characterDisplay;
     _tunes            = tunes;
 }
Ejemplo n.º 3
0
        internal static void Initialize()
        {
            ethernet_Modul = new EthernetENC28J60(SPI.SPI_module.SPI2, G120.P1_10, G120.P2_11, G120.P1_9);
            ethernet_Modul.Open();
            ethernet_Modul.EnableDhcp();
            ethernet_Modul.EnableDynamicDns();

            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
            NetworkChange.NetworkAddressChanged      += NetworkChange_NetworkAddressChanged;

            Debug.Print("Ethernet initialized.");
        }
Ejemplo n.º 4
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public EthernetENC28(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('S', this);

            socket.ReservePin(Socket.Pin.Three, this);
            socket.ReservePin(Socket.Pin.Four, this);
            socket.ReservePin(Socket.Pin.Six, this);

            this.spi = GTI.SpiFactory.Create(socket, null, GTI.SpiSharing.Exclusive, socket, Socket.Pin.Six, this);
            this.networkInterface = new EthernetENC28J60(socket.SPIModule, socket.CpuPins[6], socket.CpuPins[3], socket.CpuPins[4], 4000);

            this.NetworkSettings = this.networkInterface.NetworkInterface;
        }
Ejemplo n.º 5
0
        public EthernetManager(EthernetENC28J60 ethernetInterface = null)
        {
            isBuiltIn = ethernetInterface == null;

            if (!isBuiltIn)
            {
                ethernet = ethernetInterface;
                (ethernet as EthernetENC28J60).CableConnectivityChanged += (object sender, EthernetENC28J60.CableConnectivityEventArgs e) => { ethernet_CableConnectivityChanged(sender, e.IsConnected); };
            }
            else
            {
                ethernet = new EthernetBuiltIn();
                (ethernet as EthernetBuiltIn).CableConnectivityChanged += (object sender, EthernetBuiltIn.CableConnectivityEventArgs e) => { ethernet_CableConnectivityChanged(sender, e.IsConnected); };
            }

            ethernet.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(ethernet_NetworkAddressChanged);
        }
Ejemplo n.º 6
0
        public EthernetManager(EthernetENC28J60 ethernetInterface = null)
        {
            isBuiltIn = ethernetInterface == null;

            if (!isBuiltIn)
            {
                ethernet = ethernetInterface;
                (ethernet as EthernetENC28J60).CableConnectivityChanged += (object sender, EthernetENC28J60.CableConnectivityEventArgs e) => { ethernet_CableConnectivityChanged(sender, e.IsConnected); };
            }
            else
            {
                ethernet = new EthernetBuiltIn();
                (ethernet as EthernetBuiltIn).CableConnectivityChanged += (object sender, EthernetBuiltIn.CableConnectivityEventArgs e) => { ethernet_CableConnectivityChanged(sender, e.IsConnected); };
            }

            ethernet.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(ethernet_NetworkAddressChanged);
        }
Ejemplo n.º 7
0
        public VolumioRestApiPlayer(Cpu.Pin chipSelect, Cpu.Pin externalInterrupt, Cpu.Pin reset)
        {
            commands = new QueueThreadWorker(ProcessCommand, "httpRequestsThread", ThreadPriority.Lowest);

            var netif = new EthernetENC28J60(SPI.SPI_module.SPI2, chipSelect, externalInterrupt /*, reset*/);

            netif.Open();
            ////netif.EnableDhcp();
            ////netif.EnableDynamicDns();
            netif.EnableStaticIP("169.254.194.93", "255.255.0.0", "0.0.0.0");
            int attemps = 0;

            while (netif.IPAddress != "169.254.194.93" && attemps++ < 4)
            {
                System.Threading.Thread.Sleep(250);
            }
            Inited = true;

            CheckStatusThread.Start();
        }
Ejemplo n.º 8
0
        public static void Main()
        {
            if (null == eth1)
                eth1 = new EthernetENC28J60(SPI.SPI_module.SPI2, G400.PC22, G400.PC31, G400.PA5);

            if (!eth1.Opened)
                eth1.Open();

            eth1.EnableDhcp();
            eth1.EnableDynamicDns();

            Debug.Print("Waiting for DHCP...");
            while (eth1.IPAddress == "0.0.0.0")
                Thread.Sleep(250);

            Debug.Print("Network Ready");

            client = new Client("NETmfG400D");
            client.Start();

            Thread.Sleep(Timeout.Infinite);
        }
Ejemplo n.º 9
0
        private static void SetupNetwork()
        {
            const string suntimeUpdateFormat     = "{0} - {1}: {2}";
            const string suntimeUpdateTypeThread = "Thread";
            const string suntimeUpdateTypeInit   = "Init";
            const string suntimeUpdateSunrise    = "Sunrise";
            const string suntimeUpdateSunset     = "Sunset";
            int          currentDay = DateTime.Now.DayOfYear;

            Trace.TraceInformation("Setting up networking...");

            ethernet = new EthernetENC28J60(SPI.SPI_module.SPI2, Pin.P1_10, Pin.P2_11, Pin.P1_9, 4000);

            ethernet.NetworkAddressChanged +=
                (o, e) =>
            {
                if (ethernet.NetworkInterface.IPAddress == "0.0.0.0")
                {
                    return;
                }

                Trace.TraceInformation("IP Address: {0}", ethernet.NetworkInterface.IPAddress);

                time.EnsureTime(true);

                time.GetSunTimes(out sunrise, out sunset);
                Trace.TraceInformation(suntimeUpdateFormat, suntimeUpdateTypeInit, suntimeUpdateSunrise, sunrise.ToString());
                Trace.TraceInformation(suntimeUpdateFormat, suntimeUpdateTypeInit, suntimeUpdateSunset, sunset.ToString());

                //new System.Threading.Timer(
                //    (state) =>
                //    {
                //        time.GetSunTimes(out sunrise, out sunset);
                //        Trace.TraceInformation(suntimeUpdateFormat, suntimeUpdateTypeThread, suntimeUpdateSunrise, sunrise.ToString());
                //        Trace.TraceInformation(suntimeUpdateFormat, suntimeUpdateTypeThread, suntimeUpdateSunset, sunset.ToString());
                //    },
                //    null,
                //    DateTime.Today.AddHours(24) - DateTime.Now.AddMinutes(-5),
                //    new TimeSpan(24, 0, 0));

                try
                {
                    Trace.TraceInformation("Sunrise/set updater...");
                    new Thread(
                        () =>
                    {
                        while (true)
                        {
                            // 1 min? 5 mins? 1 hour?
                            Thread.Sleep(60000);

                            if (DateTime.Now.DayOfYear != currentDay)
                            {
                                currentDay = DateTime.Now.DayOfYear;

                                time.GetSunTimes(out sunrise, out sunset);
                                Trace.TraceInformation(suntimeUpdateFormat, suntimeUpdateTypeThread, suntimeUpdateSunrise, sunrise.ToString());
                                Trace.TraceInformation(suntimeUpdateFormat, suntimeUpdateTypeThread, suntimeUpdateSunset, sunset.ToString());
                            }
                        }
                    }).Start();
                }
                catch (Exception ex)
                {
                    Trace.TraceInformation("Sunrise/set updater exception: {0}", ex.Message);
                }
            };

            ethernet.CableConnectivityChanged +=
                (o, e) =>
            {
                Trace.TraceInformation("Network cable is {0}", e.IsConnected ? "connected" : "disconnected");
            };

            if (!ethernet.IsOpen)
            {
                ethernet.Open();
            }

            if (settings.Network.IPType == Constants.NetworkIPType.DHCP)
            {
                if (!ethernet.NetworkInterface.IsDhcpEnabled)
                {
                    ethernet.NetworkInterface.EnableDhcp();
                }
                else
                {
                    ethernet.NetworkInterface.RenewDhcpLease();
                }
            }
            else
            {
                var ip      = settings.Network.IPAddress;
                var subnet  = settings.Network.Subnet;
                var gateway = settings.Network.Gateway;

                ethernet.NetworkInterface.EnableStaticIP(ip, subnet, gateway);
                ethernet.NetworkInterface.EnableStaticDns(new string[] { gateway });
            }

            NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet);
        }
Ejemplo n.º 10
0
        /// <summary>Constructs a new instance.</summary>
        public FEZCerbuinoNet()
        {
            this.configSet           = false;
            this.debugLed            = null;
            this.ethernet            = null;
            this.storageDevices      = new IRemovable[2];
            this.sdCardStorageDevice = null;

            RemovableMedia.Insert += this.OnInsert;
            RemovableMedia.Eject  += this.OnEject;

            Controller.MouseConnected += (a, b) => {
                this.connectedMouse = b;
                this.OnMouseConnected(this, b);

                b.Disconnected += (c, d) => this.connectedMouse = null;
            };

            Controller.KeyboardConnected += (a, b) => {
                this.connectedKeyboard = b;
                this.OnKeyboardConnected(this, b);

                b.Disconnected += (c, d) => this.connectedKeyboard = null;
            };

            Controller.MassStorageConnected += (a, b) => {
                this.IsMassStorageConnected = true;

                this.MountStorageDevice("USB");

                b.Disconnected += (c, d) => {
                    this.IsMassStorageConnected = false;

                    if (this.IsMassStorageMounted)
                    {
                        this.UnmountStorageDevice("USB");
                    }
                };
            };

            this.IsSDCardMounted        = false;
            this.IsMassStorageConnected = false;
            this.IsMassStorageMounted   = false;

            this.sdCardDetect              = new InterruptPort(FEZCerbuinoNetPins.SdCardDetect, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
            this.sdCardDetect.OnInterrupt += this.OnSDCardDetect;

            if (this.IsSDCardInserted)
            {
                this.MountStorageDevice("SD");
            }

            Controller.Start();

            this.NativeBitmapConverter = this.NativeBitmapConvert;
            this.NativeBitmapCopyToSpi = this.NativeBitmapSpi;

            #region Sockets
            GT.SocketInterfaces.I2CBusIndirector nativeI2C = (s, sdaPin, sclPin, address, clockRateKHz, module) => new InteropI2CBus(s, sdaPin, sclPin, address, clockRateKHz, module);
            GT.Socket socket;

            socket = GT.Socket.SocketInterfaces.CreateNumberedSocket(1);
            socket.SupportedTypes = new char[] { 'P', 'S', 'U', 'X' };
            socket.CpuPins[3]     = FEZCerbuinoNetPins.Socket1.Pin3;
            socket.CpuPins[4]     = FEZCerbuinoNetPins.Socket1.Pin4;
            socket.CpuPins[5]     = FEZCerbuinoNetPins.Socket1.Pin5;
            socket.CpuPins[6]     = FEZCerbuinoNetPins.Socket1.Pin6;
            socket.CpuPins[7]     = FEZCerbuinoNetPins.Socket1.Pin7;
            socket.CpuPins[8]     = FEZCerbuinoNetPins.Socket1.Pin8;
            socket.CpuPins[9]     = FEZCerbuinoNetPins.Socket1.Pin9;
            socket.SerialPortName = "COM1";
            socket.PWM7           = Cpu.PWMChannel.PWM_6;
            socket.PWM8           = Cpu.PWMChannel.PWM_7;
            socket.PWM9           = (Cpu.PWMChannel) 8;
            socket.SPIModule      = SPI.SPI_module.SPI1;
            GT.Socket.SocketInterfaces.RegisterSocket(socket);

            socket = GT.Socket.SocketInterfaces.CreateNumberedSocket(2);
            socket.SupportedTypes   = new char[] { 'A', 'I', 'K', 'U', 'Y' };
            socket.CpuPins[3]       = FEZCerbuinoNetPins.Socket2.Pin3;
            socket.CpuPins[4]       = FEZCerbuinoNetPins.Socket2.Pin4;
            socket.CpuPins[5]       = FEZCerbuinoNetPins.Socket2.Pin5;
            socket.CpuPins[6]       = FEZCerbuinoNetPins.Socket2.Pin6;
            socket.CpuPins[7]       = FEZCerbuinoNetPins.Socket2.Pin7;
            socket.CpuPins[8]       = FEZCerbuinoNetPins.Socket2.Pin8;
            socket.CpuPins[9]       = FEZCerbuinoNetPins.Socket2.Pin9;
            socket.I2CBusIndirector = nativeI2C;
            socket.SerialPortName   = "COM2";
            socket.AnalogInput3     = Cpu.AnalogChannel.ANALOG_0;
            socket.AnalogInput4     = Cpu.AnalogChannel.ANALOG_1;
            socket.AnalogInput5     = Cpu.AnalogChannel.ANALOG_2;
            GT.Socket.SocketInterfaces.SetAnalogInputFactors(socket, 3.3, 0, 12);
            GT.Socket.SocketInterfaces.RegisterSocket(socket);

            socket = GT.Socket.SocketInterfaces.CreateNumberedSocket(3);
            socket.SupportedTypes   = new char[] { 'A', 'O', 'P', 'Y' };
            socket.CpuPins[3]       = FEZCerbuinoNetPins.Socket3.Pin3;
            socket.CpuPins[4]       = FEZCerbuinoNetPins.Socket3.Pin4;
            socket.CpuPins[5]       = FEZCerbuinoNetPins.Socket3.Pin5;
            socket.CpuPins[6]       = FEZCerbuinoNetPins.Socket3.Pin6;
            socket.CpuPins[7]       = FEZCerbuinoNetPins.Socket3.Pin7;
            socket.CpuPins[8]       = FEZCerbuinoNetPins.Socket3.Pin8;
            socket.CpuPins[9]       = FEZCerbuinoNetPins.Socket3.Pin9;
            socket.I2CBusIndirector = nativeI2C;
            socket.PWM7             = (Cpu.PWMChannel) 14;
            socket.PWM8             = Cpu.PWMChannel.PWM_1;
            socket.PWM9             = (Cpu.PWMChannel) 15;
            socket.AnalogOutput5    = Cpu.AnalogOutputChannel.ANALOG_OUTPUT_0;
            socket.AnalogInput3     = Cpu.AnalogChannel.ANALOG_3;
            socket.AnalogInput4     = Cpu.AnalogChannel.ANALOG_4;
            socket.AnalogInput5     = Cpu.AnalogChannel.ANALOG_5;
            GT.Socket.SocketInterfaces.SetAnalogInputFactors(socket, 3.3, 0, 12);
            GT.Socket.SocketInterfaces.SetAnalogOutputFactors(socket, 3.3, 0, 12);
            GT.Socket.SocketInterfaces.RegisterSocket(socket);

            #endregion Sockets
        }
Ejemplo n.º 11
0
 public NetworkWrapper(EthernetENC28J60 ether)
 {
     _ether = ether;
 }
Ejemplo n.º 12
0
		public NetworkWrapper(EthernetENC28J60 ether)
		{
			_ether = ether;
		}