blob: a7cfba1ae96c215c910aa79183768f8e40db481c [file] [log] [blame]
Nikhil Potadeb669b6b2019-03-13 10:52:21 -07001#pragma once
2
Ed Tanous1f978632023-02-28 18:16:39 -08003#include <boost/asio/io_context.hpp>
Nikhil Potadeb669b6b2019-03-13 10:52:21 -07004#include <sensor.hpp>
5
6class NVMeSensor : public Sensor
7{
8 public:
Zev Weiss054aad82022-08-18 01:37:34 -07009 static constexpr const char* sensorType = "NVME1000";
Andrew Jeffery0c23fc32021-12-08 16:48:30 +103010
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070011 NVMeSensor(sdbusplus::asio::object_server& objectServer,
Ed Tanous1f978632023-02-28 18:16:39 -080012 boost::asio::io_context& io,
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070013 std::shared_ptr<sdbusplus::asio::connection>& conn,
14 const std::string& sensorName,
Ed Tanous8a57ec02020-10-09 12:46:52 -070015 std::vector<thresholds::Threshold>&& thresholds,
Nnamdi Ajah06cd9882023-02-15 13:21:32 +010016 const std::string& sensorConfiguration, int busNumber,
17 uint8_t slaveAddr);
Ed Tanous74cffa82022-01-25 13:00:28 -080018 ~NVMeSensor() override;
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070019
20 NVMeSensor& operator=(const NVMeSensor& other) = delete;
21
Andrew Jeffery14108bb2022-03-21 15:00:16 +103022 bool sample();
23
Nnamdi Ajahc54f6c52023-05-02 11:02:16 +020024 const int bus;
25 const uint8_t address;
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070026
27 private:
Andrew Jeffery14108bb2022-03-21 15:00:16 +103028 const unsigned int scanDelayTicks = 5 * 60;
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070029 sdbusplus::asio::object_server& objServer;
Ed Tanousb429f312022-06-27 16:09:53 -070030 unsigned int scanDelay{0};
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070031
Ed Tanous201a1012024-04-03 18:07:28 -070032 void checkThresholds() override;
Nikhil Potadeb669b6b2019-03-13 10:52:21 -070033};