Facility Control

 View Only
  • 1.  Dashboard WOL (wake on lan)

    Posted 11-28-2023 16:57

    Hi,

    I would like to do a WOL.

    Here, function that i use in javascript... Is somebody can help me to translate it inside dashboard? Thx a lot,

     
    function wakeOnLAN(macAddress, ipAddress, port) {
        
        const macBytes = macAddress.split(':').map(hex => parseInt(hex, 16));
        const magicPacket = new Uint8Array(6 + 16 * macBytes.length);
     
        
        magicPacket.fill(0xFF, 0, 6);
     
        
       /for (let i = 6; i < magicPacket.length; i += macBytes.length) {
            magicPacket.set(macBytes, i);
        }
        rosstalk.sendMessageWithResponse(ipAddress, port, magicPacket+'\n', '\n', callback);
    }
    Best regards,


    ------------------------------
    Sylvain Menet
    Technical Manager
    Dreamwall
    ------------------------------


  • 2.  RE: Dashboard WOL (wake on lan)

    Ross Staff
    Posted 12-12-2023 11:34

    Hi Sylvain,

    To translate this code to ogscript, we use translate the map to manually fill the array with Parsed Ints and make use of a message builder. Since the first 6 values would always be 255, we directly push 255 into the message builder. After this, we loop through the macBytes array and insert into the magicBuilder until it fills 102 positions which when subtracted with the first six positions becomes 96. So we loop though it 16 times (16 times 6 would be 96).

    Here is the code for your reference:

    var macAddress = "00:1A:2B:3C:4D:5E";
    var macParts = macAddress.split(':');
    var macBytes = []; 
    for (var i = 0; i < macParts.length; i++) 
     {
      var decimalInt = parseInt(macParts[i], 16);
      macBytes.push(decimalInt);
     }
    
    var magicPacket = ogscript.createMessageBuilder(); 
    
    for (var i = 0; i < 6; i++) 
     {
      magicPacket.writeByte(255);
     }
    for (var i = 0; i < 16; i++) 
     {
      for (var j = 0; j < macParts.length; j++) 
       {
         magicPacket.writeByte(macBytes[j]);
       }
     }
    var messageArray = magicPacket.toByteArray();
    for (var j = 0; j < messageArray.length; j++) 
     {
       ogscript.debug(messageArray[j]);
     }

    I hope this helps!

    Best Regards,



    ------------------------------
    Altaz Daruwala
    Ross Video
    ------------------------------