hey guys
I try to send a Wake on LAN "Magic Packet" with my Arduino Ethernet. This "Magic Packet" is quite easy, 6 x "0xff" then 16 x the mac address, so the payload should be 102 bytes (raw data, without headers). My captured packet is only 38 bytes large, I guess the SENDING buffer is limited.
Here is the code I use:
byte broadcastAddress[] = { 255, 255, 255, 255 }; //to verify!
//send wol magic pajet
void WOL(byte mac[]) {
#ifdef USE_SERIAL_DEBUG
Serial.print("Send WOL... ");
#endif
byte i;
//Starts a connection to write UDP data to the remote connection, parameter: remoteIP, remotePort
//Hint about port 7: Since the magic packet is only scanned for the string above, and not actually
//parsed by a full protocol stack, it may be sent as any network- and transport-layer protocol, although
//it is typically sent as a UDP datagram to port 7 or 9
Udp.beginPacket(broadcastAddress, 7);
//Writes UDP data to the remote connection. Must be wrapped between beginPacket() and endPacket().
//Start of WOL magic paket (preamble)
for (i=0; i<6; i++) {
Udp.write(0xff);
}
//the wol packet contains 16 times the mac address
//NOTE: BUG here, we cannot send more than 46 bytes...
for (i=0; i<16; i++) {
Udp.write(mac, sizeof mac);
}
//Called after writing UDP data to the remote connection.
Udp.endPacket();
#ifdef USE_SERIAL_DEBUG
Serial.println("done!");
#endif
}
I took a look at the EthernetUDP class, all I found was a
#define UDP_TX_PACKET_MAX_SIZE 24
which is a bit unrelated I guess. Can someone help me?
Cheers