intrusionsensor: Add Rearm property
This patch adds Rearm property to intrusionsensor service, under
"xyz.openbmc_project.Chassis.Intrusion" interface, to specify the method
for rearming the chassis cover and updating the "Status" property.
As defined in Redfish schema specification, this property is optional.
If not set, "Rearm" will default to "Automatic", which will directly
update the raw chassis intrusion status to the "Status" property.
If set to "Manual", after an intrusion event, the "Status" property
will be kept to "HardwareIntrusion" until a reset action happens for it
to be set to "Normal" (manual rearm). The rearm action comes from
Redfish by writing "Normal" to the "IntrusionSensor" property in
/redfish/v1/Chassis/chassis.
Example:
{
"Class": "Aspeed2600_Hwmon",
"Name": "Chassis_Intrusion_Status",
"Rearm": "Manual",
"Type": "ChassisIntrusionSensor"
}
Tested: This has been tested on Ampere's Mt.Mitchell platform using
hwmon reading method (property values below need to be prefixed with
strings "xyz.openbmc_project.Chassis.Intrusion.Status." and
"xyz.openbmc_project.Chassis.Intrusion.RearmMode." respectively for
Status and Rearm to achieve the real values on DBus).
Automatic mode (default):
1. The chassis cover is closed => the Status property shows "Normal"
2. The chassis cover is open => Status shows "HardwareIntrusion"
Manual mode:
1. The chassis cover is first open from the last rearm action =>
"HardwareIntrusion"
2. The chassis cover is closed => "HardwareIntrusion"
3. The chassis cover is open again => "HardwareIntrusion"
4. The rearm action is taken => "Normal"
5. The chassis cover is closed => "Normal"
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
Change-Id: I8257a5fee9db67a072e7fafc140f6a143028c429
diff --git a/src/ChassisIntrusionSensor.hpp b/src/ChassisIntrusionSensor.hpp
index e3b84cf..d22eaf8 100644
--- a/src/ChassisIntrusionSensor.hpp
+++ b/src/ChassisIntrusionSensor.hpp
@@ -13,7 +13,8 @@
class ChassisIntrusionSensor
{
public:
- explicit ChassisIntrusionSensor(sdbusplus::asio::object_server& objServer);
+ explicit ChassisIntrusionSensor(bool autoRearm,
+ sdbusplus::asio::object_server& objServer);
virtual ~ChassisIntrusionSensor();
@@ -25,13 +26,14 @@
void updateValue(const size_t& value);
private:
- // intrusion status. 0: not intruded, 1: intruded
- std::string mValue = "unknown";
- std::string mOldValue = "Normal";
+ std::string mValue;
+ // If this sensor uses automatic rearm method. Otherwise, manually rearm it
+ bool mAutoRearm;
std::shared_ptr<sdbusplus::asio::dbus_interface> mIface;
sdbusplus::asio::object_server& mObjServer;
bool mOverridenState = false;
bool mInternalSet = false;
+ bool mRearmFlag = false;
int setSensorValue(const std::string& req, std::string& propertyValue);
};
@@ -41,7 +43,7 @@
public std::enable_shared_from_this<ChassisIntrusionPchSensor>
{
public:
- ChassisIntrusionPchSensor(boost::asio::io_context& io,
+ ChassisIntrusionPchSensor(bool autoRearm, boost::asio::io_context& io,
sdbusplus::asio::object_server& objServer,
int busId, int slaveAddr);
@@ -60,7 +62,7 @@
public std::enable_shared_from_this<ChassisIntrusionGpioSensor>
{
public:
- ChassisIntrusionGpioSensor(boost::asio::io_context& io,
+ ChassisIntrusionGpioSensor(bool autoRearm, boost::asio::io_context& io,
sdbusplus::asio::object_server& objServer,
bool gpioInverted);
@@ -80,7 +82,7 @@
public std::enable_shared_from_this<ChassisIntrusionHwmonSensor>
{
public:
- ChassisIntrusionHwmonSensor(boost::asio::io_context& io,
+ ChassisIntrusionHwmonSensor(bool autoRearm, boost::asio::io_context& io,
sdbusplus::asio::object_server& objServer,
std::string hwmonName);