xref: /openbmc/dbus-sensors/src/nvme/NVMeSensor.hpp (revision 76e0dd56c340cf11344e038979f88f59b71bff46)
1 #pragma once
2 
3 #include "Thresholds.hpp"
4 
5 #include <boost/asio/io_context.hpp>
6 #include <sdbusplus/asio/connection.hpp>
7 #include <sdbusplus/asio/object_server.hpp>
8 #include <sensor.hpp>
9 
10 #include <cstdint>
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 class NVMeSensor : public Sensor
16 {
17   public:
18     static constexpr const char* sensorType = "NVME1000";
19 
20     NVMeSensor(sdbusplus::asio::object_server& objectServer,
21                boost::asio::io_context& io,
22                std::shared_ptr<sdbusplus::asio::connection>& conn,
23                const std::string& sensorName,
24                std::vector<thresholds::Threshold>&& thresholds,
25                const std::string& sensorConfiguration, int busNumber,
26                uint8_t slaveAddr, bool smbusPEC);
27     ~NVMeSensor() override;
28 
29     NVMeSensor& operator=(const NVMeSensor& other) = delete;
30 
31     bool sample();
32 
33     const int bus;
34     const uint8_t address;
35     const bool smbusPEC;
36 
37   private:
38     const unsigned int scanDelayTicks = 5 * 60;
39     sdbusplus::asio::object_server& objServer;
40     unsigned int scanDelay{0};
41 
42     void checkThresholds() override;
43 };
44