Fix the getStateSensorReadings command

It should be return all the composite sensors when set the sensorRearm
and reserved to 0.
When the sensorRearm property is set to 0, all composite sensors
should be returned.

Also, update the presentState property value.
s/PLDM_SENSOR_UNKNOWN/PLDM_SENSOR_NORMAL

Tested:
When the D-Bus object is not present, opState = PLDM_SENSOR_UNAVAILABLE
./pldmtool raw -v -d 0x80 0x02 0x21 0x01 0x00 0x01 0x00
Request Message:
08 01 80 02 21 01 00 01 00
Success in creating the socket : RC = 4
Success in connecting to socket : RC = 0
Success in sending message type as pldm to mctp : RC = 0
Write to socket successful : RC = 9
sd_bus_call: xyz.openbmc_project.Common.Error.ResourceNotFound: path or object not found
Total length:11
Shutdown Socket successful :  RC = 0
Response Message:
08 01 00 02 21 00 01 02 01 00 00

When the D-Bus object is present: opState = PLDM_SENSOR_ENABLED
/pldmtool raw -v -d 0x80 0x02 0x21 0x01 0x00 0x01 0x00
Request Message:
08 01 80 02 21 01 00 01 00
Success in creating the socket : RC = 4
Success in connecting to socket : RC = 0
Success in sending message type as pldm to mctp : RC = 0
Write to socket successful : RC = 9
Total length:11
Shutdown Socket successful :  RC = 0
Response Message:
08 01 00 02 21 00 01 00 01 00 01

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I3513c469e87cf3a080d01a749eaf7f574c8cafd2
diff --git a/libpldmresponder/platform_state_sensor.hpp b/libpldmresponder/platform_state_sensor.hpp
index 3fd55cd..48a750a 100644
--- a/libpldmresponder/platform_state_sensor.hpp
+++ b/libpldmresponder/platform_state_sensor.hpp
@@ -56,7 +56,7 @@
         std::cerr << e.what() << '\n';
     }
 
-    return PLDM_SENSOR_DISABLED;
+    return PLDM_SENSOR_UNKNOWN;
 }
 
 /** @brief Function to get the state sensor readings requested by pldm requester
@@ -117,6 +117,13 @@
                       << "SENSOR_REARM_COUNT=" << sensorRearmCnt << "\n";
             return PLDM_PLATFORM_REARM_UNAVAILABLE_IN_PRESENT_STATE;
         }
+
+        if (sensorRearmCnt == 0)
+        {
+            sensorRearmCnt = compSensorCnt;
+            stateField.resize(sensorRearmCnt);
+        }
+
         break;
     }
 
@@ -132,14 +139,21 @@
             handler.getDbusObjMaps(sensorId, TypeId::PLDM_SENSOR_ID);
 
         stateField.clear();
-        for (size_t i = 0; i < compSensorCnt; i++)
+        for (size_t i = 0; i < sensorRearmCnt; i++)
         {
             auto& dbusMapping = dbusMappings[i];
 
-            uint8_t sensorOpState = getStateSensorEventState<DBusInterface>(
+            uint8_t sensorEvent = getStateSensorEventState<DBusInterface>(
                 dBusIntf, dbusValMaps[i], dbusMapping);
-            stateField.push_back({PLDM_SENSOR_ENABLED, PLDM_SENSOR_UNKNOWN,
-                                  PLDM_SENSOR_UNKNOWN, sensorOpState});
+
+            uint8_t opState = PLDM_SENSOR_ENABLED;
+            if (sensorEvent == PLDM_SENSOR_UNKNOWN)
+            {
+                opState = PLDM_SENSOR_UNAVAILABLE;
+            }
+
+            stateField.push_back({opState, PLDM_SENSOR_NORMAL,
+                                  PLDM_SENSOR_UNKNOWN, sensorEvent});
         }
     }
     catch (const std::out_of_range& e)