Friday, February 6, 2015

Tasker Remote Wake On Lan

This is a followup to my previous post about setting up remote wol.  This time we will use Tasker on Android to send the request to wake up your computer.  So if you have not already set up your network to allow remote wol the read this post first.

Before We begin:

    Word of Warning:
         Both Tasker and the ssh plugin cost money so expect to spend a few dollars to make this work.  But in my mind Tasker is well worth the money and the plugin is about $0.99

    Hardware needed:
        Android smart phone
        Network set up to allow remote wol

    Software needed:
       Tasker
       SSH Tasker Plugin



I am going to show you how to create the task first and then show a few ways to use it.

1.


 Tap on the plus in the bottom right corner



Give the new task a descriptive name



Tap on the plus in the middle of the screen


Tap on Plugin in the lower left of the screen


Scroll down until you find SSH Plugin and tap on it


Tap on the pencil in the top right of the screen



Type in the user name host url or ip address, port number, password and command


It should look something like this.  Tap the floppy disk icon


Your screen should now look something like this.  Tap the Tasker icon in the top left

You are all set!  You should be able to tap the play button and wake up your remote machine


2.) Application
Now that you have the task up and working there are a few applications that I can think of off the top of my head.  First you can make a home screen shortcut on your phone that just runs the task when you click on it.  So you could modify the task to wait for a minute or so after sending the wake up command and then launch Microsoft Remote Desktop App for you or Plex.  Another idea is to turn on your computer as soon as Tasker detects your home wireless network.  That way your computer is already running by the time you walk in the house.  Or if you want to do a nightly backup and you are out of town Tasker can send the command each day at the same time, wake up the computer so it can run the backup(I have a nightly backup script that shuts the computer down after backing up).  That way you don't have to remember to do the back ups or leave your computer on while you are gone.

Remote wake on lan

There are several ways to remotely turn on a computer and this is what I ended up doing because it was the easiest for me at the time.


Before you get Started:

    Word of warning:
       This will only work if you control the network.  If you don't have access to the router that
       directly connects to the modem or public network then you won't be able to make the changes
       needed to accomplish this task.

    Hardware needed:
        public facing router
        always on machine
        computer you want to remotely turn on

    Hardware used:
        Asus RT-N66U router
        raspberry pi model B running raspbian
        Windows 8.1 desktop using an ASUS P8Z68-V PRO/GEN3 motherboard


Brief Overview
So basically what I did was to ssh into my raspberry pi which is always on and then run a wakeonlan command that would turn on my desktop.

1. Static IP address
each router has it's own user interface so it's impossible for me to explain exactly where to go but I can explain generally what you will need to do.  So first you have to be able to log into your router.  You do this by typing in the local ip address of the router in a browser of your choice.  Generally routers use ip addresses like 192.168.1.1 or 192.168.1.0 if you don't know what it is then you can generally look up online the default ip address for your specific router.  You can also look up the default username and password(which I recommend changing).  After you have logged in you will have to start navigating menus looking for wording like reserve dhcp which will generally be located in the LAN area of the menus.  Here you can reserve a specific ip address for a specific mac address.


Reserve an ip address for your always on machine.
At this point you should also look for the MAC address of the machine you want to remotely turn on and make a not of it.
Having a static ip address is very important for the next step port forwarding.

2. Port forwarding
In order to ssh into your raspberry pi you need to forward the ssh traffic through your router and to the pi.  Generally unsolicited traffic is ignored by a NAT router but in this case we want to be able to reach the router over ssh.  To do this we add an exception to the rule.  This is called port forwarding.  ssh by default uses port 22. Port forwarding needs three pieces of information.
    1.) Public port
    2.) private port
    3.) private ip address
For the public port I would recommend using a random port in the upper range of port numbers like 54623.  For the private port I used 22 because using port 22 internally is just fine and that way you don't have to change anything on the always on machine.  For the private ip address use the static one that you assigned to your always on machine in step one.

At this point you need to make sure that you have ssh enabled on your always on machine.  If you are using a raspberry pi you can follow this quick tutorial
http://www.raspberrypi.org/documentation/remote-access/ssh/

3. Install wakeonlan
on the raspberry pi open a terminal and type "sudo apt-get install wakeonlan" and follow any onscreen directions.

