Wake up by LAN using Raspberry Pi

J’ai décidé d’ajouter une fonctionnalité à mon ensemble domotique pour pouvoir allumer mon PC fixe depuis mon site web (hébergé sur mon raspberry Pi).

Rien de plus simple car il suffit d’utiliser le binaire linux etherwake disponible sur Raspbian

sudo apt-get install etherwake

puis :

/usr/sbin/etherwake 20:cf:30:ca:8a:50 (avec l'adresse MAC de la carte réseau du PC fixe).

Il faut aussi penser à bien configurer le BIOS du PC fixe pour supporter le WOL. Pour la partie WEB j’ai simplement ajouté un cas dans la passerelle :

case "CMD_WOL" :
            $aCommandToExecute = 'sudo /usr/sbin/etherwake 20:cf:30:ca:8a:50';
            echo exec($aCommandToExecute);
            break;

et ajouté un bouton :

et la callback :

$("#Bopen").click(function() 
        {
            $.ajax(
            {
                type: "POST",
                   url: "http://82.227.228.35/Sender/XbeeWrapper.php",
                   data: ({iCmdType : "CMD_WOL"}),
                   cache: false,
                   dataType: "text",
                   success: onSuccess
            });
        });
...
<input id="Bopen" type="button" name="open" value="Wake up PC"/>