Esempio n. 1
0
        public static void Main()
        {
            // http://forums.netduino.com/index.php?/topic/322-experimental-drivers-for-wiznet-based-ethernet-shields/page__view__findpost__p__3170
            // 5C-86-4A-00-00-DD   This is a test MAC address from Secret Labs
            // Note: This MAC address should be Unique, but it should work fine on a local network (as long as there is only one instance running with this MAC)
            Networking.Adapter.Start(new byte[] { 0x5c, 0x86, 0x4a, 0x00, 0x00, 0xdd }, "mip", InterfaceProfile.Hero_Socket1_ENC28);

            // Listen for UDP messages sent to activated ports
            Networking.Adapter.OnUdpReceivedPacketEvent += new Adapter.UdpPacketReceivedEventHandler(Adapter_OnUdpReceivedPacketEvent);
            // Activate the NTP (date/time) port 123
            Networking.Adapter.ListenToPort(123);

            // Create a NTP (date/time) Request Message
            var msg = new byte[48];

            msg[0] = 0x1b;

            // Let's get the UTC time from a time zerver using a UDP Message
            UDP.SendUDPMessage(msg, new byte[4] {
                0x40, 0x5a, 0xb6, 0x37
            }, 123, 123);                                                               // 64.90.182.55 the address of a NIST time server

            // Loop to keep program alive
            while (true)
            {
                Thread.Sleep(100);
            }
        }