Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wake on Lan (WOL) #25

Open
volkansari opened this issue Sep 24, 2024 · 4 comments
Open

Wake on Lan (WOL) #25

volkansari opened this issue Sep 24, 2024 · 4 comments
Labels
feature feature

Comments

@volkansari
Copy link

volkansari commented Sep 24, 2024

I have been user of Rabbit Remote Control and find its features very valuable. To further enhance its utility, I would like to suggest the addition of Wake-on-LAN (WoL) support. This feature would enable users to remotely wake up devices that are powered off or in sleep mode, making the tool even more versatile.

@volkansari volkansari added the feature feature label Sep 24, 2024
@KangLin
Copy link
Owner

KangLin commented Sep 25, 2024

WOL is supported by the operating system.

I guess you want to wake up the computer with this program?

Please describe your thoughts in detail.

@volkansari
Copy link
Author

volkansari commented Sep 25, 2024

To integrate this into Rabbit Remote Control, you could add a right-click context menu option labeled WAKE UP for each offline device in the UI. The MAC address of the device should be stored along with the connection information. When the WAKE UP option is selected, the program would call a function like sendWakeOnLanPacket() to wake up the device.

@volkansari
Copy link
Author

for example

#include <QtNetwork/QUdpSocket>
#include <QHostAddress>
#include <QByteArray>
#include <QNetworkDatagram>
#include <QDebug>

void sendWakeOnLanPacket(const QString &macAddress)
{
    // Parse the MAC address
    QStringList macBytes = macAddress.split(":");
    if (macBytes.size() != 6) {
        qDebug() << "Invalid MAC address";
        return;
    }

    QByteArray macByteArray;
    foreach (const QString &byte, macBytes) {
        bool ok;
        macByteArray.append(byte.toUInt(&ok, 16));
        if (!ok) {
            qDebug() << "Invalid byte in MAC address";
            return;
        }
    }

    // Create the magic packet
    QByteArray magicPacket;
    magicPacket.fill(0xFF, 6);  // Start with 6 bytes of 0xFF
    for (int i = 0; i < 16; ++i) {
        magicPacket.append(macByteArray);  // Repeat MAC address 16 times
    }

    // Send the packet via UDP
    QUdpSocket udpSocket;
    QHostAddress broadcastAddress("255.255.255.255");  // Broadcast address
    udpSocket.writeDatagram(magicPacket, broadcastAddress, 9);  // Use port 9

    if (udpSocket.waitForBytesWritten(3000)) {
        qDebug() << "Magic packet sent successfully!";
    } else {
        qDebug() << "Failed to send magic packet!";
    }
}

@KangLin
Copy link
Owner

KangLin commented Sep 25, 2024

There are two or more implementation methods to see which one is suitable.

  • To integrate connect dialog

WakeOnLan

  • Make a separate WOL plug-in to manage all the devices that need wake on lan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature feature
Projects
None yet
Development

No branches or pull requests

2 participants