public static void Main()
        {
            const Int32 c_port = 2000;

            byte[] ip      = { 192, 168, 1, 100 };
            byte[] subnet  = { 255, 255, 255, 0 };
            byte[] gateway = { 192, 168, 1, 1 };
            byte[] mac     = { 0x00, 0x26, 0x1C, 0x7B, 0x29, 0xE8 };
            WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10,
                                (Cpu.Pin)FEZ_Pin.Digital.Di7, true);
            NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
            NetworkInterface.EnableStaticDns(new byte[] { 192, 168, 1, 1 });
            Socket server = new Socket(AddressFamily.InterNetwork,
                                       SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, c_port);

            server.Bind(localEndPoint);
            server.Listen(1);
            while (true)
            {
                // Wait for a client to connect.
                Socket clientSocket = server.Accept();
                // Process the client request. true means asynchronous.
                new ProcessClientRequest(clientSocket, true);
            }
        }
Example #2
0
 /// <summary>
 /// Initalizes the network shield to use a static IP connection and the provided MAC address.
 /// </summary>
 /// <param name="ip">The IP address assigned to your device.</param>
 /// <param name="subnet">Your connection's subnet address</param>
 /// <param name="gateway">You connection'sgateway address</param>
 /// <param name="mac">
 /// This must be a unique MAC address value represented as a byte array.
 ///  Here is a resource for generating random MAC addresses: http://www.macvendorlookup.com/
 /// </param>
 /// <param name="dns">The IP address of your DNS server</param>
 public static void Initialize(byte[] ip, byte[] subnet, byte[] gateway, byte[] mac, byte[] dns)
 {
     // Configure the ethernet port
     WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di9, true); // WIZnet interface on FEZ Panda
     NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
     NetworkInterface.EnableStaticDns(dns);
 }
Example #3
0
        // подготовить микроконтроллер для работы с интернетом
        private void enableNetworking()
        {
            // Настраиваем Wi-Fi модуль WIZNet W5100
            WIZnet_W5100.Enable(SPI.SPI_module.SPI1,           // спецификация производителя
                                (Cpu.Pin)FEZ_Pin.Digital.Di10, // спецификация производителя
                                (Cpu.Pin)FEZ_Pin.Digital.Di7,  // ???
                                false);

            // TODO пояснить что и зачем
            // ИП аддресс для нашего микроконтроллера
            byte[] ipAddress = new byte[] { 192, 168, 17, 36 };
            byte[] netmask   = new byte[] { 255, 255, 255, 0 };
            byte[] gateway   = new byte[] { 192, 168, 17, 1 };
            // set our own mac address for this device
            byte[] macAddress = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x36 };

            // enable microcontroller to use static IP
            NetworkInterface.EnableStaticIP(ipAddress, netmask, gateway, macAddress);
        }
Example #4
0
        /// <summary>
        /// Initialize connection
        /// </summary>
        public DataPointService(Credentials credentials, string projectName, string hubId, int intervalMilliseconds)
        {
            // Configure Internet connection
            byte[] mac      = { 0x00, 0x26, 0x1C, 0x7B, 0x29, 0xE8 };
            string hostname = "idiotsdk";

            WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di7, true);
            Dhcp.EnableDhcp(mac, hostname);
            Dhcp.RenewDhcpLease();

            // Set current time
            NTPTime("pool.ntp.org");

            // Set interval between requests
            this.RequestInterval = intervalMilliseconds;

            this.username    = credentials.Username;
            this.credentials = credentials;
            this.projectName = projectName;
            this.hubId       = hubId;

            // TODO: Display info on screen module
        }
Example #5
0
 /// <summary>
 /// Initalizes the network shield to use a DHCP connection and the provided MAC address.
 /// </summary>
 /// <param name="mac">
 ///  This must be a unique MAC address value represented as a byte array.
 ///  Here is a resource for generating random MAC addresses: http://www.macvendorlookup.com/
 /// </param>
 public static void Initialize(byte[] mac)
 {
     // Configure the ethernet port
     WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di9, true); // WIZnet interface on FEZ Panda
     Dhcp.EnableDhcp(mac, "FEZDomino");
 }