Public Access
feat: APC HID implementation
Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
6 files changed
+400
-12
No files matched your search
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include "nut_ups.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace nut_ups {
|
||||
|
||||
// APC HID Protocol implementation for modern APC UPS devices
|
||||
class ApcHidProtocol : public UpsProtocolBase {
|
||||
public:
|
||||
explicit ApcHidProtocol(NutUpsComponent *parent);
|
||||
|
||||
bool detect() override;
|
||||
bool initialize() override;
|
||||
bool read_data(UpsData &data) override;
|
||||
UpsProtocol get_protocol_type() const override { return PROTOCOL_APC_HID; }
|
||||
std::string get_protocol_name() const override { return "APC HID Protocol"; }
|
||||
|
||||
private:
|
||||
struct HidReport {
|
||||
uint8_t report_id;
|
||||
std::vector<uint8_t> data;
|
||||
|
||||
HidReport() : report_id(0) {}
|
||||
};
|
||||
|
||||
bool init_hid_communication();
|
||||
bool read_hid_report(uint8_t report_id, HidReport &report);
|
||||
bool write_hid_report(const HidReport &report);
|
||||
|
||||
void parse_status_report(const HidReport &report, UpsData &data);
|
||||
void parse_battery_report(const HidReport &report, UpsData &data);
|
||||
void parse_voltage_report(const HidReport &report, UpsData &data);
|
||||
void parse_power_report(const HidReport &report, UpsData &data);
|
||||
void read_device_info();
|
||||
void parse_device_info_report(const HidReport &report);
|
||||
};
|
||||
|
||||
} // namespace nut_ups
|
||||
} // namespace esphome
|
||||
Reference in new issue
Block a user