//-------------------------------------------------------------------------------------------------- LE_SHARED appCfg_Iter_t appCfg_FindApp ( const char* appName ///< [IN] Name of the app to find. ) { AppsIter_t* iterPtr = appCfg_CreateAppsIter(); le_cfg_GoToNode(iterPtr->cfgIter, appName); if (le_cfg_NodeExists(iterPtr->cfgIter, "") == false) { appCfg_DeleteIter(iterPtr); return NULL; } return iterPtr; }
//-------------------------------------------------------------------------------------------------- static void PopulateAppInfoObjects ( void ) //-------------------------------------------------------------------------------------------------- { appCfg_Iter_t appIterRef = appCfg_CreateAppsIter(); char appName[MAX_APP_NAME_BYTES] = ""; char versionBuffer[MAX_VERSION_STR_BYTES] = ""; le_result_t result; int foundAppCount = 0; result = appCfg_GetNextItem(appIterRef); while (result == LE_OK) { result = appCfg_GetAppName(appIterRef, appName, sizeof(appName)); if ((result == LE_OK) && (false == IsHiddenApp(appName))) { LE_DEBUG("Loading object instance for app, '%s'.", appName); assetData_InstanceDataRef_t instanceRef = GetObject9InstanceForApp(appName, false); if (appCfg_GetVersion(appIterRef, versionBuffer, sizeof(versionBuffer)) == LE_OVERFLOW) { LE_WARN("Warning, app, '%s' version string truncated to '%s'.", appName, versionBuffer); } if (0 == strlen(versionBuffer)) { // Use the application hash if the version is empty le_appInfo_GetHash(appName, versionBuffer, sizeof(versionBuffer)); } assetData_client_SetString(instanceRef, O9F_PKG_VERSION, versionBuffer); assetData_client_SetBool(instanceRef, O9F_UPDATE_SUPPORTED_OBJECTS, false); // No need to save the status in config tree, while populating object9 SetObj9State(instanceRef, US_INSTALLED, UR_INSTALLED, false); foundAppCount++; } else { LE_WARN("Application name too large or is hidden, '%s.'", appName); } result = appCfg_GetNextItem(appIterRef); } appCfg_DeleteIter(appIterRef); LE_FATAL_IF(result != LE_NOT_FOUND, "Application cache initialization, unexpected error returned, (%d): \"%s\"", result, LE_RESULT_TXT(result)); int index = 0; LE_DEBUG("Found app count %d.", foundAppCount); while (foundAppCount > 0) { assetData_InstanceDataRef_t instanceRef = NULL; le_result_t result = assetData_GetInstanceRefById(LWM2M_NAME, 9, index, &instanceRef); LE_DEBUG("Index %d.", index); if (result == LE_OK) { assetData_client_GetString(instanceRef, O9F_PKG_NAME, appName, sizeof(appName)); LE_DEBUG("Mapping app '%s'.", appName); SetObject9InstanceForApp(appName, instanceRef); foundAppCount--; } index++; } }