this change adds support for a second Victron MPPT charge controller using a second serial connection. * Add device configuration for a second victron mppt * Update VedirectView for second victron mppt * Update MqttHandleVedirect for second victron mppt * Update MqttHandleVedirectHass for second victron mppt * Handle nonexisting victron controllers with optionals * Add bool-function to Battery and inherited classes, if uart port 2 is being used * Introduced a serial port manager. In order to prevent the battery and the Victron MPPT to use the same hw serial ports, this class keeps track of the used ports and their owners.
31 lines
820 B
C++
31 lines
820 B
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
|
|
#include "Configuration.h"
|
|
#include "Battery.h"
|
|
#include <espMqttClient.h>
|
|
#include <driver/twai.h>
|
|
#include <Arduino.h>
|
|
#include <memory>
|
|
|
|
class PylontechCanReceiver : public BatteryProvider {
|
|
public:
|
|
bool init(bool verboseLogging) final;
|
|
void deinit() final;
|
|
void loop() final;
|
|
std::shared_ptr<BatteryStats> getStats() const final { return _stats; }
|
|
bool usesHwPort2() override;
|
|
|
|
private:
|
|
uint16_t readUnsignedInt16(uint8_t *data);
|
|
int16_t readSignedInt16(uint8_t *data);
|
|
float scaleValue(int16_t value, float factor);
|
|
bool getBit(uint8_t value, uint8_t bit);
|
|
|
|
void dummyData();
|
|
|
|
bool _verboseLogging = true;
|
|
std::shared_ptr<PylontechBatteryStats> _stats =
|
|
std::make_shared<PylontechBatteryStats>();
|
|
};
|