OpenDTU-old/lib/Hoymiles/src/Hoymiles.h
Thomas Basler f689fedf4e Hoymiles Lib: Remove hard coded Serial output
The serial port for output of debug information can now changed during runtime
2022-12-19 20:52:12 +01:00

47 lines
1.4 KiB
C++

// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "HoymilesRadio.h"
#include "inverters/InverterAbstract.h"
#include "types.h"
#include <Print.h>
#include <SPI.h>
#include <memory>
#include <vector>
#define HOY_SYSTEM_CONFIG_PARA_POLL_INTERVAL (2 * 60 * 1000) // 2 minutes
#define HOY_SYSTEM_CONFIG_PARA_POLL_MIN_DURATION (4 * 60 * 1000) // at least 4 minutes between sending limit command and read request. Otherwise eventlog entry
class HoymilesClass {
public:
void init(SPIClass* initialisedSpiBus, uint8_t pinCE, uint8_t pinIRQ);
void loop();
void setMessageOutput(Print* output);
Print* getMessageOutput();
std::shared_ptr<InverterAbstract> addInverter(const char* name, uint64_t serial);
std::shared_ptr<InverterAbstract> getInverterByPos(uint8_t pos);
std::shared_ptr<InverterAbstract> getInverterBySerial(uint64_t serial);
std::shared_ptr<InverterAbstract> getInverterByFragment(fragment_t* fragment);
void removeInverterBySerial(uint64_t serial);
size_t getNumInverters();
HoymilesRadio* getRadio();
uint32_t PollInterval();
void setPollInterval(uint32_t interval);
private:
std::vector<std::shared_ptr<InverterAbstract>> _inverters;
std::unique_ptr<HoymilesRadio> _radio;
SemaphoreHandle_t _xSemaphore;
uint32_t _pollInterval = 0;
uint32_t _lastPoll = 0;
Print* _messageOutput = &Serial;
};
extern HoymilesClass Hoymiles;