37 lines
748 B
C++
37 lines
748 B
C++
|
|
#include <PubSubClient.h>
|
|
#include <WakeOnLan.h>
|
|
#include "MqttWOLManager.h"
|
|
|
|
MqttWOLManager::MqttWOLManager()
|
|
{
|
|
topic[0]=0;
|
|
}
|
|
void MqttWOLManager::inicia(WakeOnLan *pwol)
|
|
{
|
|
wol=pwol;
|
|
}
|
|
void MqttWOLManager::loop()
|
|
{
|
|
|
|
}
|
|
int MqttWOLManager::OnMqtt(char* top, char* payload)
|
|
{
|
|
if(strcmp(top,topic))
|
|
return -1;
|
|
|
|
wol->sendMagicPacket(payload); // Send Wake On Lan packet with the above MAC address. Default to port 9.
|
|
#ifdef DEBUG_PS
|
|
Serial.print("Enviado wol a: ");
|
|
Serial.println(payload);
|
|
#endif
|
|
// WOL.sendMagicPacket(MACAddress, 7); // Change the port number
|
|
return 1;
|
|
}
|
|
void MqttWOLManager::suscribe(PubSubClient *client_qqtt)
|
|
{
|
|
if(!topic[0])
|
|
return;
|
|
client_qqtt->subscribe(topic);
|
|
}
|