Expose granular telemetry error statuses in Redfish OEM schema

Updates Redfish sensor handlers ('routes/sensor.cc') to explicitly map all store status enums to standard DMTF states and Google OEM strings:
-> Maps all unhealthy sensor statuses ('STATUS_DRIVER_READ_ERROR', 'STATUS_INVALID_DATA', 'STATUS_STALE', etc.) to standard DMTF 'State: Disabled'.
-> Exposes machine-readable status strings ('DriverReadError', 'InvalidData', 'Stale', 'CreationFailed') under 'Status.Oem.Google.SensorState'.


Google-Bug-Id:511201651
PiperOrigin-RevId: 974054696
(cherry picked from commit e09ed69f6a4788f80234fe17f33cd8701a675975)
Change-Id: I4e87f0974afb1e1b1a84aacc482e5c0decfa1f30
diff --git a/tlbmc/redfish/routes/sensor.cc b/tlbmc/redfish/routes/sensor.cc
index 9acc3e3..8d9aeda 100644
--- a/tlbmc/redfish/routes/sensor.cc
+++ b/tlbmc/redfish/routes/sensor.cc
@@ -191,6 +191,23 @@
                                    "Sensors", sensor_id}));
 }
 
+std::string_view GetOemSensorStateString(Status status) {
+  switch (status) {
+    case STATUS_STALE:
+      return "Stale";
+    case STATUS_CREATION_FAILED:
+      return "CreationFailed";
+    case STATUS_DRIVER_READ_ERROR:
+      return "DriverReadError";
+    case STATUS_INVALID_DATA:
+      return "InvalidData";
+    case STATUS_OTHER_ERROR:
+      return "OtherError";
+    default:
+      return "Unknown";
+  }
+}
+
 }  // namespace
 
 void FillResponseWithSensorData(
@@ -199,7 +216,8 @@
     const Store& store) {
   const SensorAttributesDynamic attributes_dynamic =
       sensor->GetSensorAttributesDynamic();
-  switch (attributes_dynamic.state().status()) {
+  const Status status = attributes_dynamic.state().status();
+  switch (status) {
     case STATUS_READY: {
       std::string_view health = kHealthOk;
       double reading = sensor->GetSensorData()->reading();
@@ -234,7 +252,7 @@
       resp.SetKeyInJsonBody(sensor_pointer / "Status" / "State", "Absent");
       resp.SetKeyInJsonBody(sensor_pointer / "Reading", nullptr);
       break;
-    default:
+    default: {
       // We will always return a sensor regardless of status. For unhealthy
       // sensors, we will return a Disabled status and a detailed error message.
       nlohmann::json error_message_json;
@@ -245,8 +263,12 @@
           attributes_dynamic.state().status_message());
       resp.SetErrorMessage(error_message_json);
       resp.SetKeyInJsonBody(sensor_pointer / "Status" / "State", "Disabled");
+      resp.SetKeyInJsonBody(
+          sensor_pointer / "Status" / "Oem" / "Google" / "SensorState",
+          GetOemSensorStateString(status));
       resp.SetKeyInJsonBody(sensor_pointer / "Reading", nullptr);
       break;
+    }
   }
   const SensorAttributesStatic& attributes_static =
       sensor->GetSensorAttributesStatic();