Exemplo n.º 1
0
//
// UDP stuff
//
void sendUDPmessage( String msg, int port = 5100 )
{
    IPAddress multicast( 225, 1, 1, 1 );
    UDP server;
    
    if ( server.begin( port ) )
    {
        server.beginPacket( multicast, port );
        server.write( msg );
        server.endPacket();
        
        server.stop();
    }
}
Exemplo n.º 2
0
int WolClient::wake(const char* mac) {
    uint8_t contents[MAGIC_HEADER_LENGTH + REPEAT_MAC * MAC_BYTES];
    uint8_t rawMac[MAC_BYTES];

    parseMacAddress(mac, rawMac);

    UDP udp;
    udp.begin(port);
    udp.beginPacket(broadcastIP, port);

    for (int i = 0; i < MAGIC_HEADER_LENGTH; i++) {
        contents[i] = 0xFF;
    }
    for (uint8_t i = MAGIC_HEADER_LENGTH; i < sizeof contents; i++) {
        contents[i] = rawMac[(i - MAGIC_HEADER_LENGTH) % MAC_BYTES];
    }

    udp.write(contents, sizeof contents);

    udp.endPacket();
    udp.stop();

    return TRUE;
}