blob: 31afbf361b2353361448cc430ce7ef3e608ea5f6 [file] [log] [blame]
Nikhil Potadeb669b6b2019-03-13 10:52:21 -07001#pragma once
2
Ed Tanous18b61862025-01-30 10:56:28 -08003#include "Thresholds.hpp"
4
Ed Tanous1f978632023-02-28 18:16:39 -08005#include <boost/asio/io_context.hpp>
Ed Tanous18b61862025-01-30 10:56:28 -08006#include <sdbusplus/asio/connection.hpp>
7#include <sdbusplus/asio/object_server.hpp>
Nikhil Potadeb669b6b2019-03-13 10:52:21 -07008#include <sensor.hpp>
9
Ed Tanous18b61862025-01-30 10:56:28 -080010#include <cstdint>
11#include <memory>
12#include <string>
13#include <vector>
14
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070015class NVMeSensor : public Sensor
16{
17 public:
Zev Weiss054aad82022-08-18 01:37:34 -070018 static constexpr const char* sensorType = "NVME1000";
Andrew Jeffery0c23fc32021-12-08 16:48:30 +103019
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070020 NVMeSensor(sdbusplus::asio::object_server& objectServer,
Ed Tanous1f978632023-02-28 18:16:39 -080021 boost::asio::io_context& io,
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070022 std::shared_ptr<sdbusplus::asio::connection>& conn,
23 const std::string& sensorName,
Ed Tanous8a57ec02020-10-09 12:46:52 -070024 std::vector<thresholds::Threshold>&& thresholds,
Nnamdi Ajah06cd9882023-02-15 13:21:32 +010025 const std::string& sensorConfiguration, int busNumber,
26 uint8_t slaveAddr);
Ed Tanous74cffa82022-01-25 13:00:28 -080027 ~NVMeSensor() override;
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070028
29 NVMeSensor& operator=(const NVMeSensor& other) = delete;
30
Andrew Jeffery14108bb2022-03-21 15:00:16 +103031 bool sample();
32
Nnamdi Ajahc54f6c52023-05-02 11:02:16 +020033 const int bus;
34 const uint8_t address;
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070035
36 private:
Andrew Jeffery14108bb2022-03-21 15:00:16 +103037 const unsigned int scanDelayTicks = 5 * 60;
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070038 sdbusplus::asio::object_server& objServer;
Ed Tanousb429f312022-06-27 16:09:53 -070039 unsigned int scanDelay{0};
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070040
Ed Tanous201a1012024-04-03 18:07:28 -070041 void checkThresholds() override;
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070042};