xref: /openbmc/dbus-sensors/src/nvme/NVMeSensor.hpp (revision 18b6186e531ae37dd22b634c6530f793528473f4)
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);
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 
36   private:
37     const unsigned int scanDelayTicks = 5 * 60;
38     sdbusplus::asio::object_server& objServer;
39     unsigned int scanDelay{0};
40 
41     void checkThresholds() override;
42 };
43