44 #ifdef USE_XRDK_SDCARD_PROFILE
49 #ifdef USE_RDK_STORAGE_MANAGER_V2
50 #include "rdkStorageMgr.h"
52 typedef union _uSDCardParamValue {
59 typedef enum _eSD_PROPERTY_Type {
70 } eSD_ParamPropertyType;
72 typedef struct _strMgrSDcardPropParam_t {
73 uSDCard_Param_Val sdCardProp;
74 eSD_ParamPropertyType eSDPropType;
75 } strMgrSDcardPropParam_t;
78 #include "storageMgr.h"
80 #include "safec_lib.h"
82 static bool getSDCardProperties(strMgrSDcardPropParam_t *);
94 catch(
const std::exception& e)
96 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Caught exception \" %s\"\n", __FUNCTION__, e.what());
114 hostIf_STBServiceXSDCard::hostIf_STBServiceXSDCard()
142 int ret = NOT_HANDLED;
161 int ret = NOT_HANDLED;
162 const char *path = NULL, *paramName = NULL;
164 int str_len = strlen(X_SDCARD_OBJ);
167 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s]Entering... \n", __FILE__, __FUNCTION__);
170 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d]Failed : Parameter is NULL, %s \n", __FILE__, __FUNCTION__, __LINE__, path);
174 if((strncasecmp(path, X_SDCARD_OBJ, str_len) != 0)) {
175 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s:%d]Failed : Mismatch parameter path : %s \n", __FILE__, __FUNCTION__, __LINE__, path);
178 const char *tmp_ptr = strchr(path+str_len-1,
'.');
179 if(tmp_ptr == NULL) {
180 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s] Parameter is NULL \n", __FILE__, __FUNCTION__);
186 if (strcasecmp(paramName, CAPACITY_STRING) == 0)
188 ret = getCapacity(stMsgData);
190 else if (strcasecmp(paramName, CARDFAILED_STRING) == 0)
192 ret = getCardFailed(stMsgData);
194 else if (strcasecmp(paramName, LIFEELAPSED_STRING) == 0)
196 ret = getLifeElapsed(stMsgData);
198 else if (strcasecmp(paramName, LOTID_STRING) == 0)
200 ret = getLotID(stMsgData);
202 else if (strcasecmp(paramName, MANUFACTURED_STRING) == 0)
204 ret = getManufacturer(stMsgData);
206 else if (strcasecmp(paramName, MODEL_STRING) == 0)
208 ret = getModel(stMsgData);
210 else if (strcasecmp(paramName, READONLY_STRING) == 0)
212 ret = getReadOnly(stMsgData);
214 else if (strcasecmp(paramName, SERIALNUMBER_STRING) == 0)
216 ret = getSerialNumber(stMsgData);
218 else if (strcasecmp(paramName, TSBQUALIFIED_STRING) == 0)
220 ret = getTSBQualified(stMsgData);
222 else if (strcasecmp(paramName, SDCARD_STATUS) == 0)
224 ret = getStatus(stMsgData);
228 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s] Parameter \'%s\' is Not Supported \n", __FILE__, __FUNCTION__, paramName);
232 catch (
const std::exception& e )
234 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s:%s] Exception caught %s \n", __FILE__, __FUNCTION__, e.what());
237 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s]Exiting... \n", __FILE__, __FUNCTION__);
251 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
254 strMgrSDcardPropParam_t param;
255 memset(¶m,
'\0',
sizeof(param));
256 param.eSDPropType = SD_Capacity;
257 if(getSDCardProperties(¶m) ) {
259 unsigned long long capacityBytes = 0;
260 int capacityMegaBytes = 0;
261 capacityBytes = (
unsigned long long) param.sdCardProp.ui32Val;
262 capacityMegaBytes = (capacityBytes /1024/1024) ;
265 stMsgData->
paramtype=hostIf_UnsignedIntType;
267 catch (
const std::exception& e) {
268 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception : %s\r\n",__FUNCTION__, e.what());
271 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
292 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
294 strMgrSDcardPropParam_t param;
295 memset(¶m,
'\0',
sizeof(param));
296 param.eSDPropType = SD_CardFailed;
297 if(getSDCardProperties(¶m) ) {
302 catch (
const std::exception& e) {
303 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception : %s\r\n",__FUNCTION__, e.what());
306 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
327 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
329 strMgrSDcardPropParam_t param;
330 memset(¶m,
'\0',
sizeof(param));
331 param.eSDPropType = SD_LifeElapsed;
332 if(getSDCardProperties(¶m) ) {
337 catch (
const std::exception& e) {
338 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception : %s\r\n",__FUNCTION__, e.what());
341 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
359 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
361 strMgrSDcardPropParam_t param;
362 memset(¶m,
'\0',
sizeof(param));
363 param.eSDPropType = SD_LotID;
364 if(getSDCardProperties(¶m) ) {
365 rc=strcpy_s((
char *)stMsgData->
paramValue,
sizeof(stMsgData->
paramValue), (
const char*) param.sdCardProp.uchVal);
373 catch (
const std::exception& e) {
374 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception : %s\r\n",__FUNCTION__, e.what());
377 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
396 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
398 strMgrSDcardPropParam_t param;
399 memset(¶m,
'\0',
sizeof(param));
400 param.eSDPropType = SD_Manufacturer;
401 if(getSDCardProperties(¶m) ) {
402 rc=strcpy_s((
char *)stMsgData->
paramValue,
sizeof(stMsgData->
paramValue), (
const char*) param.sdCardProp.uchVal);
410 catch (
const std::exception& e) {
411 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception : %s\r\n",__FUNCTION__, e.what());
414 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
434 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
436 strMgrSDcardPropParam_t param;
437 memset(¶m,
'\0',
sizeof(param));
438 param.eSDPropType = SD_Model;
439 if(getSDCardProperties(¶m) ) {
440 rc=strcpy_s((
char *)stMsgData->
paramValue,
sizeof(stMsgData->
paramValue), (
const char*) param.sdCardProp.uchVal);
448 catch (
const std::exception& e) {
449 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception : %s\r\n",__FUNCTION__, e.what());
452 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
471 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
473 strMgrSDcardPropParam_t param;
474 memset(¶m,
'\0',
sizeof(param));
475 param.eSDPropType = SD_ReadOnly;
476 if(getSDCardProperties(¶m) ) {
481 catch (
const std::exception& e) {
482 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception : %s\r\n",__FUNCTION__, e.what());
485 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
501 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
503 strMgrSDcardPropParam_t param;
504 memset(¶m,
'\0',
sizeof(param));
505 param.eSDPropType = SD_SerialNumber;
506 if(getSDCardProperties(¶m) ) {
507 sprintf(stMsgData->
paramValue,
"%s" ,param.sdCardProp.uchVal);
511 catch (
const std::exception& e) {
512 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception : %s\r\n",__FUNCTION__, e.what());
515 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
534 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
536 strMgrSDcardPropParam_t param;
537 memset(¶m,
'\0',
sizeof(param));
538 param.eSDPropType = SD_TSBQualified;
539 if(getSDCardProperties(¶m) ) {
541 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] param.sdCardProp.bVal: %d\n", __FUNCTION__, __FILE__, param.sdCardProp.bVal);
545 catch (
const std::exception& e) {
546 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception : %s\r\n",__FUNCTION__, e.what());
549 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
569 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
571 strMgrSDcardPropParam_t param;
572 memset(¶m,
'\0',
sizeof(param));
573 param.eSDPropType = SD_Status;
574 if(getSDCardProperties(¶m) ) {
575 rc=strcpy_s((
char *)stMsgData->
paramValue,
sizeof(stMsgData->
paramValue), (
const char*) param.sdCardProp.uchVal);
580 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] param.sdCardProp.bchVal: %d\n", __FUNCTION__, __FILE__, param.sdCardProp.uchVal);
584 catch (
const std::exception& e) {
585 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception : %s\r\n",__FUNCTION__, e.what());
588 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
594 bool getSDCardProperties(strMgrSDcardPropParam_t *sdCardParam)
596 errno_t safec_rc = -1;
597 #ifdef USE_RDK_STORAGE_MANAGER_V2
599 static char sdCardDeviceID[RDK_STMGR_MAX_STRING_LENGTH] =
"";
600 static char sdCardPartitionID[RDK_STMGR_MAX_STRING_LENGTH] =
"";
603 if (
'\0' == sdCardDeviceID[0])
605 eSTMGRDeviceInfoList deviceInfoList;
606 memset (&deviceInfoList, 0,
sizeof(deviceInfoList));
607 stRet = rdkStorage_getDeviceInfoList(&deviceInfoList);
608 for (
int i = 0; i < deviceInfoList.m_numOfDevices; i++)
610 if (RDK_STMGR_DEVICE_TYPE_SDCARD == deviceInfoList.m_devices[i].m_type)
612 safec_rc=memcpy_s (&sdCardDeviceID, RDK_STMGR_MAX_STRING_LENGTH ,&deviceInfoList.m_devices[i].m_deviceID, RDK_STMGR_MAX_STRING_LENGTH);
617 safec_rc=memcpy_s (&sdCardPartitionID, RDK_STMGR_MAX_STRING_LENGTH , &deviceInfoList.m_devices[i].m_partitions, RDK_STMGR_MAX_STRING_LENGTH);
627 if (
'\0' != sdCardDeviceID[0])
629 if (sdCardParam->eSDPropType == SD_LifeElapsed)
631 eSTMGRHealthInfo healthInfo;
632 memset (&healthInfo, 0 ,
sizeof(healthInfo));
633 if (RDK_STMGR_RETURN_SUCCESS == rdkStorage_getHealth (sdCardDeviceID, &healthInfo))
635 sdCardParam->sdCardProp.iVal = -1;
637 for (
int i = 0; i < healthInfo.m_diagnostics.m_list.m_numOfAttributes; i++)
639 if (0 == strcmp (healthInfo.m_diagnostics.m_list.m_diagnostics[i].m_name,
"used"))
641 sdCardParam->sdCardProp.iVal = atoi (healthInfo.m_diagnostics.m_list.m_diagnostics[i].m_value);
648 sdCardParam->sdCardProp.iVal = -1;
653 eSTMGRDeviceInfo deviceInfo;
654 memset (&deviceInfo, 0 ,
sizeof(deviceInfo));
655 if (RDK_STMGR_RETURN_SUCCESS == rdkStorage_getDeviceInfo (sdCardDeviceID, &deviceInfo))
657 switch(sdCardParam->eSDPropType)
660 sdCardParam->sdCardProp.ui32Val = deviceInfo.m_capacity;
665 if(deviceInfo.status == SM_DEV_STATUS_NOT_QUALIFIED || deviceInfo.status == SM_DEV_STATUS_NOT_PRESENT)
667 sdCardParam->sdCardProp.bVal =
false;
671 sdCardParam->sdCardProp.bVal =
false;
674 sdCardParam->sdCardProp.bVal =
false;
679 safec_rc=strcpy_s (sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal), deviceInfo.m_hwVersion);
686 case SD_Manufacturer:
688 safec_rc=strcpy_s(sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal),deviceInfo.m_manufacturer);
697 safec_rc=strcpy_s (sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal), deviceInfo.m_model);
705 sdCardParam->sdCardProp.bVal = (deviceInfo.m_status == RDK_STMGR_DEVICE_STATUS_READ_ONLY) ?
true :
false;
707 case SD_SerialNumber:
709 safec_rc=strcpy_s(sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal), deviceInfo.m_serialNumber);
718 switch (deviceInfo.m_status)
720 case RDK_STMGR_DEVICE_STATUS_OK:
722 safec_rc=strcpy_s (sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal),
"SDCARD_OK");
729 case RDK_STMGR_DEVICE_STATUS_READ_ONLY:
731 safec_rc=strcpy_s (sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal),
"SDCARD_READ_ONLY");
738 case RDK_STMGR_DEVICE_STATUS_NOT_PRESENT:
740 safec_rc=strcpy_s (sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal),
"SDCARD_NOT_PRESENT");
747 case RDK_STMGR_DEVICE_STATUS_NOT_QUALIFIED:
749 safec_rc=strcpy_s (sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal),
"SDCARD_NOT_QUALIFIED");
756 case RDK_STMGR_DEVICE_STATUS_DISK_FULL:
758 safec_rc=strcpy_s (sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal),
"SDCARD_DISK_FULL");
765 case RDK_STMGR_DEVICE_STATUS_READ_FAILURE:
767 safec_rc=strcpy_s (sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal),
"SDCARD_READ_FAILURE");
774 case RDK_STMGR_DEVICE_STATUS_WRITE_FAILURE:
776 safec_rc=strcpy_s (sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal),
"SDCARD_WRITE_FAILURE");
786 case SD_TSBQualified:
787 sdCardParam->sdCardProp.bVal = (deviceInfo.m_status != RDK_STMGR_DEVICE_STATUS_NOT_QUALIFIED &&
788 deviceInfo.m_status != RDK_STMGR_DEVICE_STATUS_UNKNOWN);
794 RDK_LOG(RDK_LOG_WARN, LOG_TR69HOSTIF,
"[%s] Gettng the device specific information failed\n",__FUNCTION__);
795 switch(sdCardParam->eSDPropType)
799 safec_rc=strcpy_s(sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal), (
const char*)
"None");
812 RDK_LOG(RDK_LOG_WARN, LOG_TR69HOSTIF,
"[%s] This platform does not have SD card\n",__FUNCTION__);
813 switch(sdCardParam->eSDPropType)
817 safec_rc=strcpy_s(sdCardParam->sdCardProp.uchVal,
sizeof(sdCardParam->sdCardProp.uchVal), (
const char*)
"None");
830 IARM_Result_t retVal = IARM_RESULT_SUCCESS;
831 IARM_Bus_STRMgr_Param_t param;
834 memset(¶m, 0,
sizeof(param));
836 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
838 param.data.stSDCardParams.eSDPropType = sdCardParam->eSDPropType;
840 retVal =
IARM_Bus_Call(IARM_BUS_ST_MGR_NAME, IARM_BUS_STORAGE_MGR_API_GetSDcardPropertyInfo, (
void *)¶m,
sizeof(param));
842 if(retVal == IARM_RESULT_SUCCESS && (param.status))
844 RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,
"[%s] Successfully return from \'%s\' \n", __FUNCTION__, IARM_BUS_STORAGE_MGR_API_GetSDcardPropertyInfo);
845 sdCardParam->sdCardProp = param.data.stSDCardParams.sdCardProp;
849 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] Failed to return from \'%s\' \n", __FUNCTION__, IARM_BUS_STORAGE_MGR_API_GetSDcardPropertyInfo);
854 catch (
const std::exception& e) {
855 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception %s\r\n",__FUNCTION__, e.what());
858 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);