Beispiel #1
0
ANSC_STATUS
ssp_engage_wifi
    (
        PCCSP_COMPONENT_CFG         pStartCfg
    )
{
    ANSC_STATUS                     returnStatus    = ANSC_STATUS_SUCCESS;
    char                            CrName[256]     = {0};
    PCCSP_DM_XML_CFG_LIST           pXmlCfgList     = NULL;

    g_pComponent_Common_Dm->Health = CCSP_COMMON_COMPONENT_HEALTH_Yellow;


    if ( pWifiCcdIf )
    {
        pWifiFcContext->hCcspCcdIf = (ANSC_HANDLE)pWifiCcdIf;
        pWifiFcContext->hMessageBus = bus_handle;
    }

    g_DslhDataModelAgent->SetFcContext((ANSC_HANDLE)g_DslhDataModelAgent, (ANSC_HANDLE)pWifiFcContext);

    pDslhCpeController->AddInterface((ANSC_HANDLE)pDslhCpeController, (ANSC_HANDLE)MsgHelper_CreateCcdMbiIf((void*)bus_handle,g_Subsystem));
    pDslhCpeController->AddInterface((ANSC_HANDLE)pDslhCpeController, (ANSC_HANDLE)pWifiCcdIf);
    pDslhCpeController->SetDbusHandle((ANSC_HANDLE)pDslhCpeController, bus_handle);
    pDslhCpeController->Engage((ANSC_HANDLE)pDslhCpeController);

    if ( g_Subsystem[0] != 0 )
    {
        _ansc_sprintf(CrName, "%s%s", g_Subsystem, CCSP_DBUS_INTERFACE_CR);
    }
    else
    {
        _ansc_sprintf(CrName, "%s", CCSP_DBUS_INTERFACE_CR);
    }

    returnStatus = CcspComponentLoadDmXmlList(pStartCfg->DmXmlCfgFileName, &pXmlCfgList);

    if ( returnStatus != ANSC_STATUS_SUCCESS )
    {
        return  returnStatus;
    }

    returnStatus =
        pDslhCpeController->RegisterCcspDataModel
            (
                (ANSC_HANDLE)pDslhCpeController,
                CrName,                             /* CCSP CR ID */
                pXmlCfgList->FileList[0],           /* Data Model XML file. Can be empty if only base data model supported. */
                pStartCfg->ComponentName,           /* Component Name    */
                pStartCfg->Version,                 /* Component Version */
                pStartCfg->DbusPath,                /* Component Path    */
                g_Subsystem                         /* Component Prefix  */
            );

    if ( returnStatus == ANSC_STATUS_SUCCESS || returnStatus == CCSP_SUCCESS )
    {
        /* System is fully initialized */
        g_pComponent_Common_Dm->Health = CCSP_COMMON_COMPONENT_HEALTH_Green;
    }

    AnscFreeMemory(pXmlCfgList);

    return ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
ssp_engage_tad
    (
    )
{
	ANSC_STATUS					    returnStatus                                         = ANSC_STATUS_SUCCESS;
        char                                                CrName[256];

    g_pComponent_Common_Dm->Health = CCSP_COMMON_COMPONENT_HEALTH_Yellow;

    if ( pTadCcdIf )
    {
        pTadFcContext->hCcspCcdIf = (ANSC_HANDLE)pTadCcdIf;
        pTadFcContext->hMessageBus = bus_handle;
    }

    g_DslhDataModelAgent->SetFcContext((ANSC_HANDLE)g_DslhDataModelAgent, (ANSC_HANDLE)pTadFcContext);

    /*RDKB-7459, CID-33428, null check before use */
    if(!pDslhCpeController)
    {
        pDslhCpeController = DslhCreateCpeController(NULL, NULL, NULL);
        if ( !pDslhCpeController )
        {
            CcspTraceWarning(("Null Value, CANNOT Create pDslhCpeController... Exit!\n"));
            return ANSC_STATUS_RESOURCES;
        }
    }

    pDslhCpeController->AddInterface((ANSC_HANDLE)pDslhCpeController, (ANSC_HANDLE)MsgHelper_CreateCcdMbiIf((void*)bus_handle, g_Subsystem));
    pDslhCpeController->AddInterface((ANSC_HANDLE)pDslhCpeController, (ANSC_HANDLE)pTadCcdIf);
    pDslhCpeController->SetDbusHandle((ANSC_HANDLE)pDslhCpeController, bus_handle);
    pDslhCpeController->Engage((ANSC_HANDLE)pDslhCpeController);

    if ( g_Subsystem[0] != 0 )
    {
        _ansc_sprintf(CrName, "%s%s", g_Subsystem, CCSP_DBUS_INTERFACE_CR);
    }
    else
    {
        _ansc_sprintf(CrName, "%s", CCSP_DBUS_INTERFACE_CR);
    }

    if ( TRUE )
    {

        /*RDKB-7459, CID-33428, Load Lib if handle is null */
        if( hDiagPlugin == NULL)
        {
            hDiagPlugin = (ANSC_HANDLE)AnscLoadLibrary(COSA_DIAG_PLUGIN_LIBRARY_NAME);
        }

        if( hDiagPlugin == NULL)
        {
            CcspTraceWarning(("Unable to load library -- %s\n", COSA_DIAG_PLUGIN_LIBRARY_NAME));
#ifdef _ANSC_LINUX
            CcspTraceWarning(("cause:%s\n",  dlerror() ));
#endif
            g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
        }
        else
        {
            g_CosaDiagPluginInfo.InitProc = (COSADiagInitProc)
                AnscGetProcAddress
                    (
                        hDiagPlugin,
                        COSA_DIAG_PLUGIN_INIT_PROC
                    );

            if ( g_CosaDiagPluginInfo.InitProc == NULL )
            {
                AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_INIT_PROC));

                g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
            }
            else
            {
                g_CosaDiagPluginInfo.UnloadProc = (COSADiagUnloadProc)
                    AnscGetProcAddress
                        (
                            hDiagPlugin,
                            COSA_DIAG_PLUGIN_UNLOAD_PROC
                        );

                if ( g_CosaDiagPluginInfo.UnloadProc == NULL )
                {
                    AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_UNLOAD_PROC));

                    g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
                }
                else
                {
                    g_CosaDiagPluginInfo.GetResultsProc = (CosaDiagGetResultsProc)
                        AnscGetProcAddress
                            (
                                hDiagPlugin,
                                COSA_DIAG_PLUGIN_GETRESULTS_PROC
                            );

                    if ( g_CosaDiagPluginInfo.GetResultsProc == NULL )
                    {
                        AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_GETRESULTS_PROC));

                        g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
                    }
                    else
                    {
                        g_CosaDiagPluginInfo.ScheduleDiagnosticProc = (CosaDiagScheduleDiagnosticProc)
                            AnscGetProcAddress
                                (
                                    hDiagPlugin,
                                    COSA_DIAG_PLUGIN_SCHEDIAG_PROC
                                );

                        if ( g_CosaDiagPluginInfo.ScheduleDiagnosticProc == NULL )
                        {
                            AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_SCHEDIAG_PROC));

                            g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
                        }
                        else
                        {
                            g_CosaDiagPluginInfo.SetDiagParamsProc = (CosaDiagSetDiagParamsProc)
                                AnscGetProcAddress
                                    (
                                        hDiagPlugin,
                                        COSA_DIAG_PLUGIN_SETDIAGPARAMS_PROC
                                    );

                            if ( g_CosaDiagPluginInfo.SetDiagParamsProc == NULL )
                            {
                                AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_SETDIAGPARAMS_PROC));

                                g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
                            }
                            else
                            {
                                g_CosaDiagPluginInfo.SetDiagStateProc = (CosaDiagSetDiagStateProc)
                                    AnscGetProcAddress
                                        (
                                            hDiagPlugin,
                                            COSA_DIAG_PLUGIN_SETDIAGSTATE_PROC
                                        );

                                if ( g_CosaDiagPluginInfo.SetDiagStateProc == NULL )
                                {
                                    AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_SETDIAGSTATE_PROC));

                                    g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
                                }
                                else
                                {
                                    g_CosaDiagPluginInfo.CancelDiagnosticProc = (CosaDiagCancelDiagnosticProc)
                                        AnscGetProcAddress
                                            (
                                                hDiagPlugin,
                                                COSA_DIAG_PLUGIN_CANCELDIAG_PROC
                                            );

                                    if ( g_CosaDiagPluginInfo.CancelDiagnosticProc == NULL )
                                    {
                                        AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_CANCELDIAG_PROC));

                                        g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
                                    }
                                    else
                                    {
                                        g_CosaDiagPluginInfo.MemoryUsageProc = (CosaDiagMemoryUsageProc)
                                            AnscGetProcAddress
                                                (
                                                    hDiagPlugin,
                                                    COSA_DIAG_PLUGIN_MEMORYUSAGE_PROC
                                                );

                                        if ( g_CosaDiagPluginInfo.MemoryUsageProc == NULL )
                                        {
                                            AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_MEMORYUSAGE_PROC));

                                            g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
                                        }
                                        else
                                        {
                                            g_CosaDiagPluginInfo.MemoryTableProc = (CosaDiagMemoryTableProc)
                                                AnscGetProcAddress
                                                    (
                                                        hDiagPlugin,
                                                        COSA_DIAG_PLUGIN_MEMORYTABLE_PROC
                                                    );

                                            if ( g_CosaDiagPluginInfo.MemoryTableProc == NULL )
                                            {
                                                AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_MEMORYTABLE_PROC));

                                                g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
                                            }
                                            else
                                            {
                                                g_CosaDiagPluginInfo.GetConfigsProc = (CosaDiagGetConfigsProc)
                                                    AnscGetProcAddress
                                                        (
                                                            hDiagPlugin,
                                                            COSA_DIAG_PLUGIN_GETCONFIGS_PROC
                                                        );

                                                if ( g_CosaDiagPluginInfo.GetConfigsProc == NULL )
                                                {
                                                    AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_GETCONFIGS_PROC));

                                                    g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
                                                }
                                                else
                                                {
                                                    g_CosaDiagPluginInfo.ExportFuncProc = (CosaDiagExportFuncProc)
                                                        AnscGetProcAddress
                                                            (
                                                                hDiagPlugin,
                                                                COSA_DIAG_PLUGIN_EXPORTFUNC_PROC
                                                            );

                                                    if ( g_CosaDiagPluginInfo.ExportFuncProc == NULL )
                                                    {
                                                        AnscTraceWarning(("Unable to Get ProcAddress of  '%s'\n", COSA_DIAG_PLUGIN_EXPORTFUNC_PROC));

                                                        g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_LOAD_LIBRARY;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        if ( g_CosaDiagPluginInfo.uLoadStatus == COSA_STATUS_SUCCESS )
        {
            /* COSA Diagnostic library loaded successfully */
            g_CosaDiagPluginInfo.uPluginVersion = 1;

            returnStatus = g_CosaDiagPluginInfo.InitProc(bus_handle);

            if ( returnStatus != ANSC_STATUS_SUCCESS )
            {
                g_CosaDiagPluginInfo.uLoadStatus = COSA_STATUS_ERROR_INIT;
            }

            g_DslhDataModelAgent->RegisterInternalApi(g_DslhDataModelAgent, "COSAGetDiagPluginInfo", COSAGetDiagPluginInfo);
        }
    }

    if ( g_GetParamValueByPathNameProc == NULL )
    {
        g_GetParamValueByPathNameProc = 
            (COSAGetParamValueByPathNameProc)COSAAcquireFunction("COSAGetParamValueByPathName");

        if ( !g_GetParamValueByPathNameProc )
        {
            printf("Test and Diagnostic - failed to load the function COSAGetParamValueByPathName!\n");
        }
    }

    returnStatus =
        pDslhCpeController->RegisterCcspDataModel
            (
                (ANSC_HANDLE)pDslhCpeController,
                CrName, /*CCSP_DBUS_INTERFACE_CR,*/             /* CCSP CR ID */
                COSA_PLUGIN_XML_FILE,               /* Data Model XML file. Can be empty if only base data model supported. */
                CCSP_COMPONENT_NAME_TAD,            /* Component Name    */
                CCSP_COMPONENT_VERSION_TAD,         /* Component Version */
                CCSP_COMPONENT_PATH_TAD,            /* Component Path    */
                g_Subsystem                         /* Component Prefix  */
            );

    if ( returnStatus == ANSC_STATUS_SUCCESS || CCSP_SUCCESS == returnStatus)
    {
        /* System is fully initialized */
        g_pComponent_Common_Dm->Health = CCSP_COMMON_COMPONENT_HEALTH_Green;
    }
    pollTime();
    return ANSC_STATUS_SUCCESS;
}