4.Configure computer to Wake On LAN(wol)
This is probably the most difficult part of the entire process and unfortunately the part where I can help the least.  So I apologize in advance for throwing you to the winds but the best I can do is give a general idea of what you will need to do.  The first step is changing the BIOS to allow wol.  I would recommend looking up how to do it for your specific model online.  After you have made the Change in the BIOS boot into your OS.  Now you will have to change settings inside the OS to allow WOL as well.  Again I suggest looking up how to do it for your specific OS and Network Interface Card(NIC).  After you have made all of the changes try and see if you can wake up the computer.  Power it off and go to your always on machine, open the command line and type "wakeonlan <MAC ADDRESS> where MAC ADDRESS is the actual mac address of the computer that you want to turn on.  If you did everything correctly then your computer should power on and start to run.  I spent probably about an hour trying different tutorials and chat with tech support before I could get it to work(make sure your drivers are up to date). So all i can say is Keep the Faith brother!  Keep the faith!

5. Putting it all Together
If you have made it this far congratulations!  Now you can test to see if you did everything correctly.  In order to do this yo have to try sshing into your always on machine from outside your LAN.  you can do this from work or a friends house but if it does not work then you will have to wait until you get home to figure out what went wrong.  If you have a smart phone with a data plan I would recommend tethering to it with another computer and trying to ssh into your always on computer and running the wakeonlan command.  If you did everything correctly your computer should fire right up.  Now you can access your computer with RDP or VNC even if you forgot to turn it on before you left or don't want to leave it on all the time.

6. Other thoughts
If you don't have a machine that you can leave on all the time there is still hope.  You actually already have a machine that you leave on all the time.  Your router.  If your router supports the open source firmware dd-wrt you can install it onto your router, ssh directly into your router and then send the wol command.  For more information on this please refer to the offical dd-wrt guide
http://www.dd-wrt.com/wiki/index.php/WOL

Sunday, October 26, 2014

Scroll Wheel Not working in Fedora

I was running a Fedora 20 VM on my computer and everything was working great right out of the box except the scroll wheel on my mouse.  xev was not registering the event, xinput test also did not register the scroll wheel.  The rest of the mouse worked just fine.  After trying to write a program for class all day in the VM, I finally had enough and decided to fix the problem.  Google returned almost nothing useful other then xev and xinput test.  The scroll worked just fine in windows, just not in the VM.  I have ran plenty of vm's before with no problems I was baffled.  I finally realized what the problem was.  I was using WizMouse in windows.  WizMouse is a nice little program that lets you scroll where ever your pointer is, not where the focus is.  Its great for navigating save windows or scrolling through a web page while still typing in another window.  Anyway, after killing that the scrolling worked just fine in the VM.

Monday, February 24, 2014

Send a SMS Using a NFC Tag

I lock up a building at night and when I am  done I send the same text message to the same person.  I just got some NFC tags from WhizTags.  It comes with a cool little NFC keychain so I thought I would set it up so I just have to tap my phone to the tag and send my message.  I have only tested this on my LG G2 which is rooted so YMMV.

Edit:  After running through this a few times I found a few things that might help.

  • This will send a message if you reboot your phone(have not had the time to fix this)
  • If you don't disable the Tags app(default app for nfc ) or if you have lots of nfc reading apps on your phone it will pop up a list of apps when you scan a tag.  Just choose the one that looks like the locale NFC plugin icon and says Active NFC condition
  • if you want the sms to show up in your messaging app on step 14 also select the option Store in Messaging App.


Ingredients:
    1 Android phone with NFC(I used my rooted LG G2)
    1 Tasker app from the play store
    1 Locale NFC Plugin from the play store
    1 NFC tag

1. Install Tasker and Locale NFC Plugin(Expect to pay a few bucks for these two apps)


















2. Open Tasker and press the plus sign to create a new profile



















3. Press State



















 4. Press Plugin



















5. Press Locale NFC Plugin
















6. Select Invert then click on the edit icon
















7. Select "Allow repetitive scan" then scan your NFC tag















8.  If you properly scanned your tag you should see the big green check mark and a number(its going to be different from the one in the picture).  Press the check mark















9. Double check and make sure you have selected Invert and that it says repetitive next to your tag id number.  If everything looks good, Press the Back arrow next to the tasker icon.

















10.  You should now be back to the profile screen and you should see the "New Task" option.  Press New Task

















11. Give the new task a name and then press the check mark.  I called my "Send sms"

















12. Press Phone



















13. Press Send SMS

















14. Add Phone Number and message.  You can click on the magnifying glass to search through your contact list.  When you are done.  Press the Tasker icon just like we did in step nine.
















15.  You should now be back in the Task Edit Menu.  You can add more tasks if you want but for now we will just stick with the one.  Click the Tasker icon again to take you back to the Profile menu.





 16.  Before you scan the NFC tag your profile will not be active and will be in black text.  As soon as you scan it the first time it will become an active profile.  That's it!