smbpbi: Add support for PowerState config option
This change adds support for the `PowerState` configuration option for
SmbpbiVirtualEeprom sensor.
Tested:
- EM config
```
{
"Address": 79,
"Bus": 13,
"MaxValue": 127,
"MinValue": -128,
"Name": "HGX_GPU0_TEMP_C",
"PollRate": 1,
"PowerState": "On",
"ReadOffset": 288,
"Type": "SmbpbiVirtualEeprom",
"Units": "DegreesC",
"ValueType": "UINT64"
}
```
- Host state in running
```
root@bmc:~# busctl introspect xyz.openbmc_project.SMBPBI /xyz/openbmc_project/sensors/temperature/HGX_GPU0_TEMP_C xyz.openbmc_project.State.Decorator.Availability -l
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Available property b true emits-change writable
root@bmc:~# busctl introspect xyz.openbmc_project.SMBPBI /xyz/openbmc_project/sensors/temperature/HGX_GPU0_TEMP_C xyz.openbmc_project.Sensor.Value -l
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.MaxValue property d 127 emits-change
.MinValue property d -128 emits-change
.Unit property s "xyz.openbmc_project.Sensor.Value.Unit.DegreesC" emits-change
.Value property d 79.1562 emits-change writable
```
- Host state is off
```
root@bmc:~# busctl introspect xyz.openbmc_project.SMBPBI /xyz/openbmc_project/sensors/temperature/HGX_GPU0_TEMP_C xyz.openbmc_project.State.Decorator.Availability -l
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Available property b false emits-change writable
root@bmc:~# busctl introspect xyz.openbmc_project.SMBPBI /xyz/openbmc_project/sensors/temperature/HGX_GPU0_TEMP_C xyz.openbmc_project.Sensor.Value -l
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.MaxValue property d 127 emits-change
.MinValue property d -128 emits-change
.Unit property s "xyz.openbmc_project.Sensor.Value.Unit.DegreesC" emits-change
.Value property d nan emits-change writable
```
Change-Id: Ie088c28fe337c00265556df6b14664106be39b73
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
diff --git a/src/smbpbi/SmbpbiSensor.hpp b/src/smbpbi/SmbpbiSensor.hpp
index d27fce9..e63b5b9 100644
--- a/src/smbpbi/SmbpbiSensor.hpp
+++ b/src/smbpbi/SmbpbiSensor.hpp
@@ -5,6 +5,7 @@
#pragma once
#include "Thresholds.hpp"
+#include "Utils.hpp"
#include <boost/asio/io_context.hpp>
#include <boost/asio/random_access_file.hpp>
@@ -39,7 +40,7 @@
std::vector<thresholds::Threshold>&& thresholdData, uint8_t busId,
uint8_t addr, uint16_t offset, std::string& sensorUnits,
std::string& valueType, size_t pollTime, double minVal, double maxVal,
- std::string& path);
+ std::string& path, const PowerState& powerState);
~SmbpbiSensor() override;
void checkThresholds() override;