| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_I2C_HWMON_BASED_SENSOR_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_I2C_HWMON_BASED_SENSOR_H_ |
| |
| #include <memory> |
| #include <optional> |
| #include <string> |
| #include <string_view> |
| |
| #include "absl/status/statusor.h" |
| #include "boost/asio.hpp" //NOLINT: boost::asio is commonly used in BMC |
| #include "hwmon_temp_sensor_config.pb.h" |
| #include "i2c_common_config.pb.h" |
| #include "tlbmc/hal/sysfs/i2c.h" |
| #include "sensor.pb.h" |
| #include "tlbmc/sensors/hwmon_based_sensor.h" |
| #include "tlbmc/sensors/sensor.h" |
| |
| namespace milotic_tlbmc { |
| |
| // This class is a base class for sensors that are based on I2C HWMon devices. |
| // All public interfaces are thread-safe. |
| // The `io_context` shall run only on a single thread. |
| class I2cHwmonBasedSensor : public HwmonBasedSensor { |
| public: |
| I2cHwmonBasedSensor( |
| const std::string& input_dev_path, |
| const std::shared_ptr<boost::asio::io_context>& io_context, |
| SensorAttributesStatic&& sensor_attributes_static, |
| std::optional<NotificationCb> on_batch_notify); |
| |
| static absl::StatusOr<boost::filesystem::path> |
| CreateDeviceAndReturnsHwmonPath(const I2cCommonConfig& i2c_config, |
| std::string_view driver_name, |
| const I2cSysfs& i2c_sysfs); |
| protected: |
| I2cHwmonBasedSensor() = default; |
| }; |
| |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_I2C_HWMON_BASED_SENSOR_H_ |