Wake-on-LAN from a .NET Micro Framework Device

Tags: .NET, .NET Micro Framework, AJAX, Ajax.NET, Source Code

Well, I love the easy development of embedded devices with the .NET Micro Framework. As the device I'm currently using is really small I tried to build a small Web site on it to start my private servers at home using Wake-on-LAN. You'll find a lot of helper methods samples on the Internet but I couldn't find on source code that was working on the .NET Micro Framework. The problem is that there are too many missing methods or enum values.

Here is the source code I'm using now which is working.

public static void WakeUp(byte[] mac) { using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) { IPEndPoint endPoint = new IPEndPoint(new IPAddress(4294967295), 40000); // IP 255.255.255.255 socket.Connect(endPoint); byte[] packet = new byte[17 * 6]; for (int i = 0; i < 6; i++) packet[i] = 0xFF; for (int i = 1; i <= 16; i++) for (int j = 0; j < 6; j++) packet[i * 6 + j] = mac[j]; socket.Send(packet); } }

Using my Web server (which I will publish this week at http://www.codeplex.com/ajaxnetmicro) including the Ajax.NET M! library it is really cool to connect to the .NET Micro Framework enabled device from outside and start your servers as you need.

No Comments