// -----------------------------------------------------------------------------
// 
// -----------------------------------------------------------------------------
//
void WlanConfigureTxQueueParams::OnStateEntryEvent( 
    WlanContextImpl& aCtxImpl )
    {
    switch ( iState )
        {
        case EINIT:
            ChangeInternalState( aCtxImpl, ECONFIGUREBESTEFFORTQUEUE );
            break;
        case ECONFIGUREBESTEFFORTQUEUE:
            ConfigureQueue( aCtxImpl, WHA::ELegacy );                
            break;
        case ECONFIGUREVOICEQUEUE:
            ConfigureQueue( aCtxImpl, WHA::EVoice );
            break;
        case ECONFIGUREVIDEOQUEUE:
            ConfigureQueue( aCtxImpl, WHA::EVideo );
            break;
        case ECONFIGUREBACKGROUNDQUEUE:
            ConfigureQueue( aCtxImpl, WHA::EBackGround );
            break;
        case ECONFIGUREAC:
            ConfigureAc( aCtxImpl );
            break;
        case EFINIT:
            // fsm execution complete traverse back to history state
            TraverseToHistoryState( aCtxImpl );
            break;
        default:
            // cath internal FSM programming error
#ifndef NDEBUG
            OsTracePrint( KErrorLevel, (TUint8*)("UMAC: state:"));
            OsTracePrint( KErrorLevel, iStateName[iState] );
#endif 
            OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
        }
    }
Example #2
0
/////////////////////////////////////////////////////////////////////////
//
// CMyDevice::OnPrepareHardware
//
//  Called by UMDF to prepare the hardware for use. In our case
//  we create the SensorDDI object and initialize the Sensor Class Extension
//
// Parameters:
//      pWdfDevice - pointer to an IWDFDevice object representing the
//      device
//
// Return Values:
//      S_OK: success
//
/////////////////////////////////////////////////////////////////////////
HRESULT CMyDevice::OnPrepareHardware(
        _In_ IWDFDevice* pWdfDevice
        )
{
    Trace(TRACE_LEVEL_INFORMATION, "%!FUNC! Entry");

    HRESULT hr = (NULL != pWdfDevice) ? S_OK : E_UNEXPECTED;


    if (SUCCEEDED(hr))
    {
        hr = EnterProcessing(PROCESSING_IPNPCALLBACKHARDWARE);

        if (SUCCEEDED(hr))
        {
            if( NULL != pWdfDevice )
            {
                // Store the IWDFDevice pointer
                m_spWdfDevice = pWdfDevice;
            }

            // Create & Configure the default IO Queue
            if (SUCCEEDED(hr))
            {
                hr = ConfigureQueue();
            }

            // Create the sensor manager object
            if (SUCCEEDED(hr))
            {
                hr = CComObject<CSensorManager>::CreateInstance(&m_pSensorManager);

                if (nullptr != m_pSensorManager)
                {
                    if ((SUCCEEDED(hr)) && (NULL != m_pSensorManager))
                    {
                        m_pSensorManager->AddRef();
                    }

                    // Initialize the sensor manager object
                    if(SUCCEEDED(hr))
                    {
                        hr = m_pSensorManager->Initialize(m_spWdfDevice, this);
                    }
                }
                else
                {
                    hr = E_POINTER;
                }
            }
    
            if (SUCCEEDED(hr))
            {
                hr = StringCchCopy(m_pSensorManager->m_wszDeviceName, MAX_PATH, DEFAULT_DEVICE_MODEL_VALUE);
    
                if (SUCCEEDED(hr))
                {
                    ULONG ulCchInstanceId = 0;
                    BOOL  fResult = FALSE;
                    WCHAR* wszInstanceId = nullptr;
                    WCHAR* tempStr = nullptr;

                    try 
                    {
                        wszInstanceId = new WCHAR[MAX_PATH];
                    }
                    catch(...)
                    {
                        hr = E_UNEXPECTED;
                        Trace(TRACE_LEVEL_ERROR, "Failed to allocate memory for instance ID string, hr = %!HRESULT!", hr);

                        if (nullptr != wszInstanceId) 
                        {
                            delete[] wszInstanceId;
                        }
                    }

                    try 
                    {
                        tempStr = new WCHAR[MAX_PATH];
                    }
                    catch(...)
                    {
                        hr = E_UNEXPECTED;
                        Trace(TRACE_LEVEL_ERROR, "Failed to allocate memory for instance ID temp string, hr = %!HRESULT!", hr);

                        if (nullptr != tempStr) 
                        {
                            delete[] tempStr;
                        }
                    }

                    if (SUCCEEDED(pWdfDevice->RetrieveDeviceInstanceId(NULL, &ulCchInstanceId)))
                    {
                        if (SUCCEEDED(pWdfDevice->RetrieveDeviceInstanceId(wszInstanceId, &ulCchInstanceId)))
                        {
                            HDEVINFO hDeviceInfo = INVALID_HANDLE_VALUE;

                            if (INVALID_HANDLE_VALUE != (hDeviceInfo = ::SetupDiCreateDeviceInfoList(NULL, NULL)))
                            {
                                SP_DEVINFO_DATA deviceInfo = {sizeof(SP_DEVINFO_DATA)};
                                if (TRUE == ::SetupDiOpenDeviceInfo(hDeviceInfo, wszInstanceId, NULL, 0, &deviceInfo))
                                {
                                    DEVPROPTYPE propType;
                                    ULONG ulSize;

                                    fResult = ::SetupDiGetDeviceProperty(hDeviceInfo, &deviceInfo, &DEVPKEY_Device_DeviceDesc, &propType, (PBYTE)tempStr, MAX_PATH*sizeof(WCHAR), &ulSize, 0);
                                    if (FALSE == fResult)
                                    {
                                        hr = HRESULT_FROM_WIN32(GetLastError());
                                    }

#pragma warning(suppress: 26035) //possible failure to null terminate string
                                    if (SUCCEEDED(hr) && (wcscmp(tempStr, L"") != 0))
                                    {
                                        wcscpy_s(m_pSensorManager->m_wszDeviceName, MAX_PATH, tempStr);
                                    }

                                    ::SetupDiDestroyDeviceInfoList(hDeviceInfo);
                                }
                            }
                        }
                    }

#pragma warning(suppress: 6001) //using unitialized memory
                    if (nullptr != wszInstanceId) 
                    {
                        delete[] wszInstanceId;
                    }

#pragma warning(suppress: 6001) //using unitialized memory
                    if (nullptr != tempStr) 
                    {
                        delete[] tempStr;
                    }
                }
            }

        } // processing in progress

        ExitProcessing(PROCESSING_IPNPCALLBACKHARDWARE);
    }

    if (FAILED(hr))
    {
        Trace(TRACE_LEVEL_CRITICAL, "Abnormal results during hardware initialization, hr = %!HRESULT!", hr);
    }

    Trace(TRACE_LEVEL_INFORMATION, "%!FUNC! Exit, hr = %!HRESULT!", hr);

    return hr;
}