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/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index 3545233..dda9b6f 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -89,6 +89,20 @@
baseConfiguration = &(*sensorBase);
+ // Rearm defaults to "Automatic" mode
+ bool autoRearm = true;
+ auto findRearm = baseConfiguration->second.find("Rearm");
+ if (findRearm != baseConfiguration->second.end())
+ {
+ std::string rearmStr = std::get<std::string>(findRearm->second);
+ if (rearmStr != "Automatic" && rearmStr != "Manual")
+ {
+ std::cerr << "Wrong input for Rearm parameter\n";
+ continue;
+ }
+ autoRearm = (rearmStr == "Automatic");
+ }
+
// judge class, "Gpio", "Hwmon" or "I2C"
auto findClass = baseConfiguration->second.find("Class");
if (findClass != baseConfiguration->second.end())
@@ -112,7 +126,7 @@
(std::get<std::string>(findGpioPolarity->second) ==
"Low");
pSensor = std::make_shared<ChassisIntrusionGpioSensor>(
- io, objServer, gpioInverted);
+ autoRearm, io, objServer, gpioInverted);
pSensor->start();
if (debug)
{
@@ -152,7 +166,7 @@
try
{
pSensor = std::make_shared<ChassisIntrusionHwmonSensor>(
- io, objServer, hwmonName);
+ autoRearm, io, objServer, hwmonName);
pSensor->start();
return;
}
@@ -178,7 +192,7 @@
int busId = std::get<uint64_t>(findBus->second);
int slaveAddr = std::get<uint64_t>(findAddress->second);
pSensor = std::make_shared<ChassisIntrusionPchSensor>(
- io, objServer, busId, slaveAddr);
+ autoRearm, io, objServer, busId, slaveAddr);
pSensor->start();
if (debug)
{