-
Notifications
You must be signed in to change notification settings - Fork 0
/
WoLService.h
66 lines (46 loc) · 1.67 KB
/
WoLService.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "ENC28J60.h"
#define D1 CS_PIN
#ifndef HEADER_WOLSERVICE
#define HEADER_WOLSERVICE
class WoLService{
public:
/**
* Initializes WoLService. Instantiates ENC28J60 object and gets target's MAC address if not already found.
*/
void initialize();
/**
* Sends a magic packet with target_mac as WoL Target
*/
void SendMagicPacket();
/**
* Listens for a packet from the ethernet port, assumes it to be the target desktop, and sets the Target's MAC address as WoL target. Return true if operation is successful.
*/
bool SearchTargetMAC();
/**
* Sets Target MAC address
* @param address 6 byte array containing target's MAC address
*/
void SetTargetMAC(byte* address);
/**
* Check if target has been set.
*/
bool isTargetSet();
private:
byte target_mac_[6]; // MAC Address of WoL target
bool target_set_=false;
bool searching_ = false; //If MAC address search is in progress
ENC28J60 eth; // Ethernet interface.
// SPISettings default_settings(20000000,MSBFIRST, SPI_MODE0);
/**
* Generates a bare (length and payload only) magic packet to be sent. Returns a byte array of length 102.
* SecureWoL not supported currently
*/
byte* GenerateBareMagicPacket();
/**
* Sends a broadcast packet to get the MAC address of target computer's ethernet NIC.
* @return byte[] byte array of length 6 containing target's MAC address
*/
byte* RetrieveTargetMAC();
byte* GenerateMagicPacket();
};
#endif