sensor: Modify Get Device SDR command implementation

a) Specify the sensor name deduction in the yaml
b) Entity ID and entity instance is populated
c) Sensor owner is set to BMC address, since all the sensors are present
   on the BMC.

Change-Id: I7b64c48ad1dbd386e12b20af459e40baf0d97cd4
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index c8505e7..8877bb3 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -850,22 +850,23 @@
         get_sdr::body::set_b_exp(info->exponentB, body);
         get_sdr::body::set_r_exp(scale, body);
 
-        /* ID string */
-        std::string id_string = info->sensorPath.substr(
-            info->sensorPath.find_last_of('/')+1, info->sensorPath.length());
         get_sdr::body::set_id_type(0b00, body); // 00 = unicode
-        if (id_string.length() > FULL_RECORD_ID_STR_MAX_LENGTH)
-        {
-            get_sdr::body::set_id_strlen(FULL_RECORD_ID_STR_MAX_LENGTH, body);
-        }
-        else
-        {
-            get_sdr::body::set_id_strlen(id_string.length(), body);
-        }
-        strncpy(body->id_string, id_string.c_str(),
-                get_sdr::body::get_id_strlen(body));
     }
 
+    /* ID string */
+    auto id_string = info->sensorNameFunc(*info);
+
+    if (id_string.length() > FULL_RECORD_ID_STR_MAX_LENGTH)
+    {
+        get_sdr::body::set_id_strlen(FULL_RECORD_ID_STR_MAX_LENGTH, body);
+    }
+    else
+    {
+        get_sdr::body::set_id_strlen(id_string.length(), body);
+    }
+    strncpy(body->id_string, id_string.c_str(),
+            get_sdr::body::get_id_strlen(body));
+
     return IPMI_CC_OK;
 };
 
@@ -901,12 +902,14 @@
         record.header.record_length = sizeof(get_sdr::SensorDataFullRecord);
 
         /* Key */
+        get_sdr::key::set_owner_id_bmc(&(record.key));
         record.key.sensor_number = sensor_id;
 
         /* Body */
-        record.body.entity_id = sensor_id;
+        record.body.entity_id = sensor->second.entityType;
         record.body.sensor_type = sensor->second.sensorType;
         record.body.event_reading_type = sensor->second.sensorReadingType;
+        record.body.entity_instance = sensor->second.instance;
 
         // Set the type-specific details given the DBus interface
         ret = populate_record_from_dbus(&(record.body), &(sensor->second),