I had a question the other day from Lee Hung Nguyen or MrLee as he is known on his website.

I’ve always wanted to be able to remote access my PC via a mobile phone SMS. I’ve done some research, and the best I’ve found is to be able to remote control your server at home via twitter updates. Which would be pointless if your offline.
I want to be able to connect a $2 simcard + old crappy nokia via a usb cable to my server, and be able to send commands to it only via my mobile number “key commands” such as reboot, shut down, etc.

Ok well I thought about this one for a while Lee and it can be done, sort of.

The main issue here seems to be turning the PC on. Once the PC is on then TweetMyPC already does everything you want to do.

TweetMyPC

If you haven’t used TweetMyPC then you can download it from here.

Essentially this allows you to use a dedicated twitter account to capture tweets and control your PC. If you have a mobile phone which allows you to use Twitter from it, which most do as all the mobile providers are pushing it and offering free Twittering for 3 months deals etc, then you can tweet away from the phone.

On the PC it does require installing a dedicated bit of software (link above) which is a VB.NET application and it monitors the twitter account and does all the leg work for you. Anyway, I will leave people to read about that one at their leisure rather than reproduce info that’s already out there.

BootMyPC

Using the USB input didn’t appear to be an option as the PC would need to be powered up to power the USB adapter. Maybe it is possible but that, as a solution, is beyond my scope at the moment.

So now on to the missing link.I have used the .NET Compact Framework 3.5 and my old Samsung Blackjack to be the missing link. Here is the lay of the land.

qwe4xngb

One thing you will need to do is make sure the Network Adapter on the PC you want to wake up is enabled for WOL. You can see how to do this in Windows 7 below by selecting the Properties of your network adapter.

ogyoymwr

I borrowed the key bits of code courtesy of MSDN and The Code Project that posted their solutions for us. Thanks and praise below :-)

First off we need to subscribe to the event to capture the SMS Message:

publicvoid Start() { // Create MessageInterceptor object and subscribe to the MessageReceived Event messageMonitor = new MessageInterceptor(); messageMonitor.InterceptionAction = InterceptionAction.Notify; messageMonitor.MessageCondition.CaseSensitive = false; messageMonitor.MessageReceived += new MessageInterceptorEventHandler(messageMonitor_MessageReceived); // Raise an event to notify the UI of Startup Notify("Started"); }

And secondly we need to send the Magic Packet out over the network. Thanks to maxburov for this piece of code which I adapted slightly:

privatevoid Wakeup() { try { WakeOnLan client = new WakeOnLan(); client.Connect(new IPAddress(0xffffffff), //255.255.255.255 i.e broadcast 0x2fff); // port=12287 let's use this one client.SetClientToBrodcastMode(); //set sending bitesbyte[] bytes = newbyte[1024]; // more than enough :-)//first 6 bytes should be 0xFFint counter = 0; for (int y = 0; y < 6; y++) { bytes[counter++] = 0xFF; } //now repeat MAC 16 timesfor (int y = 0; y < 16; y++) { int i = 0; for (int z = 0; z < 6; z++) { bytes[counter++] = byte.Parse(MacAddress.Substring(i, 2), NumberStyles.HexNumber); i += 2; } } //now send wake up packetint returned_value = client.Send(bytes, 1024); Notify("Wake Up"); } catch (Exception ex) { Notify(string.Format("Error:{0}", ex.Message)); } }

You can find the full source code and install package for WinMo 5 or 6 Application below:

Here is the beautiful Windows Mobile 5/6 App (Yes I am being very sarcastic) that does the job:

IMG_8211

It accepts a Mobile Phone number, MAC Address and displays the messages as they are received.

The Mobile number is the one that you will be sending from, any others are ignored for security reasons. The MAC address is the MAC Address of the PC on the LAN that you want to wake up.

Conclusion:

This is not an ideal solution as the PC you want to switch on needs to be on a network, but in this day and age of ADSL everywhere and on all the time that is not such a big hurdle.

The other issue is that the mobile phone will need to be plugged in and connected via wireless continuously which is likely to drop out.

Creating this app reminded me how prehistoric developing apps for Windows Mobile is. Roll on the SDK for Windows Phone 7 and the launch of the phones. RIP Windows Mobile.

However, it can be done via a mobile phone and creating this solution was a bit of fun.

BondiGeek