OpenDTU-old/lib/Hoymiles/src/inverters/HMT_Abstract.cpp
Thomas Basler 0ffbba0cf5 Fix: Allow sending of ChannelChangeCommand even if EnableCommands is disabled
This is required to successfull move the inverter to another frequency and then polling it. Without this command its not even possible to poll a inverter.

Fixes #1127
2023-07-10 18:30:59 +02:00

28 lines
827 B
C++

// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2023 Thomas Basler and others
*/
#include "HMT_Abstract.h"
#include "Hoymiles.h"
#include "HoymilesRadio_CMT.h"
#include "commands/ChannelChangeCommand.h"
#include "parser/AlarmLogParser.h"
HMT_Abstract::HMT_Abstract(HoymilesRadio* radio, uint64_t serial)
: HM_Abstract(radio, serial)
{
EventLog()->setMessageType(AlarmMessageType_t::HMT);
};
bool HMT_Abstract::sendChangeChannelRequest()
{
if (!(getEnableCommands() || getEnablePolling())) {
return false;
}
ChannelChangeCommand* cmdChannel = _radio->enqueCommand<ChannelChangeCommand>();
cmdChannel->setChannel(HoymilesRadio_CMT::getChannelFromFrequency(Hoymiles.getRadioCmt()->getInverterTargetFrequency()));
cmdChannel->setTargetAddress(serial());
return true;
};