summaryrefslogtreecommitdiff
path: root/wpd/WpdBasicHardwareDriver
diff options
context:
space:
mode:
Diffstat (limited to 'wpd/WpdBasicHardwareDriver')
-rw-r--r--wpd/WpdBasicHardwareDriver/Device.cpp415
-rw-r--r--wpd/WpdBasicHardwareDriver/Device.h89
-rw-r--r--wpd/WpdBasicHardwareDriver/Driver.cpp197
-rw-r--r--wpd/WpdBasicHardwareDriver/Driver.h44
-rw-r--r--wpd/WpdBasicHardwareDriver/Queue.cpp340
-rw-r--r--wpd/WpdBasicHardwareDriver/Queue.h93
-rw-r--r--wpd/WpdBasicHardwareDriver/README.md52
-rw-r--r--wpd/WpdBasicHardwareDriver/RS232Connection.cpp316
-rw-r--r--wpd/WpdBasicHardwareDriver/RS232Connection.h153
-rw-r--r--wpd/WpdBasicHardwareDriver/RS232Target.cpp433
-rw-r--r--wpd/WpdBasicHardwareDriver/RS232Target.h53
-rw-r--r--wpd/WpdBasicHardwareDriver/Stdafxsrc.cpp1
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBaseDriver.cpp506
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBaseDriver.h69
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.cpp60
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.def9
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.idl24
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.inx81
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.rc15
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.rgs26
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.sln28
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.vcxproj352
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.vcxproj.Filters72
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdCapabilities.cpp505
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdCapabilities.h41
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdObjectEnum.cpp431
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdObjectEnum.h107
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdObjectProperties.cpp1314
-rw-r--r--wpd/WpdBasicHardwareDriver/WpdObjectProperties.h111
-rw-r--r--wpd/WpdBasicHardwareDriver/firmware/compass_wpd_enabled.bs294
-rw-r--r--wpd/WpdBasicHardwareDriver/firmware/flex_force_wpd_enabled.bs260
-rw-r--r--wpd/WpdBasicHardwareDriver/firmware/h48c_3-axis_wpd_enabled.bs2175
-rw-r--r--wpd/WpdBasicHardwareDriver/firmware/memsic2125_wpd_enabled.bs2107
-rw-r--r--wpd/WpdBasicHardwareDriver/firmware/piezo_wpd_enabled.bs255
-rw-r--r--wpd/WpdBasicHardwareDriver/firmware/ping_wpd_enabled.bs257
-rw-r--r--wpd/WpdBasicHardwareDriver/firmware/pir_wpd_enabled.bs250
-rw-r--r--wpd/WpdBasicHardwareDriver/firmware/qti_wpd_enabled.bs263
-rw-r--r--wpd/WpdBasicHardwareDriver/firmware/temp_humidity_wpd_enabled.bs2225
-rw-r--r--wpd/WpdBasicHardwareDriver/resource.h3
-rw-r--r--wpd/WpdBasicHardwareDriver/stdafx.h320
40 files changed, 0 insertions, 7146 deletions
diff --git a/wpd/WpdBasicHardwareDriver/Device.cpp b/wpd/WpdBasicHardwareDriver/Device.cpp
deleted file mode 100644
index 22a7ade8..00000000
--- a/wpd/WpdBasicHardwareDriver/Device.cpp
+++ /dev/null
@@ -1,415 +0,0 @@
-#include "stdafx.h"
-#include "Device.tmh"
-
-#include "WpdBasicHardwareDriver_i.c"
-
-STDMETHODIMP_(HRESULT)
-CDevice::OnD0Entry(_In_ IWDFDevice* pDevice,
- WDF_POWER_DEVICE_STATE previousState)
-{
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DEVICE, "%!FUNC! Entry");
-
- UNREFERENCED_PARAMETER(pDevice);
- UNREFERENCED_PARAMETER(previousState);
-
- HRESULT hr = S_OK;
- RS232Target* pTarget = NULL;
-
- if (m_pWpdBaseDriver != NULL)
- {
- pTarget = m_pWpdBaseDriver->GetRS232Target();
- if (pTarget != NULL)
- {
- hr = pTarget->Start();
- }
- }
-
- return hr;
-}
-
-STDMETHODIMP_(HRESULT)
-CDevice::OnD0Exit(_In_ IWDFDevice* pDevice,
- WDF_POWER_DEVICE_STATE newState)
-{
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DEVICE, "%!FUNC! Entry");
-
- UNREFERENCED_PARAMETER(pDevice);
- UNREFERENCED_PARAMETER(newState);
-
- HRESULT hr = S_OK;
- RS232Target* pTarget = NULL;
-
- if (m_pWpdBaseDriver != NULL)
- {
- pTarget = m_pWpdBaseDriver->GetRS232Target();
- if (pTarget != NULL)
- {
- hr = pTarget->Stop();
- }
- }
- return hr;
-}
-
-STDMETHODIMP_(VOID)
-CDevice::OnSurpriseRemoval(_In_ IWDFDevice* pDevice)
-{
- UNREFERENCED_PARAMETER(pDevice);
- return;
-}
-
-STDMETHODIMP_(HRESULT)
-CDevice::OnQueryRemove(_In_ IWDFDevice* /*pDevice*/)
-{
- return S_OK;
-}
-
-STDMETHODIMP_(HRESULT)
-CDevice::OnQueryStop(_In_ IWDFDevice* /*pDevice*/)
-{
- return S_OK;
-}
-
-STDMETHODIMP_(VOID)
-CDevice::OnSelfManagedIoCleanup(_In_ IWDFDevice* pDevice)
-{
- UNREFERENCED_PARAMETER(pDevice);
- return;
-}
-
-STDMETHODIMP_(VOID)
-CDevice::OnSelfManagedIoFlush(_In_ IWDFDevice* pDevice)
-{
- UNREFERENCED_PARAMETER(pDevice);
- return;
-}
-
-STDMETHODIMP_(HRESULT)
-CDevice::OnSelfManagedIoInit(_In_ IWDFDevice* pDevice)
-{
- UNREFERENCED_PARAMETER(pDevice);
- return S_OK;
-}
-
-STDMETHODIMP_(HRESULT)
-CDevice::OnSelfManagedIoSuspend(_In_ IWDFDevice* pDevice)
-{
- UNREFERENCED_PARAMETER(pDevice);
- return S_OK;
-}
-
-STDMETHODIMP_(HRESULT)
-CDevice::OnSelfManagedIoRestart(_In_ IWDFDevice* pDevice)
-{
- UNREFERENCED_PARAMETER(pDevice);
- return S_OK;
-}
-
-STDMETHODIMP_(HRESULT)
-CDevice::OnSelfManagedIoStop(_In_ IWDFDevice* pDevice)
-{
- UNREFERENCED_PARAMETER(pDevice);
- return S_OK;
-}
-
-STDMETHODIMP_(HRESULT)
-CDevice::OnPrepareHardware(_In_ IWDFDevice* pDevice)
-{
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DEVICE, "%!FUNC! Entry");
-
- HRESULT hr = S_OK;
-
- if (m_pWpdBaseDriver != NULL)
- {
- hr = m_pWpdBaseDriver->Initialize(pDevice);
- CHECK_HR(hr, "Failed to Initialize the driver class");
- }
-
- // Initialize the WPD Class Extension. This will enable the appropriate WPD interface GUID,
- // as well as do any additional initialization (e.g. enabling Legacy Compatibility layers for those drivers
- // which requested support in their INF).
- if (hr == S_OK && m_pPortableDeviceClassExtension == NULL)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceClassExtension,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceClassExtension,
- (VOID**)&m_pPortableDeviceClassExtension);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceClassExtension");
-
- if (hr == S_OK)
- {
- CComPtr<IPortableDeviceValues> pOptions;
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**)&pOptions);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
-
- if (hr == S_OK)
- {
- CComPtr<IPortableDevicePropVariantCollection> pContentTypes;
- hr = CoCreateInstance(CLSID_PortableDevicePropVariantCollection,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDevicePropVariantCollection,
- (VOID**)&pContentTypes);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDevicePropVariantCollection");
-
- // Driver has no supported content types, add an empty list of supported content types to the options
- if (hr == S_OK)
- {
- hr = pOptions->SetIPortableDevicePropVariantCollectionValue(WPD_CLASS_EXTENSION_OPTIONS_SUPPORTED_CONTENT_TYPES, pContentTypes);
- CHECK_HR(hr, "Failed to set WPD_CLASS_EXTENSION_OPTIONS_SUPPORTED_CONTENT_TYPES");
- }
-
- if (hr == S_OK)
- {
- // Initialize the PortableDeviceClassExtension
- hr = m_pPortableDeviceClassExtension->Initialize(pDevice, pOptions);
- CHECK_HR(hr, "Failed to Initialize portable device class extension object");
- }
- }
- }
-
- if (hr == S_OK)
- {
- // Since users commonly have the abiltity to customize their device even when it is not
- // connected to the PC, we need to make sure the PC is current when the driver loads.
- //
- // Send the latest device friendly name to the PortableDeviceClassExtension component
- // so the system is always updated with the current device name.
- //
- // This call should also be made after a successful property set operation of
- // WPD_DEVICE_FRIENDLY_NAME.
- LPWSTR wszDeviceFriendlyName = NULL;
-
- if (hr == S_OK)
- {
- hr = GetDeviceFriendlyName(&wszDeviceFriendlyName);
- CHECK_HR(hr, "Failed to get device's friendly name");
- }
-
- if (hr == S_OK && wszDeviceFriendlyName != NULL)
- {
- hr = UpdateDeviceFriendlyName(m_pPortableDeviceClassExtension, wszDeviceFriendlyName);
- CHECK_HR(hr, "Failed to update device's friendly name");
- }
-
- // Free the memory.
- CoTaskMemFree(wszDeviceFriendlyName);
- wszDeviceFriendlyName = NULL;
- }
- }
- return hr;
-}
-
-STDMETHODIMP_(HRESULT)
-CDevice::OnReleaseHardware(_In_ IWDFDevice* pDevice)
-{
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DEVICE, "%!FUNC! Entry");
-
- UNREFERENCED_PARAMETER(pDevice);
- if (m_pWpdBaseDriver != NULL)
- {
- m_pWpdBaseDriver->Uninitialize();
- }
-
- if (m_pPortableDeviceClassExtension != NULL)
- {
- m_pPortableDeviceClassExtension = NULL;
- }
-
- return S_OK;
-}
-
-HRESULT CDevice::GetDeviceFriendlyName(
- _Outptr_result_maybenull_ LPWSTR* pwszDeviceFriendlyName)
-{
- HRESULT hr = S_OK;
-
- CComPtr<IPortableDeviceValues> pParams;
- CComPtr<IPortableDeviceValues> pResults;
- CComPtr<IPortableDeviceKeyCollection> pKeys;
- CComPtr<IPortableDeviceValues> pValues;
-
- if (pwszDeviceFriendlyName == NULL)
- {
- hr = E_INVALIDARG;
- return hr;
- }
-
- *pwszDeviceFriendlyName = NULL;
-
- // CoCreate a collection to store the WPD_COMMAND_OBJECT_PROPERTIES_GET command parameters.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**)&pParams);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
- }
-
- // CoCreate a collection to store the WPD_COMMAND_OBJECT_PROPERTIES_GET command results.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**)&pResults);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
- }
-
- // CoCreate a collection to store the requested property keys. In our case, we are requesting just the device friendly name
- // (WPD_DEVICE_FRIENDLY_NAME)
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceKeyCollection,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceKeyCollection,
- (VOID**)&pKeys);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceKeyCollection for results");
- }
-
- // Set the params
- if (hr == S_OK)
- {
- hr = pParams->SetGuidValue(WPD_PROPERTY_COMMON_COMMAND_CATEGORY, WPD_COMMAND_OBJECT_PROPERTIES_GET.fmtid);
- CHECK_HR(hr, ("Failed to set WPD_PROPERTY_COMMON_COMMAND_CATEGORY"));
- }
-
- if (hr == S_OK)
- {
- hr = pParams->SetUnsignedIntegerValue(WPD_PROPERTY_COMMON_COMMAND_ID, WPD_COMMAND_OBJECT_PROPERTIES_GET.pid);
- CHECK_HR(hr, ("Failed to set WPD_PROPERTY_COMMON_COMMAND_ID"));
- }
-
- if (hr == S_OK)
- {
- hr = pParams->SetStringValue(WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID, WPD_DEVICE_OBJECT_ID);
- CHECK_HR(hr, ("Failed to set WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID"));
- }
-
- if (hr == S_OK)
- {
- hr = pKeys->Add(WPD_DEVICE_FRIENDLY_NAME);
- CHECK_HR(hr, ("Failed to add WPD_DEVICE_FRIENDLY_NAME to key collection"));
- }
-
- if (hr == S_OK)
- {
- hr = pParams->SetIPortableDeviceKeyCollectionValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS, pKeys);
- CHECK_HR(hr, ("Failed to set WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS"));
- }
-
- // Make the call
- if (hr == S_OK)
- {
- hr = m_pWpdBaseDriver->DispatchWpdMessage(pParams, pResults);
- CHECK_HR(hr, ("Failed to dispatch message to get supported content types"));
- }
-
- // Get the results
- if (hr == S_OK)
- {
- hr = pResults->GetIPortableDeviceValuesValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES, &pValues);
- CHECK_HR(hr, ("Failed to get WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES"));
- }
-
- if (hr == S_OK)
- {
- hr = pValues->GetStringValue(WPD_DEVICE_FRIENDLY_NAME, pwszDeviceFriendlyName);
- CHECK_HR(hr, ("Failed to get WPD_DEVICE_FRIENDLY_NAME"));
- }
-
- return hr;
-}
-
-HRESULT UpdateDeviceFriendlyName(
- _In_ IPortableDeviceClassExtension* pPortableDeviceClassExtension,
- _In_ LPCWSTR wszDeviceFriendlyName)
-{
- HRESULT hr = S_OK;
-
- // If we were passed NULL parameters we have nothing to do, return S_OK.
- if ((pPortableDeviceClassExtension == NULL) ||
- (wszDeviceFriendlyName == NULL))
- {
- return S_OK;
- }
-
- CComPtr<IPortableDeviceValues> pParams;
- CComPtr<IPortableDeviceValues> pResults;
- CComPtr<IPortableDeviceValues> pValues;
-
- // Prepare to make a call to set the device information
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**)&pParams);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
- }
-
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**)&pResults);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues for results");
- }
-
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**)&pValues);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues for results");
- }
-
- // Get the information values to update and set them in WPD_PROPERTY_CLASS_EXTENSION_DEVICE_INFORMATION_VALUES
- if (hr == S_OK)
- {
- hr = pValues->SetStringValue(WPD_DEVICE_FRIENDLY_NAME, wszDeviceFriendlyName);
- CHECK_HR(hr, ("Failed to set WPD_DEVICE_FRIENDLY_NAME"));
- }
-
- // Set the params
- if (hr == S_OK)
- {
- hr = pParams->SetGuidValue(WPD_PROPERTY_COMMON_COMMAND_CATEGORY, WPD_COMMAND_CLASS_EXTENSION_WRITE_DEVICE_INFORMATION.fmtid);
- CHECK_HR(hr, ("Failed to set WPD_PROPERTY_COMMON_COMMAND_CATEGORY"));
- }
- if (hr == S_OK)
- {
- hr = pParams->SetUnsignedIntegerValue(WPD_PROPERTY_COMMON_COMMAND_ID, WPD_COMMAND_CLASS_EXTENSION_WRITE_DEVICE_INFORMATION.pid);
- CHECK_HR(hr, ("Failed to set WPD_PROPERTY_COMMON_COMMAND_ID"));
- }
- if (hr == S_OK)
- {
- hr = pParams->SetIPortableDeviceValuesValue(WPD_PROPERTY_CLASS_EXTENSION_DEVICE_INFORMATION_VALUES, pValues);
- CHECK_HR(hr, ("Failed to set WPD_PROPERTY_CLASS_EXTENSION_DEVICE_INFORMATION_VALUES"));
- }
-
- // Make the call
- if (hr == S_OK)
- {
- hr = pPortableDeviceClassExtension->ProcessLibraryMessage(pParams, pResults);
- CHECK_HR(hr, ("Failed to process update device information message"));
- }
-
- // A Failed ProcessLibraryMessage operation for updating this value is not considered
- // fatal and should return S_OK.
-
- return S_OK;
-}
diff --git a/wpd/WpdBasicHardwareDriver/Device.h b/wpd/WpdBasicHardwareDriver/Device.h
deleted file mode 100644
index 6b7ed2d0..00000000
--- a/wpd/WpdBasicHardwareDriver/Device.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#pragma once
-
-#include "resource.h"
-#include "WpdBasicHardwareDriver.h"
-
-class ATL_NO_VTABLE CDevice :
- public CComObjectRootEx<CComMultiThreadModel>,
- public IPnpCallback,
- public IPnpCallbackSelfManagedIo,
- public IPnpCallbackHardware
-{
-public:
- CDevice() :
- m_pWpdBaseDriver(NULL)
- {
- }
-
- DECLARE_NOT_AGGREGATABLE(CDevice)
-
- BEGIN_COM_MAP(CDevice)
- COM_INTERFACE_ENTRY(IPnpCallback)
- COM_INTERFACE_ENTRY(IPnpCallbackSelfManagedIo)
- COM_INTERFACE_ENTRY(IPnpCallbackHardware)
- END_COM_MAP()
-
-public:
- static HRESULT
- CreateInstance(
- _In_ IWDFDeviceInitialize* pDeviceInit,
- _In_ WpdBaseDriver* pWpdBaseDriver,
- _COM_Outptr_ IUnknown** ppUnkwn)
- {
- *ppUnkwn = NULL;
-
- //
- // Set device properties.
- //
- pDeviceInit->SetLockingConstraint(None);
-
- CComObject< CDevice> *pMyDevice = NULL;
- HRESULT hr = CComObject<CDevice>::CreateInstance( &pMyDevice );
- if( SUCCEEDED (hr) )
- {
- pMyDevice->AddRef();
- hr = pMyDevice->QueryInterface( __uuidof(IUnknown),(void **) ppUnkwn);
- if (hr == S_OK)
- {
- pMyDevice->m_pWpdBaseDriver = pWpdBaseDriver;
- }
- pMyDevice->Release();
- pMyDevice = NULL;
- }
-
- return hr;
- }
-
- // IPnpCallback
- //
- STDMETHOD_(HRESULT, OnD0Entry) (_In_ IWDFDevice* pDevice, WDF_POWER_DEVICE_STATE previousState);
- STDMETHOD_(HRESULT, OnD0Exit) (_In_ IWDFDevice* pDevice, WDF_POWER_DEVICE_STATE newState);
- STDMETHOD_(VOID, OnSurpriseRemoval)(_In_ IWDFDevice* pDevice);
- STDMETHOD_(HRESULT, OnQueryRemove) (_In_ IWDFDevice* pDevice);
- STDMETHOD_(HRESULT, OnQueryStop) (_In_ IWDFDevice* pDevice);
-
- // IPnpCallbackSelfManagedIo
- //
- STDMETHOD_(VOID, OnSelfManagedIoCleanup)(_In_ IWDFDevice* pDevice);
- STDMETHOD_(VOID, OnSelfManagedIoFlush) (_In_ IWDFDevice* pDevice);
- STDMETHOD_(HRESULT, OnSelfManagedIoInit) (_In_ IWDFDevice* pDevice);
- STDMETHOD_(HRESULT, OnSelfManagedIoSuspend)(_In_ IWDFDevice* pDevice);
- STDMETHOD_(HRESULT, OnSelfManagedIoRestart)(_In_ IWDFDevice* pDevice);
- STDMETHOD_(HRESULT, OnSelfManagedIoStop) (_In_ IWDFDevice* pDevice);
-
- // IPnpCallbackHardware
- //
- STDMETHOD_(HRESULT, OnPrepareHardware)(_In_ IWDFDevice* pDevice);
- STDMETHOD_(HRESULT, OnReleaseHardware)(_In_ IWDFDevice* pDevice);
-
-private:
-
- HRESULT GetDeviceFriendlyName(
- _Outptr_result_maybenull_ LPWSTR* pwszDeviceFriendlyName);
-
-private:
-
- WpdBaseDriver* m_pWpdBaseDriver;
- CComPtr<IPortableDeviceClassExtension> m_pPortableDeviceClassExtension;
-};
-
diff --git a/wpd/WpdBasicHardwareDriver/Driver.cpp b/wpd/WpdBasicHardwareDriver/Driver.cpp
deleted file mode 100644
index ca0697a1..00000000
--- a/wpd/WpdBasicHardwareDriver/Driver.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-#include "stdafx.h"
-
-#include "Driver.tmh"
-
-CDriver::CDriver()
-{
-
-
-}
-
-HRESULT
-CDriver::OnDeviceAdd(
- _In_ IWDFDriver* pDriver,
- _In_ IWDFDeviceInitialize* pDeviceInit
- )
-/*++
-
-Routine Description:
-
- The framework calls this function when a device is being added to
- the driver stack.
-
-Arguments:
-
- IWDFDriver - Framework interface. The driver uses this
- interface to create device objects.
- IWDFDeviceInitialize - Framework interface. The driver uses this
- interface to set device parameters before
- creating the device obeject.
-
-Return Value:
-
- HRESULT S_OK - Device added successfully
-
---*/
-{
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DRIVER, "%!FUNC! Entry");
-
- HRESULT hr = S_OK;
- CComPtr<IUnknown> pDeviceCallback;
-
- WpdBaseDriver *pWpdBaseDriver = NULL;
-
- //
- // Create the WPD driver object that handles all WPD messages for this device
- //
- pWpdBaseDriver = new WpdBaseDriver();
- if(pWpdBaseDriver == NULL)
- {
- hr = E_OUTOFMEMORY;
- }
-
- if(SUCCEEDED(hr))
- {
- //
- // Create device callback object
- //
- hr = CDevice::CreateInstance(pDeviceInit, pWpdBaseDriver, &pDeviceCallback);
- }
-
- //
- // This driver has no special power management requirements and so
- // we set power policy ownership to UMDF to indicate that UMDF should
- // handle powermanagement for us.
- //
- pDeviceInit->SetPowerPolicyOwnership(FALSE);
-
- //
- // Create WDFDevice.
- //
- CComPtr<IWDFDevice> pIWDFDevice;
- if(SUCCEEDED(hr))
- {
- hr = pDriver->CreateDevice(
- pDeviceInit,
- pDeviceCallback,
- &pIWDFDevice);
- }
-
- //
- // Assign pWpdBaseDriver to the device object. Each UMDF device requires its own instance of
- // a WpdBaseDriver to handle WPD messages.
- //
- if(SUCCEEDED(hr))
- {
- hr = pIWDFDevice->AssignContext(this, (void*)pWpdBaseDriver);
- if(SUCCEEDED(hr))
- {
- // AddRef the WpdBaseDriver object since it is not stored with the
- // device context.
- pWpdBaseDriver->AddRef();
- }
- }
-
- //
- // Create queue callback object
- //
- CComPtr<IUnknown> pIUnknown;
- if(S_OK == hr)
- {
- hr = CQueue::CreateInstance(&pIUnknown);
- }
-
- //
- // Configure the default queue.
- //
- if(S_OK == hr)
- {
- CComPtr<IWDFIoQueue> pDefaultQueue;
- hr = pIWDFDevice->CreateIoQueue(
- pIUnknown,
- TRUE, // bDefaultQueue
- WdfIoQueueDispatchSequential,
- TRUE, // bPowerManaged
- FALSE, // bAllowZeroLengthRequests
- &pDefaultQueue);
- }
-
- pDeviceCallback = NULL;
- pIWDFDevice = NULL;
-
- //
- // It is fine to release the interface on the callback object.
- // The framework has its own refcount on this object and will
- // provide an interface when calling into the driver.
- //
- pIUnknown = NULL;
-
- // Release the WpdBaseDriver object. If it was successfully added to the device context,
- // it was already addref'd above. Releasing it here ensures it will be destroyed if
- // an error occured and it could not be added to the device context.
- SAFE_RELEASE(pWpdBaseDriver);
-
- return hr;
-}
-
-void
-CDriver::OnDeinitialize(
- _In_ IWDFDriver* pDriver
- )
-/*++
-
-Routine Description:
-
- The framework calls this function just before de-initializing itself. All
- WDF framework resources should be released by driver before returning from this call.
-
-Arguments:
-
-Return Value:
-
---*/
-{
- UNREFERENCED_PARAMETER(pDriver);
- return;
-}
-
-HRESULT
-CDriver::OnInitialize(
- _In_ IWDFDriver* pDriver
- )
-/*++
-
-Routine Description:
-
- The framework calls this function just after loading the driver. The driver can
- perform any global, device independent intialization in this routine.
-
-Arguments:
-
-Return Value:
-
---*/
-{
- UNREFERENCED_PARAMETER(pDriver);
- return S_OK;
-}
-
-STDMETHODIMP_ (void)
-CDriver::OnCleanup(
- _In_ IWDFObject* pWdfObject
- )
-{
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DRIVER, "%!FUNC! Entry");
-
- // Release the base driver object
- HRESULT hr = S_OK;
- WpdBaseDriver* pWpdBaseDriver = NULL;
-
- hr = pWdfObject->RetrieveContext((void**)&pWpdBaseDriver);
- if((hr == S_OK) && (pWpdBaseDriver != NULL))
- {
- pWpdBaseDriver->Release();
- pWpdBaseDriver = NULL;
- }
-}
-
diff --git a/wpd/WpdBasicHardwareDriver/Driver.h b/wpd/WpdBasicHardwareDriver/Driver.h
deleted file mode 100644
index 9b8cadec..00000000
--- a/wpd/WpdBasicHardwareDriver/Driver.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#pragma once
-
-class ATL_NO_VTABLE CDriver :
- public CComObjectRootEx<CComMultiThreadModel>,
- public CComCoClass<CDriver, &CLSID_WpdBasicHardwareDriver>,
- public IDriverEntry,
- public IObjectCleanup
-{
-public:
- CDriver();
-
- DECLARE_REGISTRY_RESOURCEID(IDR_WpdBasicHardwareDriver)
-
- DECLARE_NOT_AGGREGATABLE(CDriver)
-
- BEGIN_COM_MAP(CDriver)
- COM_INTERFACE_ENTRY(IDriverEntry)
- END_COM_MAP()
-
-public:
- //
- // IDriverEntry
- //
- STDMETHOD (OnInitialize)(
- _In_ IWDFDriver* pDriver
- );
- STDMETHOD (OnDeviceAdd)(
- _In_ IWDFDriver* pDriver,
- _In_ IWDFDeviceInitialize* pDeviceInit
- );
- STDMETHOD_ (void, OnDeinitialize)(
- _In_ IWDFDriver* pDriver
- );
-
- //
- // IObjectCleanup
- //
- STDMETHOD_ (void, OnCleanup)(
- _In_ IWDFObject* pWdfObject
- );
-};
-
-OBJECT_ENTRY_AUTO(__uuidof(WpdBasicHardwareDriver), CDriver)
-
diff --git a/wpd/WpdBasicHardwareDriver/Queue.cpp b/wpd/WpdBasicHardwareDriver/Queue.cpp
deleted file mode 100644
index e4e81c09..00000000
--- a/wpd/WpdBasicHardwareDriver/Queue.cpp
+++ /dev/null
@@ -1,340 +0,0 @@
-// Queue.cpp : Implementation of CQueue
-
-
-#include "stdafx.h"
-#include <devioctl.h>
-
-#include "Queue.tmh"
-
-// Add table used to lookup the Access required for Wpd Commands
-BEGIN_WPD_COMMAND_ACCESS_MAP(g_WpdCommandAccessMap)
- DECLARE_WPD_STANDARD_COMMAND_ACCESS_ENTRIES
- // Add any custom commands here e.g.
- // WPD_COMMAND_ACCESS_ENTRY(MyCustomCommand, WPD_COMMAND_ACCESS_READWRITE)
-END_WPD_COMMAND_ACCESS_MAP
-
-// This enables use to use VERIFY_WPD_COMMAND_ACCESS to check command access function for us.
-DECLARE_VERIFY_WPD_COMMAND_ACCESS;
-
-/******************************************************************************
- * This function calls the WpdBaseDriver to handle the WPD message. In order
- * to do this it does the following:
- *
- * - Deserializes pBuffer into an IPortableDeviceValues which holds the command
- * input parameters from the WPD application.
- * - Creates an IPortableDeviceValues for the results.
- * - Calls the WpdBaseDriver to handle the message. (The results of this
- * operation are put into the previously created results IPortableDeviceValues.)
- * - The results IPortableDeviceValues is then serialized back into pBuffer, making
- * sure that it does not overrun ulOutputBufferLength.
- *
- *****************************************************************************/
-HRESULT CQueue::ProcessWpdMessage(
- ULONG ControlCode,
- _In_ ContextMap* pClientContextMap,
- _In_ IWDFDevice* pDevice,
- _In_reads_bytes_(ulInputBufferLength) PVOID pInBuffer,
- ULONG ulInputBufferLength,
- _Out_writes_bytes_to_(ulOutputBufferLength, *pdwBytesWritten) PVOID pOutBuffer,
- ULONG ulOutputBufferLength,
- _Out_ DWORD* pdwBytesWritten)
-{
- CComCritSecLock<CComAutoCriticalSection> Lock(m_CriticalSection);
-
- HRESULT hr = S_OK;
- CComPtr<IPortableDeviceValues> pParams;
- CComPtr<IPortableDeviceValues> pResults;
- CComPtr<WpdBaseDriver> pWpdBaseDriver;
-
- *pdwBytesWritten = 0;
-
- if (hr == S_OK)
- {
- hr = m_pWpdSerializer->GetIPortableDeviceValuesFromBuffer((BYTE*)pInBuffer,
- ulInputBufferLength,
- &pParams);
- CHECK_HR(hr, "Failed to deserialize command parameters from input buffer");
- }
-
- // Verify that that command was sent with the appropriate access
- if (hr == S_OK)
- {
- hr = VERIFY_WPD_COMMAND_ACCESS(ControlCode, pParams, g_WpdCommandAccessMap);
- CHECK_HR(hr, "Wpd Command was sent with incorrect access flags");
- }
-
- // Create the WPD results collection
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**)&pResults);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
- }
-
- // Insert the client context map as one of this driver's private properties. This is
- // just a convenient place holder which allows other methods down the chain to
- // access the context map.
- if (hr == S_OK)
- {
- hr = pParams->SetIUnknownValue(PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP, pClientContextMap);
- CHECK_HR(hr, "Failed to set PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP");
- }
-
- // Insert the IWDFDevice interface as one of this driver's private properties. This is
- // just a convenient place holder which allows other methods down the chain to
- // access the WUDF Device object.
- if (hr == S_OK)
- {
- hr = pParams->SetIUnknownValue(PRIVATE_SAMPLE_DRIVER_WUDF_DEVICE_OBJECT, pDevice);
- CHECK_HR(hr, "Failed to set PRIVATE_SAMPLE_DRIVER_WUDF_DEVICE_OBJECT");
- }
-
- // Insert the IWpdSerializer interface as one of this driver's private properties. This is
- // just a convenient place holder which allows other methods down the chain to
- // access the WPD Serializer object.
- if (hr == S_OK)
- {
- hr = pParams->SetIUnknownValue(PRIVATE_SAMPLE_DRIVER_WPD_SERIALIZER_OBJECT, m_pWpdSerializer);
- CHECK_HR(hr, "Failed to set PRIVATE_SAMPLE_DRIVER_WPD_SERIALIZER_OBJECT");
- }
-
- // Get the WpdBaseDriver so we can dispatch the message
- if (hr == S_OK)
- {
- hr = GetWpdBaseDriver(pDevice, &pWpdBaseDriver);
- CHECK_HR(hr, "Failed to get WpdBaseDriver");
- }
-
- if (hr == S_OK)
- {
- hr = pWpdBaseDriver->DispatchWpdMessage(pParams, pResults);
- CHECK_HR(hr, "Failed to handle WPD command");
- }
-
- if (hr == S_OK)
- {
- hr = m_pWpdSerializer->WriteIPortableDeviceValuesToBuffer(ulOutputBufferLength,
- pResults,
- (BYTE*)pOutBuffer,
- pdwBytesWritten);
- CHECK_HR(hr, "Failed to serialize results to output buffer");
- }
-
- return hr;
-}
-
-/******************************************************************************
- * This method gets the WpdBaseDriver associated with the UMDF device object.
- * The caller should Release *ppWpdBaseDriver when it is done.
- *
- * When this device was created, we assigned the WpdBaseDriver as the context.
- * So, in order to retrieve the correct WpdBaseDriver for this device, we simply
- * get the device context.
- *****************************************************************************/
-HRESULT CQueue::GetWpdBaseDriver(
- _In_ IWDFDevice* pDevice,
- _Outptr_result_nullonfailure_ WpdBaseDriver** ppWpdBaseDriver)
-{
- HRESULT hr = S_OK;
- WpdBaseDriver* pContext = NULL;
-
- if((pDevice == NULL) || (ppWpdBaseDriver == NULL))
- {
- hr = E_POINTER;
- CHECK_HR(hr, "Cannot have NULL parameter for pDevice or ppWpdBaseDriver");
- }
-
- *ppWpdBaseDriver = NULL;
-
- if(SUCCEEDED(hr))
- {
- hr = pDevice->RetrieveContext((void**)&pContext);
- if(SUCCEEDED(hr))
- {
- if(pContext != NULL)
- {
- pContext->AddRef();
- *ppWpdBaseDriver = pContext;
- }
- else
- {
- hr = E_UNEXPECTED;
- CHECK_HR(hr, "Device context is NULL");
- }
- }
- }
-
- return hr;
-}
-
-// CQueue
-
-STDMETHODIMP_ (void)
-CQueue::OnCreateFile(
- _In_ IWDFIoQueue* pQueue,
- _In_ IWDFIoRequest* pRequest,
- _In_ IWDFFile* pFileObject
- )
-{
- UNREFERENCED_PARAMETER(pQueue);
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_QUEUE, "%!FUNC! Entry");
-
- // This critical section protects the section of code where we
- // Create the serializer and results interfaces used in handling I/O messages.
- // We only need to create them once, then we hang on to them for the lifetime of this
- // queue object.
- CComCritSecLock<CComAutoCriticalSection> Lock(m_CriticalSection);
- HRESULT hr = S_OK;
-
- // Create the WPD serializer
- if ((hr == S_OK) &&
- (m_pWpdSerializer == NULL))
- {
- hr = CoCreateInstance(CLSID_WpdSerializer,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IWpdSerializer,
- (VOID**)&m_pWpdSerializer);
-
- CHECK_HR(hr, "Failed to CoCreate CLSID_WpdSerializer");
- }
-
- // Create the client context map and associate it with the File Object
- // so we can obtain it on a per-client basis.
- if (hr == S_OK)
- {
- ContextMap* pClientContextMap = new ContextMap();
-
- if(pClientContextMap != NULL)
- {
- hr = pFileObject->AssignContext(this, (void*)pClientContextMap);
- CHECK_HR(hr, "Failed to set client context map");
-
- // Release the client context map if we cannot set it
- // properly
- if(FAILED(hr))
- {
- pClientContextMap->Release();
- pClientContextMap = NULL;
- }
- }
- else
- {
- hr = E_OUTOFMEMORY;
- CHECK_HR(hr, "Failed to create client context map");
- }
- }
-
- pRequest->Complete(hr);
- return;
-}
-
-STDMETHODIMP_ (void)
-CQueue::OnDeviceIoControl(
- _In_ IWDFIoQueue* pQueue,
- _In_ IWDFIoRequest* pRequest,
- ULONG ControlCode,
- SIZE_T InputBufferSizeInBytes,
- SIZE_T OutputBufferSizeInBytes
- )
-{
- UNREFERENCED_PARAMETER(InputBufferSizeInBytes);
- UNREFERENCED_PARAMETER(OutputBufferSizeInBytes);
-
- HRESULT hr = S_OK;
- DWORD dwBytesWritten = 0;
-
- if(IS_WPD_IOCTL(ControlCode))
- {
- BYTE* pInputBuffer = NULL;
- SIZE_T cbInputBuffer = 0;
- BYTE* pOutputBuffer = NULL;
- SIZE_T cbOutputBuffer = 0;
- ContextMap* pClientContextMap = NULL;
- CComPtr<IWDFMemory> pMemoryIn;
- CComPtr<IWDFMemory> pMemoryOut;
- CComPtr<IWDFDevice> pDevice;
- CComPtr<IWDFFile> pFileObject;
-
- //
- // Get input memory buffer, the memory object is always returned even if the
- // underlying buffer is NULL
- //
- pRequest->GetInputMemory(&pMemoryIn);
- pInputBuffer = (BYTE*) pMemoryIn->GetDataBuffer(&cbInputBuffer);
-
- //
- // Get output memory buffer, the memory object is always returned even if the
- // underlying buffer is NULL
- //
- pRequest->GetOutputMemory(&pMemoryOut);
- pOutputBuffer = (BYTE*) pMemoryOut->GetDataBuffer(&cbOutputBuffer);
-
- // Get the Context map for this client
- pRequest->GetFileObject(&pFileObject);
- if (pFileObject != NULL)
- {
- hr = pFileObject->RetrieveContext((void**)&pClientContextMap);
- CHECK_HR(hr, "Failed to get Contextmap from WDF File Object");
-
- if (hr == S_OK)
- {
- // Get the device object
- pQueue->GetDevice(&pDevice );
- hr = ProcessWpdMessage(ControlCode,
- pClientContextMap,
- pDevice,
- pInputBuffer,
- (DWORD)cbInputBuffer,
- pOutputBuffer,
- (DWORD)cbOutputBuffer,
- &dwBytesWritten);
- }
- }
- else
- {
- hr = E_UNEXPECTED;
- CHECK_HR(hr, "WDF File Object is NULL");
- }
- }
- else
- {
- hr = E_UNEXPECTED;
- CHECK_HR(hr, "Received invalid/unsupported IOCTL code '0x%lx'",ControlCode);
- }
-
- // Complete the request
- if (hr == S_OK)
- {
- pRequest->CompleteWithInformation(hr, dwBytesWritten);
- }
- else
- {
- pRequest->Complete(hr);
- }
-
- return;
-}
-
-STDMETHODIMP_ (void)
-CQueue::OnCleanup(
- _In_ IWDFObject* pWdfObject
- )
-{
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_QUEUE, "%!FUNC! Entry");
-
- // Destroy the client context map
- HRESULT hr = S_OK;
- ContextMap* pClientContextMap = NULL;
-
- hr = pWdfObject->RetrieveContext((void**)&pClientContextMap);
- if((hr == S_OK) && (pClientContextMap != NULL))
- {
- pClientContextMap->Release();
- pClientContextMap = NULL;
- }
-}
-
diff --git a/wpd/WpdBasicHardwareDriver/Queue.h b/wpd/WpdBasicHardwareDriver/Queue.h
deleted file mode 100644
index e5cea69d..00000000
--- a/wpd/WpdBasicHardwareDriver/Queue.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// Queue.h : Declaration of the CQueue
-
-#pragma once
-#include "resource.h" // main symbols
-#include "WpdBasicHardwareDriver.h"
-
-class ATL_NO_VTABLE CQueue :
- public CComObjectRootEx<CComMultiThreadModel>,
- public IQueueCallbackDeviceIoControl,
- public IQueueCallbackCreate,
- public IObjectCleanup
-{
-public:
- CQueue()
- {
-
- }
-
- DECLARE_NOT_AGGREGATABLE(CQueue)
-
- BEGIN_COM_MAP(CQueue)
- COM_INTERFACE_ENTRY(IQueueCallbackDeviceIoControl)
- COM_INTERFACE_ENTRY(IQueueCallbackCreate)
- END_COM_MAP()
-
-public:
- static
- HRESULT CreateInstance(
- _COM_Outptr_ IUnknown **ppUkwn)
- {
- *ppUkwn = NULL;
- CComObject< CQueue> *pMyQueue = NULL;
- HRESULT hr = CComObject<CQueue>::CreateInstance( &pMyQueue );
- if( SUCCEEDED (hr) )
- {
- pMyQueue->AddRef();
- hr = pMyQueue->QueryInterface( __uuidof(IUnknown), (void **) ppUkwn );
- pMyQueue->Release();
- pMyQueue = NULL;
- }
-
- return hr;
- }
-
- //
- // Wdf Callbacks
- //
-
- // IQueueCallbackCreateClose
- //
- STDMETHOD_ (void, OnCreateFile)(
- _In_ IWDFIoQueue *pQueue,
- _In_ IWDFIoRequest *pRequest,
- _In_ IWDFFile *pFileObject
- );
-
- //
- // IQueueCallbackDeviceIoControl
- //
- STDMETHOD_ (void, OnDeviceIoControl)(
- _In_ IWDFIoQueue* pQueue,
- _In_ IWDFIoRequest* pRequest,
- ULONG ControlCode,
- SIZE_T InputBufferSizeInBytes,
- SIZE_T OutputBufferSizeInBytes
- );
-
- //
- // IObjectCleanup
- //
- STDMETHOD_ (void, OnCleanup)(
- _In_ IWDFObject* pWdfObject
- );
-
-private:
- HRESULT ProcessWpdMessage(
- ULONG ControlCode,
- _In_ ContextMap* pClientContextMap,
- _In_ IWDFDevice* pDevice,
- _In_reads_bytes_(ulInputBufferLength) PVOID pInBuffer,
- ULONG ulInputBufferLength,
- _Out_writes_bytes_to_(ulOutputBufferLength, *pdwBytesWritten) PVOID pOutBuffer,
- ULONG ulOutputBufferLength,
- _Out_ DWORD* pdwBytesWritten);
-
- HRESULT GetWpdBaseDriver(
- _In_ IWDFDevice* pDevice,
- _Outptr_result_nullonfailure_ WpdBaseDriver** ppWpdBaseDriver);
-
- CComPtr<IWpdSerializer> m_pWpdSerializer;
- CComAutoCriticalSection m_CriticalSection;
-};
-
diff --git a/wpd/WpdBasicHardwareDriver/README.md b/wpd/WpdBasicHardwareDriver/README.md
deleted file mode 100644
index 56414e93..00000000
--- a/wpd/WpdBasicHardwareDriver/README.md
+++ /dev/null
@@ -1,52 +0,0 @@
----
-page_type: sample
-description: "Supports nine sensor devices that integrate with the Parallax BS2 programmable microcontroller."
-languages:
-- cpp
-products:
-- windows
-- windows-wdk
----
-
-# WPD Basic Hardware Sample Driver (UMDF Version 1)
-
-The WpdBasicHardwareDriver is a WPD driver that supports nine devices. These devices were selected because of their simplicity. This simplicity allowed the sample to focus on the tasks that are common to portable devices without getting bogged down in hardware complexities.
-
-This sample driver is based on the WpdHelloWorldDriver that is also included in the Windows Driver Kit (WDK). The "Supporting the WPD Infrastructure" sections for this driver show the changes that were made to the WpdHelloWorldDriver source so that it can communicate with basic hardware devices. Before you work through the topics in this section of the documentation, be familiar with the WpdHelloWorldDriver.
-
-The sensor devices that are supported by the WpdBasicHardwareDriver, such as the Memsic 2125 Accelerometer, are sold by the Parallax Corporation in Rocklin, California.
-
-To use these sensors with the WpdBasicHardwareDriver, you must purchase the sensors, a programmable microcontroller (Parallax BS2), a test board (like the Parallax BASIC Stamp Homework Board), an RS232 cable, and miscellaneous parts. All of this hardware is available from Parallax and can be ordered through their Web site.
-
-The circuit designs are based on the sample circuits provided by Parallax in their sensor data sheets. These circuits are designed to integrate each sensor with the Parallax BS2 programmable microcontroller .
-
-The microcontroller firmware for each of the nine circuits is included in the **\\firmware** subdirectory of this sample.
-
-For a complete description of this sample and its underlying code and functionality, refer to the [WPD Basic Hardware Driver](https://docs.microsoft.com/windows-hardware/drivers/portable/the-wpdbasichardwaredriver-sample) description in the Windows Driver Kit documentation.
-
-## Related topics
-
-[WPD Design Guide](https://docs.microsoft.com/windows-hardware/drivers/portable/wpd-design-guide)
-
-[WPD Driver Development Tools](https://docs.microsoft.com/windows-hardware/drivers/portable/familiarizing-yourself-with-the-sample-driver)
-
-[WPD Programming Guide](https://docs.microsoft.com/windows-hardware/drivers/portable/wpd-programming-guide)
-
-## Installation
-
-To test this sample, you must have a test computer. This can be a second computer or, if necessary, your development computer.
-
-To install the WpdBasicHardwareDriver sample, do the following:
-
-1. Copy the driver binary and the wpdbasichardwaredriver.inf file to a directory on your test computer (for example, C:\\wpdbasichardwaredriver.)
-
-1. Copy the UMDF coinstaller, WUDFUpdate\_*MMmmmm*.dll, from the \\redist\\wdf\\\<architecture\> directory to the same directory (for example, C:\\wpdbasichardwaredriver).
-
- > [!NOTE]
- > You can obtain the co-installers by downloading and installing the "Windows Driver Framework (WDF)" package from [WDK 8 Redistributable Components](https://go.microsoft.com/fwlink/p/?LinkID=253170).
-
-1. Navigate to the directory that contains the INF file and binaries (for example, cd /d c:\\wpdbasichardwaredriver), and run DevCon.exe as follows:
-
- `devcon.exe install wpdbasichardwaredriver.inf WUDF\WpdBasicHardware`
-
- You can find DevCon.exe in the \\tools directory of the WDK (for example, \\tools\\devcon\\i386\\devcon.exe).
diff --git a/wpd/WpdBasicHardwareDriver/RS232Connection.cpp b/wpd/WpdBasicHardwareDriver/RS232Connection.cpp
deleted file mode 100644
index eab5479b..00000000
--- a/wpd/WpdBasicHardwareDriver/RS232Connection.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-#include "stdafx.h"
-
-#include "RS232Connection.tmh"
-
-/*-----------------------------------------------------------------------------
-
-FUNCTION: RS232Connection()
-
-PURPOSE: Constructor. Initializes TTY structure
-
-COMMENTS: This structure is a collection of TTY attributes
- used by all parts of this program
-
-HISTORY: Date: Author: Comment:
- 10/27/95 AllenD Wrote it
- 2/14/96 AllenD Removed npTTYInfo
- 12/06/06 DonnMo Changed return value type
- 12/06/06 DonnMo Replaced macro calls with member-variable settings
- 12/06/06 DonnMo Removed initialization of font-related variables
-
------------------------------------------------------------------------------*/
-RS232Connection::RS232Connection()
-{
- //
- // initialize generial TTY info
- //
- m_hCommPort = NULL;
- m_fConnected = FALSE;
- m_fLocalEcho = FALSE;
- m_bPort = 1;
- m_dwBaudRate = CBR_9600;
- m_bByteSize = 8;
- m_bParity = NOPARITY;
- m_bStopBits = ONESTOPBIT;
- m_fAutowrap = TRUE;
- m_fNewLine = FALSE;
- m_fDisplayErrors = TRUE;
-
- //
- // timeouts
- //
-
- //
- // TimeoutsDefault
- // We need ReadIntervalTimeout here to cause the read operations
- // that we do to actually timeout and become overlapped.
- // Specifying 1 here causes ReadFile to return very quickly
- // so that our reader thread will continue execution.
- //
-
- m_TimeoutsDefault = { 25, 0, 0, 0, 0 };
- m_timeoutsnew = m_TimeoutsDefault;
-
- //
- // read state and status events
- //
- m_dwReceiveState = RECEIVE_TTY;
- m_dwEventFlags = EVENTFLAGS_DEFAULT;
- m_chFlag = FLAGCHAR_DEFAULT;
-
- //
- // Flow Control Settings
- //
- m_fDtrControl = DTR_CONTROL_ENABLE;
- m_fRtsControl = RTS_CONTROL_ENABLE;
- m_chXON = ASCII_XON;
- m_chXOFF = ASCII_XOFF;
- m_wXONLimit = 0;
- m_wXOFFLimit = 0;
- m_fCTSOutFlow = FALSE;
- m_fDSROutFlow = FALSE;
- m_fDSRInFlow = FALSE;
- m_fXonXoffOutFlow = FALSE;
- m_fXonXoffInFlow = FALSE;
- m_fTXafterXoffSent = FALSE;
- m_fNoReading = FALSE;
- m_fNoWriting = FALSE;
- m_fNoEvents = FALSE;
- m_fNoStatus = FALSE;
- m_fDisplayTimeouts = FALSE;
-
-}
-
-
-/*-----------------------------------------------------------------------------
-
-FUNCTION: SetPortState( void )
-
-PURPOSE: Sets port state based on settings from the user
-
-COMMENTS: Sets up DCB structure and calls SetCommState.
- Sets up new timeouts by calling SetCommTimeouts.
-
-HISTORY: Date: Author: Comment:
- 1/9/96 AllenD Wrote it
- 12/06/06 DonnMo Replaced calls to ErrorReporter() with CHECK_HR()
-
------------------------------------------------------------------------------*/
-HRESULT RS232Connection::SetPortState()
-{
- HRESULT hr = S_OK;
- DCB dcb = {0};
- DWORD dwLastError = 0;
-
- dcb.DCBlength = sizeof(dcb);
-
- //
- // get current DCB settings
- //
- if (!GetCommState(m_hCommPort, &dcb))
- {
- dwLastError = GetLastError();
- hr = HRESULT_FROM_WIN32(dwLastError);
- CHECK_HR(hr, "GetCommState() failed within SetPortState().");
- return hr;
- }
-
- //
- // update DCB rate, byte size, parity, and stop bits size
- //
- dcb.BaudRate = m_dwBaudRate;
- dcb.ByteSize = m_bByteSize;
- dcb.Parity = m_bParity;
- dcb.StopBits = m_bStopBits;
-
- //
- // update event flags
- //
- if (m_dwEventFlags & EV_RXFLAG)
- {
- dcb.EvtChar = m_chFlag;
- }
- else
- {
- dcb.EvtChar = '\0';
- }
-
- dcb.EofChar = '\n';
-
- //
- // update flow control settings
- //
- dcb.fDtrControl = m_fDtrControl;
- dcb.fRtsControl = m_fRtsControl;
-
- dcb.fOutxCtsFlow = m_fCTSOutFlow;
- dcb.fOutxDsrFlow = m_fDSROutFlow;
- dcb.fDsrSensitivity = m_fDSRInFlow;
- dcb.fOutX = m_fXonXoffOutFlow;
- dcb.fInX = m_fXonXoffInFlow;
- dcb.fTXContinueOnXoff = m_fTXafterXoffSent;
- dcb.XonChar = m_chXON;
- dcb.XoffChar = m_chXOFF;
- dcb.XonLim = m_wXONLimit;
- dcb.XoffLim = m_wXOFFLimit;
-
- //
- // DCB settings not in the user's control
- //
- dcb.fParity = TRUE;
-
- //
- // set new state
- //
- if (!SetCommState(m_hCommPort, &dcb))
- {
- dwLastError = GetLastError();
- hr = HRESULT_FROM_WIN32(dwLastError);
- CHECK_HR(hr, "SetCommState() failed within SetPortState() when setting the new state.");
- return hr;
- }
-
-
- //
- // set new timeouts
- //
- if (!SetCommTimeouts(m_hCommPort, &m_timeoutsnew))
- {
- dwLastError = GetLastError();
- hr = HRESULT_FROM_WIN32(dwLastError);
- CHECK_HR(hr, "SetCommTimeouts() failed within SetPortState() when setting the new timeouts.");
- return hr;
- }
-
- return hr;
-}
-
-
-/*-----------------------------------------------------------------------------
-
-FUNCTION: Connect( void )
-
-PURPOSE: Setup Communication Port with our settings
-
-RETURN:
- S_OK and handle of com port if successful
-
------------------------------------------------------------------------------*/
-HRESULT RS232Connection::Connect(_In_ LPCWSTR wszPortName, _Out_ HANDLE *phCommPort)
-{
- HRESULT hr = S_OK;
- DWORD dwLastError = 0;
-
- if (phCommPort == NULL)
- {
- hr = E_POINTER;
- CHECK_HR(hr, "A NULL phCommPort parameter was received");
- return hr;
- }
-
- *phCommPort = NULL;
-
- //
- // retrieve a handle for the com port
- // and configure the port for asynchronous
- // communications.
- //
- m_hCommPort = CreateFileW(wszPortName,
- GENERIC_READ | GENERIC_WRITE,
- 0,
- 0,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
- 0);
-
- if (m_hCommPort == NULL)
- {
- dwLastError = GetLastError();
- hr = HRESULT_FROM_WIN32(dwLastError);
- CHECK_HR(hr, "CreateFileW() failed in RS232Connection::Connect");
- return hr;
- }
-
- //
- // Save original comm timeouts and set new ones
- //
- if (!GetCommTimeouts( m_hCommPort, &(m_timeoutsorig)))
- {
- dwLastError = GetLastError();
- hr = HRESULT_FROM_WIN32(dwLastError);
- CHECK_HR(hr, "GetCommTimeouts() failed within RS232Connection::Connect");
- return hr;
- }
-
- //
- // Set port state
- //
- hr = SetPortState();
- if (FAILED(hr))
- {
- CHECK_HR(hr, "SetPortState() failed within RS232Connection::Connect");
- return hr;
- }
-
- //
- // set comm buffer sizes
- //
- if (!SetupComm(m_hCommPort, MAX_READ_BUFFER, MAX_WRITE_BUFFER))
- {
- dwLastError = GetLastError();
- hr = HRESULT_FROM_WIN32(dwLastError);
- CHECK_HR(hr, "SetupComm(SETDTR) failed within RS232Connection::Connect");
- return hr;
- }
-
- //
- // raise DTR
- //
- if (!EscapeCommFunction(m_hCommPort, SETDTR))
- {
- dwLastError = GetLastError();
- hr = HRESULT_FROM_WIN32(dwLastError);
- CHECK_HR(hr, "EscapeCommFunction() failed within RS232Connection::Connect");
- return hr;
- }
-
- //
- // set overall connect flag
- //
- m_fConnected = TRUE;
-
- //
- // set the return value
- //
- *phCommPort = m_hCommPort;
-
-
- if (SUCCEEDED(hr))
- {
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DEVICE, "%!FUNC! handle: %p", m_hCommPort);
- }
-
- return hr;
-}
-
-
-/*-----------------------------------------------------------------------------
-
-FUNCTION: Disconnect( void )
-
-PURPOSE: Tears down the Communication Port
-
-RETURN: nothing
-
------------------------------------------------------------------------------*/
-void RS232Connection::Disconnect()
-{
- if (m_hCommPort != NULL)
- {
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DEVICE, "%!FUNC! handle: %p", m_hCommPort);
-
- CloseHandle(m_hCommPort);
- m_hCommPort = NULL;
-
- }
-} \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/RS232Connection.h b/wpd/WpdBasicHardwareDriver/RS232Connection.h
deleted file mode 100644
index cd7f10b7..00000000
--- a/wpd/WpdBasicHardwareDriver/RS232Connection.h
+++ /dev/null
@@ -1,153 +0,0 @@
-#pragma once
-
-//
-// Sensor device structures and definitions
-//
-
-//
-// Format of the 9-byte receive packet (device to PC):
-//
-// ORIGINAL TEMP_SENSOR PACKET FORMAT: [ VALUE (4 bytes) | INTERVAL (5 bytes) ]
-//
-// Format of the multi-byte receive packet (device to PC):
-//
-// NEW PACKET FORMAT: [ SENSOR_ID (1 byte) | ELEMENT_COUNT (1 byte) | ELEMENT_SIZE (1 byte) | ELEMENTS (size bytes) | INTERVAL (5 bytes) ]
-// COMPASS PACKET FORMAT: [ SENSOR_ID = 1 | ELEMENT_COUNT = 1 | ELEMENT_SIZE = 3 | HEADING 3-bytes | INTERVAL (5 bytes) ]
-// SENSIRON PACKET FORMAT: [ SENSOR_ID = 2 | ELEMENT_COUNT = 1 | ELEMENT_SIZE = 7 | TEMP 4-bytes | HUMIDITY 3-bytes | INTERVAL (5 bytes) ]
-// FLEX PACKET FORMAT: [ SENSOR_ID = 3 | ELEMENT_COUNT = 1 | ELEMENT_SIZE = 5 | PRESSURE 5-bytes | INTERVAL (5 bytes) ]
-// PING PACKET FORMAT: [ SENSOR_ID = 4 | ELEMENT_COUNT = 1 | ELEMENT_SIZE = 5 | PRESSURE 5-bytes | INTERVAL (5 bytes) ]
-// PIR PACKET FORMAT: [ SENSOR_ID = 5 | ELEMENT_COUNT = 1 | ELEMENT_SIZE = 1 | STATE 1-byte | INTERVAL (5 bytes) ]
-// MEMSIC PACKET FORMAT: [ SENSOR_ID = 6 | ELEMENT_COUNT = 1 | ELEMENT_SIZE = 6 | X-Axis Gs 3-bytes | Y-Axis Gs 3-bytes | INTERVAL (5 bytes) ]
-// QTI PACKET FORMAT: [ SENSOR_ID = 7 | ELEMENT_COUNT = 1 | ELEMENT_SIZE = 4 | PRESSURE 4-bytes | INTERVAL (5 bytes) ]
-// PIEZO PACKET FORMAT: [ SENSOR_ID = 8 | ELEMENT_COUNT = 1 | ELEMENT_SIZE = 1 | STATE 1-byte | INTERVAL (5 bytes)
-// HITACHI PACKET FORMAT: [ SENSOR_ID = 9 | ELEMENT_COUNT = 3 | ELEMENT_SIZE = 4 | X-Axis Gs 4-bytes | Y-Axis Gs 4-bytes | Z-Axis Gs 4-bytes | INTERVAL (5 bytes) ]
-//
-//
-// Format of the 6-byte send packet (PC to device):
-// The final NULL byte signals the SERIN DEC formatter to stop reading
-//
-// [ INTERVAL (5 bytes) | 0 (1 byte) ]
-//
-#define INTERVAL_DATA_LENGTH 6 // count of bytes for interval
-#define MIN_DATA_LENGTH 4 // minimum count of bytes for any sensor
-#define MAX_DATA_LENGTH 21 // maximum count of bytes for any sensor
-#define MAX_AMOUNT_TO_READ (MAX_DATA_LENGTH+INTERVAL_DATA_LENGTH) // maximum total bytes to read
-
-#define MEMSIC_DATA_LENGTH 9 // count of data bytes for Memsic dual-axis accelerometer
-#define HITACHI_DATA_LENGTH 15 // count of data bytes for Hitachi tri-axis accelerometer
-#define COMPASS_DATA_LENGTH 6 // count of data bytes for Compass
-#define SENSIRON_DATA_LENGTH 10 // count of data bytes for Sensiron temp/humidity sensor
-#define PING_DATA_LENGTH 8 // count of data bytes for Ping distance sensor
-#define FLEX_DATA_LENGTH 8 // count of data bytes for Flexiforce pressure sensor
-#define PIR_DATA_LENGTH 4 // count of data bytes for PIR
-#define QTI_DATA_LENGTH 7 // count of data bytes for QTI
-#define PIEZO_DATA_LENGTH 4 // count of data bytes for Piezo
-
-#define MEMSIC_AMOUNT_TO_READ (MEMSIC_DATA_LENGTH+INTERVAL_DATA_LENGTH) // total Memsic byte count
-#define HITACHI_AMOUNT_TO_READ (HITACHI_DATA_LENGTH+INTERVAL_DATA_LENGTH) // total Hitachi byte count
-#define COMPASS_AMOUNT_TO_READ (COMPASS_DATA_LENGTH+INTERVAL_DATA_LENGTH) // total Compass byte count
-#define SENSIRON_AMOUNT_TO_READ (SENSIRON_DATA_LENGTH+INTERVAL_DATA_LENGTH) // total Sensiron byte count
-#define PING_AMOUNT_TO_READ (PING_DATA_LENGTH+INTERVAL_DATA_LENGTH) // total Ping byte count
-#define FLEX_AMOUNT_TO_READ (FLEX_DATA_LENGTH+INTERVAL_DATA_LENGTH) // total Flexiforce byte count
-#define PIR_AMOUNT_TO_READ (PIR_DATA_LENGTH+INTERVAL_DATA_LENGTH) // total PIR byte count
-#define QTI_AMOUNT_TO_READ (QTI_DATA_LENGTH+INTERVAL_DATA_LENGTH) // total QTI byte count
-#define PIEZO_AMOUNT_TO_READ (PIEZO_DATA_LENGTH+INTERVAL_DATA_LENGTH) // total Piezo byte count
-
-#define DEVICE_ID 0 // byte 0 contains the Device ID
-#define ELEMENT_SIZE 1 // byte 1 contains the Element Size
-#define ELEMENT_COUNT 2 // byte 2 contains the Element Count
-
-// Update interval range in milliseconds
-#define SENSOR_UPDATE_INTERVAL_MIN 10 // milliseconds
-#define SENSOR_UPDATE_INTERVAL_MAX 60000 // milliseconds
-#define SENSOR_UPDATE_INTERVAL_STEP 1 // milliseconds
-
-// TODO: Change these range values to match your sensor hardware
-#define SENSOR_READING_MIN 1 // ?Units
-#define SENSOR_READING_MAX 378 // ?Units
-#define SENSOR_READING_STEP 1 // ?Units
-
-// TODO: Change this to match the default COM port to use
-#define COM_PORT_NAME L"COM1"
-#define NUM_READSTAT_HANDLES 4
-#define MAX_STATUS_LENGTH 100
-
-// Ascii definitions
-#define ASCII_BEL 0x07
-#define ASCII_BS 0x08
-#define ASCII_LF 0x0A
-#define ASCII_CR 0x0D
-#define ASCII_XON 0x11
-#define ASCII_XOFF 0x13
-
-// Miscellaneous definitions
-#define MAX_READ_BUFFER 2048
-#define MAX_WRITE_BUFFER 1024
-#define EVENTFLAGS_DEFAULT EV_BREAK | EV_CTS | EV_DSR | EV_ERR | EV_RING | EV_RLSD
-#define FLAGCHAR_DEFAULT '\n'
-
-// Read states
-#define RECEIVE_TTY 0x01
-#define RECEIVE_CAPTURED 0x02
-
-class RS232Connection
-{
-
-public:
- RS232Connection();
-
- ~RS232Connection()
- {
- Disconnect();
- }
-
- HRESULT Connect(_In_ LPCWSTR wszPortName, _Out_ HANDLE *phCommPort);
- void Disconnect();
-
-private:
- HRESULT SetPortState();
-
-private:
-
- //
- // Required for the RS232 initialization and communication.
- //
-
- // TTY member variables and defines
- HANDLE m_hCommPort;
- DWORD m_dwEventFlags;
- CHAR m_chFlag;
- CHAR m_chXON;
- CHAR m_chXOFF;
- WORD m_wXONLimit;
- WORD m_wXOFFLimit;
- DWORD m_fRtsControl;
- DWORD m_fDtrControl;
- BOOL m_fConnected;
- BOOL m_fTransferring;
- BOOL m_fRepeating;
- BOOL m_fLocalEcho;
- BOOL m_fNewLine;
- BOOL m_fDisplayErrors;
- BOOL m_fAutowrap;
- BOOL m_fCTSOutFlow;
- BOOL m_fDSROutFlow;
- BOOL m_fDSRInFlow;
- BOOL m_fXonXoffOutFlow;
- BOOL m_fXonXoffInFlow;
- BOOL m_fTXafterXoffSent;
- BOOL m_fNoReading;
- BOOL m_fNoWriting;
- BOOL m_fNoEvents;
- BOOL m_fNoStatus;
- BOOL m_fDisplayTimeouts;
- BYTE m_bPort;
- BYTE m_bByteSize;
- BYTE m_bParity;
- BYTE m_bStopBits;
- DWORD m_dwBaudRate;
- COMMTIMEOUTS m_timeoutsorig;
- COMMTIMEOUTS m_timeoutsnew;
- COMMTIMEOUTS m_TimeoutsDefault;
- DWORD m_dwReceiveState;
-}; \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/RS232Target.cpp b/wpd/WpdBasicHardwareDriver/RS232Target.cpp
deleted file mode 100644
index bedfecd2..00000000
--- a/wpd/WpdBasicHardwareDriver/RS232Target.cpp
+++ /dev/null
@@ -1,433 +0,0 @@
-#include "stdafx.h"
-
-#include "RS232Target.tmh"
-
-RS232Target::RS232Target() :
- m_cRef(1), m_pBaseDriver(NULL)
-{
-}
-
-RS232Target::~RS232Target()
-{
- Delete();
-}
-
-ULONG __stdcall RS232Target::AddRef()
-{
- InterlockedIncrement((long*) &m_cRef);
- return m_cRef;
-}
-
-ULONG __stdcall RS232Target::Release()
-{
- ULONG ulRefCount = m_cRef - 1;
-
- if (InterlockedDecrement((long*) &m_cRef) == 0)
- {
- delete this;
- return 0;
- }
- return ulRefCount;
-}
-
-HRESULT __stdcall RS232Target::QueryInterface(
- REFIID riid,
- void** ppv)
-{
- HRESULT hr = S_OK;
-
- if(riid == IID_IUnknown)
- {
- *ppv = static_cast<IUnknown*>(this);
- AddRef();
- }
- if(riid == __uuidof(IRequestCallbackRequestCompletion))
- {
- *ppv = static_cast<IRequestCallbackRequestCompletion*>(this);
- AddRef();
- }
- else
- {
- *ppv = NULL;
- hr = E_NOINTERFACE;
- }
- return hr;
-}
-
-
-
-/**
- * This method is called to initialize the RS232 I/O Target
- */
-HRESULT RS232Target::Create(_In_ WpdBaseDriver* pBaseDriver,
- _In_ IWDFDevice* pDevice,
- HANDLE hRS232Port)
-{
- CComPtr<IWDFFileHandleTargetFactory> pFileHandleTargetFactory;
-
- HRESULT hr = S_OK;
-
- if (pDevice == NULL)
- {
- hr = E_POINTER;
- CHECK_HR(hr, "NULL parameter received for IWDFDevice");
- return hr;
- }
-
- m_pWDFDevice = pDevice;
- m_pBaseDriver = pBaseDriver;
-
- hr = m_pWDFDevice->QueryInterface(IID_PPV_ARGS(&pFileHandleTargetFactory));
- CHECK_HR(hr, "QI of IID_IWDFFileHandleTargetFactory failed");
-
- if (hr == S_OK)
- {
- hr = pFileHandleTargetFactory->CreateFileHandleTarget(hRS232Port, &m_pFileTarget);
- CHECK_HR(hr, "Failed to create an I/O Target for the port file handle");
- }
-
- if (hr == S_OK)
- {
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DEVICE,
- "%!FUNC! Created win32 I/O target %p for handle %p", m_pFileTarget, hRS232Port);
- }
-
- return hr;
-}
-
-/**
- * This method is called to remove the RS232 I/O Target object
- * and do any cleanup
- */
-void RS232Target::Delete()
-{
- if (m_pFileTarget)
- {
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DEVICE,
- "%!FUNC! Deleted win32 I/O target %p", m_pFileTarget);
- m_pFileTarget = NULL;
- }
-
- if (m_pWDFDevice)
- {
- m_pWDFDevice = NULL;
- }
-
- if (m_pBaseDriver)
- {
- m_pBaseDriver = NULL;
- }
-}
-
-/**
- * This method is called to start the RS232 I/O Target after it
- * it has been created
- */
-HRESULT RS232Target::Start()
-{
- CComPtr<IWDFIoTargetStateManagement> pStateMgmt;
-
- HRESULT hr = S_OK;
-
- if (m_pFileTarget)
- {
- hr = m_pFileTarget->QueryInterface(IID_PPV_ARGS(&pStateMgmt));
- CHECK_HR(hr, "Failed to QI IWDFIoTargetStateManagement from the I/O target");
-
- if (hr == S_OK)
- {
- hr = pStateMgmt->Start();
- CHECK_HR(hr, "Failed to start the I/O target");
- }
-
- if (hr == S_OK && IsReady())
- {
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DEVICE, "%!FUNC! I/O target ready. Sending read request");
- hr = SendReadRequest();
- CHECK_HR(hr, "SendReadRequest failed");
- }
- }
- return hr;
-}
-
-/**
- * This method is called to stop the RS232 I/O Target
- * if it is currently running
- */
-HRESULT RS232Target::Stop()
-{
- CComPtr<IWDFIoTargetStateManagement> pStateMgmt;
-
- HRESULT hr = S_OK;
-
- // Stop the target only if it is started.
- if (m_pFileTarget && (WdfIoTargetStarted == GetState()))
- {
- hr = m_pFileTarget->QueryInterface(IID_PPV_ARGS(&pStateMgmt));
- CHECK_HR(hr, "Failed to QI IWDFIoTargetStateManagement from the I/O target");
-
- if (hr == S_OK)
- {
- // Stop the target, and cancel sent I/O
- hr = pStateMgmt->Stop(WdfIoTargetCancelSentIo);
- CHECK_HR(hr, "Failed to stop the I/O target");
- }
-
- if (hr == S_OK)
- {
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DEVICE, "%!FUNC! S_OK");
- }
- }
- return hr;
-}
-
-/**
- * This method is called to return the current state of the RS232 I/O Target
- */
-WDF_IO_TARGET_STATE RS232Target::GetState()
-{
- CComPtr<IWDFIoTargetStateManagement> pStateMgmt;
-
- WDF_IO_TARGET_STATE State = WdfIoTargetStateUndefined;
- HRESULT hr = S_OK;
-
- if (m_pFileTarget)
- {
- hr = m_pFileTarget->QueryInterface(IID_PPV_ARGS(&pStateMgmt));
- CHECK_HR(hr, "Failed to QI IWDFIoTargetStateManagement from the I/O target");
-
- if (hr == S_OK)
- {
- State = pStateMgmt->GetState();
- }
- }
- return State;
-}
-
-
-/**
- * This method returns TRUE is the target is ready to receive requests
- */
-BOOL RS232Target::IsReady()
-{
- if (WdfIoTargetStarted == GetState())
- {
- return TRUE;
- }
- return FALSE;
-}
-
-
-/**
- * This method is called to dispatch an asynchronous read request to the RS232 I/O Target
- * with a completion callback
- */
-HRESULT RS232Target::SendReadRequest()
-{
- CComPtr<IWDFDriver> pWdfDriver;
- CComPtr<IWDFFile> pWdfFile;
- CComPtr<IWDFMemory> pWdfBuffer;
- CComPtr<IWDFIoRequest> pWdfReadRequest;
- CComPtr<IRequestCallbackRequestCompletion> pCompletionCallback;
-
- HRESULT hr = S_OK;
-
- if (m_pWDFDevice == NULL || m_pFileTarget == NULL)
- {
- hr = HRESULT_FROM_WIN32(ERROR_NOT_READY);
- CHECK_HR(hr, "Device is not ready to receive read requests");
- return hr;
- }
-
- m_pWDFDevice->GetDriver(&pWdfDriver);
-
- ZeroMemory((void*)m_pReadBuffer, sizeof(m_pReadBuffer));
-
- // Create the WDF memory buffer
- hr = pWdfDriver->CreatePreallocatedWdfMemory(m_pReadBuffer,
- sizeof(m_pReadBuffer),
- NULL, // no object event callback
- NULL, // driver object as parent
- &pWdfBuffer);
- CHECK_HR(hr, "Failed to create the pre-allocaed WDF memory");
-
- if (hr == S_OK)
- {
- hr = m_pWDFDevice->CreateRequest(NULL, // no object event callback
- m_pWDFDevice, // device object as parent
- &pWdfReadRequest);
-
- CHECK_HR(hr, "Failed to create a WDF request");
- }
-
- if (hr == S_OK)
- {
- // Format the read request
- m_pFileTarget->GetTargetFile(&pWdfFile);
-
- hr = m_pFileTarget->FormatRequestForRead(pWdfReadRequest,
- pWdfFile,
- pWdfBuffer,
- NULL, // no memory offset
- NULL); // no device offset
-
- CHECK_HR(hr, "Failed to format the WDF request for read");
- }
-
- if (hr == S_OK)
- {
- this->QueryInterface(IID_PPV_ARGS(&pCompletionCallback));
-
- // Set the completion callback
- pWdfReadRequest->SetCompletionCallback(pCompletionCallback, NULL);
-
- hr = pWdfReadRequest->Send(m_pFileTarget, 0, 0);
- CHECK_HR(hr, "Failed to send the read request");
- }
-
- if (FAILED(hr))
- {
- // Cleanup on failure
- if (pWdfReadRequest)
- {
- pWdfReadRequest->DeleteWdfObject();
- }
- }
-
- return hr;
-}
-
-
-/**
- * This method is called to dispatch an asynchronous write request to the RS232 I/O Target
- * with a completion callback
- */
-HRESULT RS232Target::SendWriteRequest(
- _In_reads_(cbBufferSize) BYTE* pBuffer,
- size_t cbBufferSize)
-{
- CComPtr<IWDFDriver> pWdfDriver;
- CComPtr<IWDFFile> pWdfFile;
- CComPtr<IWDFMemory> pWdfBuffer;
- CComPtr<IWDFIoRequest> pWdfWriteRequest;
- CComPtr<IRequestCallbackRequestCompletion> pCompletionCallback;
-
- HRESULT hr = S_OK;
-
- if (pBuffer == NULL)
- {
- hr = E_POINTER;
- CHECK_HR(hr, "A NULL buffer parameter was received");
- return hr;
- }
-
- if (m_pWDFDevice == NULL || m_pFileTarget == NULL)
- {
- hr = HRESULT_FROM_WIN32(ERROR_NOT_READY);
- CHECK_HR(hr, "Device is not ready to receive write requests");
- }
-
- m_pWDFDevice->GetDriver(&pWdfDriver);
- m_pFileTarget->GetTargetFile(&pWdfFile);
-
- // Create the WDF memory buffer
- hr = pWdfDriver->CreatePreallocatedWdfMemory(pBuffer,
- cbBufferSize,
- NULL, // no object event callback
- NULL, // driver object as parent
- &pWdfBuffer);
- CHECK_HR(hr, "Failed to create a pre-allocaed Wdf memory buffer from the input buffer of size %d", static_cast<DWORD>(cbBufferSize));
-
- if (hr == S_OK)
- {
- hr = m_pWDFDevice->CreateRequest(NULL, // no object event callback
- m_pWDFDevice, // device object as parent
- &pWdfWriteRequest);
-
- CHECK_HR(hr, "Failed to create a WDF request");
- }
-
- if (hr == S_OK)
- {
- hr = m_pFileTarget->FormatRequestForWrite(pWdfWriteRequest,
- pWdfFile,
- pWdfBuffer,
- NULL, // no memory offset
- NULL); // no device offset
-
- CHECK_HR(hr, "Failed to format the WDF request for write");
- }
-
- if (hr == S_OK)
- {
- this->QueryInterface(IID_PPV_ARGS(&pCompletionCallback));
-
- // Set the completion callback
- pWdfWriteRequest->SetCompletionCallback(pCompletionCallback, NULL);
-
- hr = pWdfWriteRequest->Send(m_pFileTarget, 0, 0);
- CHECK_HR(hr, "Failed to send the write request");
- }
-
- if (FAILED(hr))
- {
- // Cleanup on failure
- if (pWdfWriteRequest)
- {
- pWdfWriteRequest->DeleteWdfObject();
- }
- }
-
- return hr;
-}
-
-
-/**
- * This callback method is called by UMDF on the completion of the asynchronous reads and writes
- */
-void RS232Target::OnCompletion(
- _In_ IWDFIoRequest* pWdfRequest,
- _In_ IWDFIoTarget* pIoTarget,
- _In_ IWDFRequestCompletionParams* pParams,
- _In_ PVOID pContext)
-{
- UNREFERENCED_PARAMETER(pIoTarget);
- UNREFERENCED_PARAMETER(pContext);
- UNREFERENCED_PARAMETER(pParams);
-
- CComPtr<IWDFRequestCompletionParams> pCompletionParams;
- HRESULT hr = S_OK;
-
- // Get the request completion status
- pWdfRequest->GetCompletionParams(&pCompletionParams);
-
- HRESULT hrStatus = pCompletionParams->GetCompletionStatus();
- WDF_REQUEST_TYPE RequestType = pCompletionParams->GetCompletedRequestType();
-
- if (RequestType == WdfRequestRead)
- {
- TraceEvents(TRACE_LEVEL_VERBOSE, TRACE_FLAG_DEVICE, "%!FUNC! Read Status %!HRESULT!", hrStatus);
-
- // Retrieve the data from the completed read request if successful
- if (SUCCEEDED(hrStatus) && m_pBaseDriver)
- {
- m_pBaseDriver->ProcessReadData(m_pReadBuffer, sizeof(m_pReadBuffer));
- }
-
- // Send another read request if the target is not stopped or removed
- if (IsReady())
- {
- hr = SendReadRequest();
- CHECK_HR(hr, "SendReadRequest failed");
- }
-
-
- }
- else if (RequestType == WdfRequestWrite)
- {
- TraceEvents(TRACE_LEVEL_VERBOSE, TRACE_FLAG_DEVICE, "%!FUNC! Write Status %!HRESULT!", hrStatus);
- }
-
- // Clean up the existing request
- pWdfRequest->DeleteWdfObject();
-}
diff --git a/wpd/WpdBasicHardwareDriver/RS232Target.h b/wpd/WpdBasicHardwareDriver/RS232Target.h
deleted file mode 100644
index b4754639..00000000
--- a/wpd/WpdBasicHardwareDriver/RS232Target.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#pragma once
-
-class RS232Target :
- public IRequestCallbackRequestCompletion
-{
-public:
- RS232Target();
-
- ~RS232Target();
-
- HRESULT Create(_In_ WpdBaseDriver* pBaseDriver,
- _In_ IWDFDevice* pDevice,
- HANDLE hRS232Port);
-
- void Delete();
-
- HRESULT Start();
-
- HRESULT Stop();
-
- BOOL IsReady();
-
- WDF_IO_TARGET_STATE GetState();
-
- HRESULT SendReadRequest();
-
- HRESULT SendWriteRequest(_In_reads_(cbBufferSize) BYTE* pBuffer,
- size_t cbBufferSize);
-
-public: // IUnknown
- ULONG __stdcall AddRef();
- ULONG __stdcall Release();
- HRESULT __stdcall QueryInterface(REFIID riid, void** ppv);
-
- //
- // IRequestCallbackRequestCompletion
- //
- STDMETHOD_ (void, OnCompletion)(_In_ IWDFIoRequest* pWdfRequest,
- _In_ IWDFIoTarget* pIoTarget,
- _In_ IWDFRequestCompletionParams* pParams,
- _In_ PVOID pContext);
-
-private:
- ULONG m_cRef;
-
- WpdBaseDriver* m_pBaseDriver;
-
- // Ensure ample buffer size
- BYTE m_pReadBuffer[MAX_AMOUNT_TO_READ*2];
-
- CComPtr<IWDFDevice> m_pWDFDevice;
- CComPtr<IWDFIoTarget> m_pFileTarget;
-}; \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/Stdafxsrc.cpp b/wpd/WpdBasicHardwareDriver/Stdafxsrc.cpp
deleted file mode 100644
index 5105a28d..00000000
--- a/wpd/WpdBasicHardwareDriver/Stdafxsrc.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "Stdafx.h" \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/WpdBaseDriver.cpp b/wpd/WpdBasicHardwareDriver/WpdBaseDriver.cpp
deleted file mode 100644
index cf1665c2..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBaseDriver.cpp
+++ /dev/null
@@ -1,506 +0,0 @@
-#include "stdafx.h"
-
-#include "WpdBaseDriver.tmh"
-
-
-WpdBaseDriver::WpdBaseDriver() :
- m_cRef(1)
-{
-}
-
-WpdBaseDriver::~WpdBaseDriver()
-{
-}
-
-ULONG __stdcall WpdBaseDriver::AddRef()
-{
- InterlockedIncrement((long*) &m_cRef);
- return m_cRef;
-}
-
-_At_(this, __drv_freesMem(Mem))
-ULONG __stdcall WpdBaseDriver::Release()
-{
- ULONG ulRefCount = m_cRef - 1;
-
- if (InterlockedDecrement((long*) &m_cRef) == 0)
- {
- delete this;
- return 0;
- }
- return ulRefCount;
-}
-
-HRESULT __stdcall WpdBaseDriver::QueryInterface(
- REFIID riid,
- void** ppv)
-{
- HRESULT hr = S_OK;
-
- if(riid == IID_IUnknown)
- {
- *ppv = static_cast<IUnknown*>(this);
- AddRef();
- }
- else
- {
- *ppv = NULL;
- hr = E_NOINTERFACE;
- }
- return hr;
-}
-
-RS232Target* WpdBaseDriver::GetRS232Target()
-{
- return &m_Target;
-}
-
-HRESULT WpdBaseDriver::DispatchWpdMessage(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- GUID guidCommandCategory = {0};
- DWORD dwCommandID = 0;
- PROPERTYKEY CommandKey = WPD_PROPERTY_NULL;
-
- if (hr == S_OK)
- {
- hr = pParams->GetGuidValue(WPD_PROPERTY_COMMON_COMMAND_CATEGORY, &guidCommandCategory);
- CHECK_HR(hr, "Failed to get WPD_PROPERTY_COMMON_COMMAND_CATEGORY from input parameters");
- }
-
- if (hr == S_OK)
- {
- hr = pParams->GetUnsignedIntegerValue(WPD_PROPERTY_COMMON_COMMAND_ID, &dwCommandID);
- CHECK_HR(hr, "Failed to get WPD_PROPERTY_COMMON_COMMAND_ID from input parameters");
- }
-
- // If WPD_PROPERTY_COMMON_COMMAND_CATEGORY or WPD_PROPERTY_COMMON_COMMAND_ID could not be extracted
- // properly then we should return E_INVALIDARG to the client.
- if (FAILED(hr))
- {
- hr = E_INVALIDARG;
- CHECK_HR(hr, "Failed to get WPD_PROPERTY_COMMON_COMMAND_CATEGORY or WPD_PROPERTY_COMMON_COMMAND_ID from input parameters");
- }
-
- if (hr == S_OK)
- {
- CommandKey.fmtid = guidCommandCategory;
- CommandKey.pid = dwCommandID;
-
- if (CommandKey.fmtid == WPD_CATEGORY_OBJECT_ENUMERATION)
- {
- hr = m_ObjectEnum.DispatchWpdMessage(CommandKey, pParams, pResults);
- }
- else if (CommandKey.fmtid == WPD_CATEGORY_OBJECT_PROPERTIES)
- {
- hr = m_ObjectProperties.DispatchWpdMessage(CommandKey, pParams, pResults);
- }
- else if (CommandKey.fmtid == WPD_CATEGORY_CAPABILITIES)
- {
- hr = m_Capabilities.DispatchWpdMessage(CommandKey, pParams, pResults);
- }
- else if (IsEqualPropertyKey(CommandKey, WPD_COMMAND_COMMON_GET_OBJECT_IDS_FROM_PERSISTENT_UNIQUE_IDS))
- {
- hr = OnGetObjectIDsFromPersistentUniqueIDs(pParams, pResults);
- }
- else
- {
- hr = E_NOTIMPL;
- CHECK_HR(hr, "Unknown command %ws.%d received",CComBSTR(CommandKey.fmtid), CommandKey.pid);
- }
- }
-
- HRESULT hrTemp = pResults->SetErrorValue(WPD_PROPERTY_COMMON_HRESULT, hr);
- CHECK_HR(hrTemp, ("Failed to set WPD_PROPERTY_COMMON_HRESULT"));
-
- // Set to a success code, to indicate that the message was received.
- // the return code for the actual command's results is stored in the
- // WPD_PROPERTY_COMMON_HRESULT property.
- hr = S_OK;
-
- return hr;
-}
-
-/**
- * This method is called to initialize the driver object.
- * This is where the driver establishes a connection with the
- * COM port, creates the IoTarget to forward read/write requests to, and
- * starts the thread which monitors these events.
- */
-HRESULT WpdBaseDriver::Initialize(_In_ IWDFDevice* pDevice)
-{
- HRESULT hr = S_OK;
- HANDLE hPort = NULL;
-
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DRIVER, "%!FUNC! Entry");
-
- if (pDevice == NULL)
- {
- hr = E_POINTER;
- CHECK_HR(hr, "A NULL IWDFDevice parameter was received.");
- return hr;
- }
-
- // Save the WDF device instance
- m_pWDFDevice = pDevice;
- m_ObjectProperties.Initialize(this);
- m_ObjectEnum.Initialize(this);
-
- // Initialize the Wpd Serializer for posting events
- hr = CoCreateInstance(CLSID_WpdSerializer,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IWpdSerializer,
- (VOID**)&m_pWpdSerializer);
-
- CHECK_HR(hr, "Failed to CoCreate the Wpd Serializer.");
-
-
- // Initialize a handle to the RS232 connection
- hr = m_Connection.Connect(COM_PORT_NAME, &hPort);
- CHECK_HR(hr, "Failed to connect to port: %ws", COM_PORT_NAME);
-
- // Initialize the IoTarget to wrap the opened handle
- if (hr == S_OK)
- {
- hr = m_Target.Create(this, pDevice, hPort);
- CHECK_HR(hr, "Failed to create the port I/O target.");
- }
-
- return hr;
-}
-
-/**
- * This method is called to uninitialize the driver object.
- * This is where the driver disables the connection with the
- * COM port and performs the necessary cleanup.
- */
-void WpdBaseDriver::Uninitialize()
-{
- TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_DRIVER, "%!FUNC! Entry");
-
- m_Target.Delete();
- m_Connection.Disconnect();
-
- m_pWDFDevice = NULL;
-}
-
-/**
- * This method is called to extract the sensor data and interval prop from the raw serial buffer
- * and to post a new reading PnP event if valid data is received
- */
-HRESULT WpdBaseDriver::ProcessReadData(_In_reads_(cbData) BYTE* pData, size_t cbData)
-{
- HRESULT hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
- LONGLONG llSensorReading = 0; // was originally DWORD but the accelerometers required addt'l bytes
- DWORD dwUpdateInterval = 0;
-
- // Parse the serial data
- CHAR szInterval[INTERVAL_DATA_LENGTH + 1] = {0}; // last byte is always null
- CHAR* szReading = NULL; // buffer containing the reading
-
- const SENSOR_INFO c_SensorInfoTable [] = {
- {'1', COMPASS_DATA_LENGTH}, // Compass
- {'2', SENSIRON_DATA_LENGTH}, // Temp/humidity sensor
- {'3', FLEX_DATA_LENGTH}, // Flexiforce sensor
- {'4', PING_DATA_LENGTH}, // Ultrasonic ping
- {'5', PIR_DATA_LENGTH}, // Passive infrared
- {'6', MEMSIC_DATA_LENGTH}, // 2-axis accelerometer
- {'7', QTI_DATA_LENGTH}, // Light sensor
- {'8', PIEZO_DATA_LENGTH}, // Vibration Sensor
- {'9', HITACHI_DATA_LENGTH}, // 3-axis accelerometer
- };
-
- // Allocate the necessary bytes for collecting the sensor data.
- // We'll examine the DEVICE_ID field of the batched serial data and allocate
- // the necessary bytes accordingly...
- // This is also where we set the sensor identifier and related properties).
-
- if (cbData > DEVICE_ID)
- {
- switch (pData[DEVICE_ID]){
- case '1':
- m_SensorType = COMPASS;
- szReading = (CHAR *)malloc(COMPASS_DATA_LENGTH + 1); // last byte is always null
- hr = S_OK;
- break;
- case '2':
- m_SensorType = SENSIRON;
- szReading = (CHAR *)malloc(SENSIRON_DATA_LENGTH + 1); // last byte is always null
- hr = S_OK;
- break;
- case '3':
- m_SensorType = FLEX;
- szReading = (CHAR *)malloc(FLEX_DATA_LENGTH + 1); // last byte is always null
- hr = S_OK;
- break;
- case '4':
- m_SensorType = PING;
- szReading = (CHAR *)malloc(PING_DATA_LENGTH + 1); // last byte is always null
- hr = S_OK;
- break;
- case '5':
- m_SensorType = PIR;
- szReading = (CHAR *)malloc(PIR_DATA_LENGTH + 1); // last byte is always null
- hr = S_OK;
- break;
- case '6':
- m_SensorType = MEMSIC;
- szReading = (CHAR *)malloc(MEMSIC_AMOUNT_TO_READ + 1); // last byte is always null
- hr = S_OK;
- break;
- case '7':
- m_SensorType = QTI;
- szReading = (CHAR *)malloc(QTI_DATA_LENGTH + 1); // last byte is always null
- hr = S_OK;
- break;
- case '8':
- m_SensorType = PIEZO;
- szReading = (CHAR *)malloc(PIEZO_DATA_LENGTH + 1); // last byte is always null
- hr = S_OK;
- break;
- case '9':
- m_SensorType = HITACHI;
- szReading = (CHAR *)malloc(HITACHI_DATA_LENGTH + 1); // last byte is always null
- hr = S_OK;
- break;
- default:
- break;
- }
- }
-
- if ((hr == S_OK) && (szReading == NULL))
- {
- hr = E_OUTOFMEMORY;
- }
-
- // Ensure we have sufficient input buffer size, and, if we do
- // process the data for the given sensor.
- if (hr == S_OK && (cbData >= (INTERVAL_DATA_LENGTH + MIN_DATA_LENGTH)))
- {
- for (int i=0; i<ARRAYSIZE(c_SensorInfoTable); i++)
- {
- if (pData[DEVICE_ID] == c_SensorInfoTable[i].deviceID)
- {
- memcpy((void*)szReading, (void*)pData, c_SensorInfoTable[i].dataLength);
- szReading[c_SensorInfoTable[i].dataLength] = '\0'; // ensure null termination
- llSensorReading = _atoi64(szReading);
- hr = (errno == ERANGE) ? HRESULT_FROM_WIN32(ERROR_INVALID_DATA) : S_OK;
- if (hr == S_OK)
- {
- // Process the Interval data
- memcpy((void*)szInterval, (void*)(pData+c_SensorInfoTable[i].dataLength), INTERVAL_DATA_LENGTH);
- szInterval[INTERVAL_DATA_LENGTH] = '\0'; // ensure null termination
- dwUpdateInterval = atoi(szInterval);
- hr = (errno == ERANGE) ? HRESULT_FROM_WIN32(ERROR_INVALID_DATA) : S_OK;
- }
- break;
- }
- }
- }
-
- if (hr == S_OK)
- {
- // Post the Updated PnP event so applications receive the notification
- hr = PostSensorReadingEvent(llSensorReading, dwUpdateInterval);
- CHECK_HR(hr, "Failed to post a sensor reading event");
-
- // If the cached interval has not yet been initialized, set to the value returned from the device
- if (m_ObjectProperties.GetUpdateInterval() == 0)
- {
- m_ObjectProperties.SetUpdateInterval(dwUpdateInterval);
- }
-
- // Update the sensor reading property for the sensor functional object
- m_ObjectProperties.SetSensorReading(llSensorReading);
- }
-
- if (szReading)
- {
- // Free the bytes allocated with malloc()
- free(szReading);
- }
-
- return hr;
-}
-
-/**
- * This method is called to send a device event with
- * the new sensor data
- */
-HRESULT WpdBaseDriver::PostSensorReadingEvent(
- LONGLONG llSensorData,
- DWORD dwUpdateInterval)
-{
- HRESULT hr = S_OK;
- BYTE* pBuffer = NULL;
- DWORD cbBuffer = 0;
-
- CComPtr<IPortableDeviceValues> pEventParams;
-
- TraceEvents(TRACE_LEVEL_VERBOSE, TRACE_FLAG_DRIVER, "%!FUNC! Reading: %I64d, Interval: %d", llSensorData, dwUpdateInterval);
-
- // Create the event parameters collection if it doesn't exist
- if (m_pEventParams == NULL)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**)&m_pEventParams);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
- }
-
- if (hr == S_OK)
- {
- // Initialize the event parameters
- m_pEventParams->Clear();
-
- // Populate the event parameters
- hr = m_pEventParams->SetGuidValue(WPD_EVENT_PARAMETER_EVENT_ID, EVENT_SENSOR_READING_UPDATED);
- CHECK_HR(hr, "Failed to set the WPD_EVENT_PARAMETER_EVENT_ID");
- }
-
- if (hr == S_OK)
- {
- //hr = m_pEventParams->SetUnsignedIntegerValue(SENSOR_READING, dwTemperatureData);
- hr = m_pEventParams->SetUnsignedLargeIntegerValue(SENSOR_READING, llSensorData);
- CHECK_HR(hr, "Failed to set the sensor reading");
- }
-
- if (hr == S_OK)
- {
- hr = m_pEventParams->SetUnsignedIntegerValue(SENSOR_UPDATE_INTERVAL, dwUpdateInterval);
- CHECK_HR(hr, "Failed to set the sensor update interval");
- }
-
- if (hr == S_OK)
- {
- // Create a buffer with the serialized parameters
- hr = m_pWpdSerializer->GetBufferFromIPortableDeviceValues(m_pEventParams, &pBuffer, &cbBuffer);
- CHECK_HR(hr, "Failed to get buffer from IPortableDeviceValues");
- }
-
- // Send the event
- if (hr == S_OK && pBuffer != NULL)
- {
- hr = m_pWDFDevice->PostEvent(WPD_EVENT_NOTIFICATION, WdfEventBroadcast, pBuffer, cbBuffer);
- CHECK_HR(hr, "Failed to post the WPD broadcast event");
- }
-
- // Free the memory
- CoTaskMemFree(pBuffer);
- pBuffer = NULL;
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_COMMON_GET_OBJECT_IDS_FROM_PERSISTENT_UNIQUE_IDS
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_COMMON_PERSISTENT_UNIQUE_IDS: Contains an IPortableDevicePropVariantCollection of VT_LPWSTR,
- * indicating the PersistentUniqueIDs.
- *
- * The driver should:
- * - Iterate through the PersistentUniqueIDs, and convert to a currently valid object id.
- * This object ID list should be returned as an IPortableDevicePropVariantCollection of VT_LPWSTR
- * in WPD_PROPERTY_COMMON_OBJECT_IDS.
- * Order is implicit, i.e. the first element in the Persistent Unique ID list corresponds to the
- * to the first element of the ObjectID list and so on.
- *
- * For those elements where an existing ObjectID could not be found (e.g. the
- * object is no longer present on the device), the element will contain the
- * empty string (L"").
- */
-HRESULT WpdBaseDriver::OnGetObjectIDsFromPersistentUniqueIDs(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
-
- HRESULT hr = S_OK;
- DWORD dwCount = 0;
- CComPtr<IPortableDevicePropVariantCollection> pPersistentIDs;
- CComPtr<IPortableDevicePropVariantCollection> pObjectIDs;
-
- if((pParams == NULL) ||
- (pResults == NULL))
- {
- hr = E_POINTER;
- CHECK_HR(hr, "Cannot have NULL parameter");
- return hr;
- }
-
- // Get the list of Persistent IDs
- if (hr == S_OK)
- {
- hr = pParams->GetIPortableDevicePropVariantCollectionValue(WPD_PROPERTY_COMMON_PERSISTENT_UNIQUE_IDS, &pPersistentIDs);
- CHECK_HR(hr, "Failed to get WPD_PROPERTY_COMMON_PERSISTENT_UNIQUE_IDS");
- }
-
- // Create the collection to hold the ObjectIDs
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDevicePropVariantCollection,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDevicePropVariantCollection,
- (VOID**) &pObjectIDs);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDevicePropVariantCollection");
- }
-
- // Iterate through the persistent ID list and add the equivalent object ID for each element.
- if (hr == S_OK)
- {
- hr = pPersistentIDs->GetCount(&dwCount);
- CHECK_HR(hr, "Failed to get count from persistent ID collection");
-
- if (hr == S_OK)
- {
- DWORD dwIndex = 0;
- PROPVARIANT pvPersistentID = {0};
- PROPVARIANT pvObjectID = {0};
-
- PropVariantInit(&pvPersistentID);
- PropVariantInit(&pvObjectID);
-
- for(dwIndex = 0; dwIndex < dwCount; dwIndex++)
- {
- pvObjectID.vt = VT_LPWSTR;
- hr = pPersistentIDs->GetAt(dwIndex, &pvPersistentID);
- CHECK_HR(hr, "Failed to get persistent ID at index %d", dwIndex);
-
- // Since our persistent unique identifier are identical to our object
- // identifiers, we just return it back to the caller.
- if (hr == S_OK)
- {
- pvObjectID.pwszVal = AtlAllocTaskWideString(pvPersistentID.pwszVal);
- }
-
- if (hr == S_OK)
- {
- hr = pObjectIDs->Add(&pvObjectID);
- CHECK_HR(hr, "Failed to add next Object ID");
- }
-
- PropVariantClear(&pvPersistentID);
- PropVariantClear(&pvObjectID);
-
- if(FAILED(hr))
- {
- break;
- }
- }
- }
- }
-
- if (hr == S_OK)
- {
- hr = pResults->SetIPortableDevicePropVariantCollectionValue(WPD_PROPERTY_COMMON_OBJECT_IDS, pObjectIDs);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_COMMON_OBJECT_IDS");
- }
-
- return hr;
-}
diff --git a/wpd/WpdBasicHardwareDriver/WpdBaseDriver.h b/wpd/WpdBasicHardwareDriver/WpdBaseDriver.h
deleted file mode 100644
index 13dd4694..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBaseDriver.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#pragma once
-
-typedef struct tagSENSOR_INFO{
- unsigned char deviceID;
- unsigned short dataLength;
-} SENSOR_INFO;
-
-class WpdBaseDriver :
- public IUnknown
-{
-public:
- WpdBaseDriver();
- virtual ~WpdBaseDriver();
-
- HRESULT Initialize(_In_ IWDFDevice *pDevice);
- void Uninitialize();
-
- HRESULT DispatchWpdMessage(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT ProcessReadData(_In_reads_(cbData) BYTE* pData, size_t cbData);
-
- RS232Target* GetRS232Target();
-
-public: // IUnknown
- ULONG __stdcall AddRef();
-
- _At_(this, __drv_freesMem(Mem))
- ULONG __stdcall Release();
-
- HRESULT __stdcall QueryInterface(REFIID riid, void** ppv);
-
-private:
- HRESULT OnGetObjectIDsFromPersistentUniqueIDs(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT PostSensorReadingEvent(LONGLONG llSensorData, DWORD dwUpdateInterval);
-
-public:
-
- enum SensorType{
- UNKNOWN, // Unknown
- COMPASS, // Compass
- SENSIRON, // Temp/humidity sensor
- FLEX, // Flexiforce sensor
- PING, // Ultrasonic ping
- PIR, // Passive infrared
- MEMSIC, // 2-axis accelerometer
- QTI, // Light sensor
- PIEZO, // Vibration Sensor
- HITACHI, // 3-axis accelerometer
- };
-
- SensorType m_SensorType; // enum value specifying sensor type
-
-private:
- WpdObjectEnumerator m_ObjectEnum;
- WpdObjectProperties m_ObjectProperties;
- WpdCapabilities m_Capabilities;
-
- ULONG m_cRef;
- RS232Connection m_Connection;
- RS232Target m_Target;
-
- CComPtr<IWDFDevice> m_pWDFDevice;
- CComPtr<IWpdSerializer> m_pWpdSerializer;
- CComPtr<IPortableDeviceValues> m_pEventParams;
-};
-
diff --git a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.cpp b/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.cpp
deleted file mode 100644
index 2620e909..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "stdafx.h"
-
-#include "WpdBasicHardwareDriver.tmh"
-
-HINSTANCE g_hInstance = NULL;
-
-class CWpdBasicHardwareDriverModule : public CAtlDllModuleT< CWpdBasicHardwareDriverModule >
-{
-public :
- DECLARE_REGISTRY_APPID_RESOURCEID(IDR_WpdBasicHardwareDriver, "{021AD204-6411-4698-8CFB-C1A72B581733}")
- DECLARE_LIBID(LIBID_WpdBasicHardwareDriverLib)
-};
-
-CWpdBasicHardwareDriverModule _AtlModule;
-
-// DLL Entry Point
-extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
-{
- if(dwReason == DLL_PROCESS_ATTACH)
- {
- g_hInstance = hInstance;
-
- // Initialize tracing.
- WPP_INIT_TRACING(MYDRIVER_TRACING_ID);
- }
- else if (dwReason == DLL_PROCESS_DETACH)
- {
- // Cleanup tracing.
- WPP_CLEANUP();
- }
-
- return _AtlModule.DllMain(dwReason, lpReserved);
-}
-
-// Used to determine whether the DLL can be unloaded by OLE
-STDAPI DllCanUnloadNow(void)
-{
- return _AtlModule.DllCanUnloadNow();
-}
-
-// Returns a class factory to create an object of the requested type
-STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv)
-{
- return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
-}
-
-// DllRegisterServer - Adds entries to the system registry
-STDAPI DllRegisterServer(void)
-{
- // registers object, typelib and all interfaces in typelib
- HRESULT hr = _AtlModule.DllRegisterServer();
- return hr;
-}
-
-// DllUnregisterServer - Removes entries from the system registry
-STDAPI DllUnregisterServer(void)
-{
- HRESULT hr = _AtlModule.DllUnregisterServer();
- return hr;
-}
diff --git a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.def b/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.def
deleted file mode 100644
index 4af498d9..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.def
+++ /dev/null
@@ -1,9 +0,0 @@
-; WpdBasicHardwareDriver.def : Declares the module parameters.
-
-LIBRARY "WpdBasicHardwareDriver.DLL"
-
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.idl b/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.idl
deleted file mode 100644
index 73ff16af..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.idl
+++ /dev/null
@@ -1,24 +0,0 @@
-
-import "oaidl.idl";
-import "ocidl.idl";
-
-import "wudfddi.idl";
-
-[
- uuid(69A9B934-73F0-45AF-B3C5-1D5BC7BC982B),
- version(1.0),
- helpstring("Windows Portable Device Basic Hardware Driver Type Library")
-]
-library WpdBasicHardwareDriverLib
-{
- importlib("stdole2.tlb");
- [
- uuid(EC7445EE-BC00-4CED-AFE7-A52849F10239),
- helpstring("WpdBasicHardwareDriver Class")
- ]
- coclass WpdBasicHardwareDriver
- {
- [default] interface IDriverEntry;
- };
-};
-
diff --git a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.inx b/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.inx
deleted file mode 100644
index 493a1964..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.inx
+++ /dev/null
@@ -1,81 +0,0 @@
-;
-; WpdBasicHardwareDriver.inf
-;
-
-[Version]
-Signature="$Windows NT$"
-Class=WPD
-ClassGuid={EEC5AD98-8080-425f-922A-DABF3DE3F69A}
-Provider=%Provider%
-CatalogFile=WpdBasicHardwareDriver.cat
-DriverVer=01/24/2007,1.1.1.1
-
-[Manufacturer]
-%Mfg%=Standard,NT$ARCH$
-
-[Standard.NT$ARCH$]
-%BasicDeviceName%=Basic_Install,WUDF\WpdBasicHardware
-
-[SourceDisksFiles]
-WudfUpdate_$UMDFCOINSTALLERVERSION$.dll=1
-WpdBasicHardwareDriver.dll=1
-
-[SourceDisksNames]
-1 = %MediaDescription%
-
-; =================== WPD Sample Device ==================================
-
-[Basic_Install]
-CopyFiles=System32Copy
-
-[Basic_Install.hw]
-AddReg=Device_AddReg
-
-[Basic_Install.Services]
-AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall
-
-[Basic_Install.CoInstallers]
-AddReg=Basic_Install.CoInstallers_AddReg
-CopyFiles=CoInstallers_CopyFiles
-
-[CoInstallers_CopyFiles]
-WudfUpdate_$UMDFCOINSTALLERVERSION$.dll
-
-[Basic_Install.CoInstallers_AddReg]
-HKR,,CoInstallers32,0x00010000,"WudfUpdate_$UMDFCOINSTALLERVERSION$.dll"
-
-[Basic_Install.Wdf]
-UmdfService=WpdBasicHardwareDriver, WpdBasicHardwareDriver_Install
-UmdfServiceOrder=WpdBasicHardwareDriver
-; Enable file-handle-based I/O targets
-UmdfDispatcher = FileHandle
-
-[WpdBasicHardwareDriver_Install]
-UmdfLibraryVersion=$UMDFVERSION$
-DriverCLSID="{EC7445EE-BC00-4CED-AFE7-A52849F10239}"
-ServiceBinary=%12%\UMDF\WpdBasicHardwareDriver.dll
-
-[Device_AddReg]
-; HKR,,"EnableLegacySupport",0x10001,0
-
-[WUDFRD_ServiceInstall]
-ServiceType=1
-StartType=3
-ErrorControl=1
-ServiceBinary=%12%\WUDFRd.sys
-
-[DestinationDirs]
-System32Copy=12,UMDF ; copy to system32\drivers\umdf
-CoInstallers_CopyFiles=11
-
-[System32Copy]
-WpdBasicHardwareDriver.dll
-
-
-; =================== Generic ==================================
-
-[Strings]
-Mfg="Windows Portable Devices"
-Provider="TODO-Set-Provider"
-MediaDescription="WPD Basic Hardware Driver Installation Media"
-BasicDeviceName="WPD Basic Hardware Driver"
diff --git a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.rc b/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.rc
deleted file mode 100644
index f743120a..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.rc
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "resource.h"
-#include <windows.h>
-#include <ntverp.h>
-
-#define VER_FILETYPE VFT_DLL
-#define VER_FILESUBTYPE VFT2_UNKNOWN
-#define VER_FILEDESCRIPTION_STR "Windows Portable Device Basic Hardware Driver"
-#define VER_INTERNALNAME_STR "WpdBasicHardwareDriver.dll"
-
-#include <common.ver>
-
-1 TYPELIB "WpdBasicHardwareDriver.tlb"
-
-IDR_WpdTempSensorDriver REGISTRY "WpdBasicHardwareDriver.rgs"
-
diff --git a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.rgs b/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.rgs
deleted file mode 100644
index 6b4ae538..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.rgs
+++ /dev/null
@@ -1,26 +0,0 @@
-HKCR
-{
- WpdBasicHardwareDriver.WpdBasicHardwareDriver.1 = s 'WpdBasicHardwareDriver Class'
- {
- CLSID = s '{FB2CC0AD-6723-45D2-9EC6-7B603F9BCD17}'
- }
- WpdBasicHardwareDriver.WpdBasicHardwareDriver = s 'WpdBasicHardwareDriver Class'
- {
- CLSID = s '{FB2CC0AD-6723-45D2-9EC6-7B603F9BCD17}'
- CurVer = s 'WpdBasicHardwareDriver.WpdBasicHardwareDriver.1'
- }
- NoRemove CLSID
- {
- ForceRemove {FB2CC0AD-6723-45D2-9EC6-7B603F9BCD17} = s 'WpdBasicHardwareDriver Class'
- {
- ProgID = s 'WpdBasicHardwareDriver.WpdBasicHardwareDriver.1'
- VersionIndependentProgID = s 'WpdBasicHardwareDriver.WpdBasicHardwareDriver.1'
- InprocServer32 = s '%MODULE%'
- {
- val ThreadingModel = s 'Free'
- }
- 'TypeLib' = s '{20E7797C-2981-49EE-8A78-85A11440785C}'
- }
- }
-}
-
diff --git a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.sln b/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.sln
deleted file mode 100644
index df39a1bb..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.sln
+++ /dev/null
@@ -1,28 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0
-MinimumVisualStudioVersion = 12.0
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WpdBasicHardwareDriver", "WpdBasicHardwareDriver.vcxproj", "{7A722DFC-8A5B-42CB-BC5D-BD6A66446260}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- Debug|x64 = Debug|x64
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {7A722DFC-8A5B-42CB-BC5D-BD6A66446260}.Debug|Win32.ActiveCfg = Debug|Win32
- {7A722DFC-8A5B-42CB-BC5D-BD6A66446260}.Debug|Win32.Build.0 = Debug|Win32
- {7A722DFC-8A5B-42CB-BC5D-BD6A66446260}.Release|Win32.ActiveCfg = Release|Win32
- {7A722DFC-8A5B-42CB-BC5D-BD6A66446260}.Release|Win32.Build.0 = Release|Win32
- {7A722DFC-8A5B-42CB-BC5D-BD6A66446260}.Debug|x64.ActiveCfg = Debug|x64
- {7A722DFC-8A5B-42CB-BC5D-BD6A66446260}.Debug|x64.Build.0 = Debug|x64
- {7A722DFC-8A5B-42CB-BC5D-BD6A66446260}.Release|x64.ActiveCfg = Release|x64
- {7A722DFC-8A5B-42CB-BC5D-BD6A66446260}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.vcxproj b/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.vcxproj
deleted file mode 100644
index e7c78060..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.vcxproj
+++ /dev/null
@@ -1,352 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{7A722DFC-8A5B-42CB-BC5D-BD6A66446260}</ProjectGuid>
- <RootNamespace>$(MSBuildProjectName)</RootNamespace>
- <UMDF_VERSION_MAJOR>1</UMDF_VERSION_MAJOR>
- <KMDF_VERSION_MAJOR>1</KMDF_VERSION_MAJOR>
- <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
- <Platform Condition="'$(Platform)' == ''">Win32</Platform>
- <SampleGuid>{67BF652A-585A-43F0-BAB1-C84527A6B802}</SampleGuid>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <TargetVersion>Windows10</TargetVersion>
- <UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Desktop</DriverTargetPlatform>
- <DriverType>UMDF</DriverType>
- <PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- </PropertyGroup>
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <TargetVersion>Windows10</TargetVersion>
- <UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Desktop</DriverTargetPlatform>
- <DriverType>UMDF</DriverType>
- <PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- </PropertyGroup>
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <TargetVersion>Windows10</TargetVersion>
- <UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Desktop</DriverTargetPlatform>
- <DriverType>UMDF</DriverType>
- <PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- </PropertyGroup>
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <TargetVersion>Windows10</TargetVersion>
- <UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Desktop</DriverTargetPlatform>
- <DriverType>UMDF</DriverType>
- <PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <PropertyGroup>
- <OutDir>$(IntDir)</OutDir>
- </PropertyGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
- </ImportGroup>
- <ItemGroup Label="WrappedTaskItems">
- <ClCompile Include="WpdBasicHardwareDriver.cpp">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Use</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <ClCompile Include="Driver.cpp">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Use</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <ClCompile Include="Device.cpp">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Use</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <ClCompile Include="Queue.cpp">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Use</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <ClCompile Include="RS232Connection.cpp">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Use</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <ClCompile Include="RS232Target.cpp">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Use</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <ClCompile Include="WpdBaseDriver.cpp">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Use</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <ClCompile Include="WpdObjectEnum.cpp">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Use</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <ClCompile Include="WpdObjectProperties.cpp">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Use</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <ClCompile Include="WpdCapabilities.cpp">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Use</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <Inf Include="WpdBasicHardwareDriver.inx">
- <Architecture>$(InfArch)</Architecture>
- <SpecifyArchitecture>true</SpecifyArchitecture>
- <CopyOutput>.\$(IntDir)\WpdBasicHardwareDriver.inf</CopyOutput>
- </Inf>
- <OtherWpp Include="WpdBasicHardwareDriver.rc; WpdBasicHardwareDriver.idl">
- <WppEnabled>true</WppEnabled>
- <WppDllMacro>true</WppDllMacro>
- <WppScanConfigurationData>stdafx.h</WppScanConfigurationData>
- </OtherWpp>
- </ItemGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <TargetName>WpdBasicHardwareDriver</TargetName>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <TargetName>WpdBasicHardwareDriver</TargetName>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <TargetName>WpdBasicHardwareDriver</TargetName>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <TargetName>WpdBasicHardwareDriver</TargetName>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Link>
- <EntryPointSymbol Condition="'$(Platform)'=='win32'">_DllMainCRTStartup@12</EntryPointSymbol>
- <EntryPointSymbol Condition="'$(Platform)'!='win32'">_DllMainCRTStartup</EntryPointSymbol>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Link>
- <EntryPointSymbol Condition="'$(Platform)'=='win32'">_DllMainCRTStartup@12</EntryPointSymbol>
- <EntryPointSymbol Condition="'$(Platform)'!='win32'">_DllMainCRTStartup</EntryPointSymbol>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Link>
- <EntryPointSymbol Condition="'$(Platform)'=='win32'">_DllMainCRTStartup@12</EntryPointSymbol>
- <EntryPointSymbol Condition="'$(Platform)'!='win32'">_DllMainCRTStartup</EntryPointSymbol>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Link>
- <EntryPointSymbol Condition="'$(Platform)'=='win32'">_DllMainCRTStartup@12</EntryPointSymbol>
- <EntryPointSymbol Condition="'$(Platform)'!='win32'">_DllMainCRTStartup</EntryPointSymbol>
- </Link>
- </ItemDefinitionGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <UseOfAtl>Dynamic</UseOfAtl>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <UseOfAtl>Dynamic</UseOfAtl>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <UseOfAtl>Dynamic</UseOfAtl>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <UseOfAtl>Dynamic</UseOfAtl>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <ExceptionHandling>Sync</ExceptionHandling>
- <TreatWarningAsError>true</TreatWarningAsError>
- <WarningLevel>Level4</WarningLevel>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </ClCompile>
- <ResourceCompile>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </ResourceCompile>
- <Midl>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </Midl>
- <Link>
- <AdditionalDependencies>%(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\ole32.lib;$(SDK_LIB_PATH)\oleaut32.lib;$(SDK_LIB_PATH)\uuid.lib;$(SDK_LIB_PATH)\user32.lib;$(SDK_LIB_PATH)\advapi32.lib;$(SDK_LIB_PATH)\shlwapi.lib;$(SDK_LIB_PATH)\PortableDeviceGuids.lib</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <ExceptionHandling>Sync</ExceptionHandling>
- <TreatWarningAsError>true</TreatWarningAsError>
- <WarningLevel>Level4</WarningLevel>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </ClCompile>
- <ResourceCompile>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </ResourceCompile>
- <Midl>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </Midl>
- <Link>
- <AdditionalDependencies>%(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\ole32.lib;$(SDK_LIB_PATH)\oleaut32.lib;$(SDK_LIB_PATH)\uuid.lib;$(SDK_LIB_PATH)\user32.lib;$(SDK_LIB_PATH)\advapi32.lib;$(SDK_LIB_PATH)\shlwapi.lib;$(SDK_LIB_PATH)\PortableDeviceGuids.lib</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <ExceptionHandling>Sync</ExceptionHandling>
- <TreatWarningAsError>true</TreatWarningAsError>
- <WarningLevel>Level4</WarningLevel>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </ClCompile>
- <ResourceCompile>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </ResourceCompile>
- <Midl>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </Midl>
- <Link>
- <AdditionalDependencies>%(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\ole32.lib;$(SDK_LIB_PATH)\oleaut32.lib;$(SDK_LIB_PATH)\uuid.lib;$(SDK_LIB_PATH)\user32.lib;$(SDK_LIB_PATH)\advapi32.lib;$(SDK_LIB_PATH)\shlwapi.lib;$(SDK_LIB_PATH)\PortableDeviceGuids.lib</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <ExceptionHandling>Sync</ExceptionHandling>
- <TreatWarningAsError>true</TreatWarningAsError>
- <WarningLevel>Level4</WarningLevel>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </ClCompile>
- <ResourceCompile>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </ResourceCompile>
- <Midl>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)</AdditionalIncludeDirectories>
- </Midl>
- <Link>
- <AdditionalDependencies>%(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\ole32.lib;$(SDK_LIB_PATH)\oleaut32.lib;$(SDK_LIB_PATH)\uuid.lib;$(SDK_LIB_PATH)\user32.lib;$(SDK_LIB_PATH)\advapi32.lib;$(SDK_LIB_PATH)\shlwapi.lib;$(SDK_LIB_PATH)\PortableDeviceGuids.lib</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Link>
- <ModuleDefinitionFile>WpdBasicHardwareDriver.def</ModuleDefinitionFile>
- </Link>
- <DriverSign>
- <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
- </DriverSign>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Link>
- <ModuleDefinitionFile>WpdBasicHardwareDriver.def</ModuleDefinitionFile>
- </Link>
- <DriverSign>
- <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
- </DriverSign>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Link>
- <ModuleDefinitionFile>WpdBasicHardwareDriver.def</ModuleDefinitionFile>
- </Link>
- <DriverSign>
- <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
- </DriverSign>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Link>
- <ModuleDefinitionFile>WpdBasicHardwareDriver.def</ModuleDefinitionFile>
- </Link>
- <DriverSign>
- <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
- </DriverSign>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="Stdafxsrc.cpp">
- <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreCompiledHeaderFile>Stdafx.h</PreCompiledHeaderFile>
- <PreCompiledHeader>Create</PreCompiledHeader>
- <PreCompiledHeaderOutputFile>$(IntDir)\Stdafx.h.pch</PreCompiledHeaderOutputFile>
- </ClCompile>
- <Midl Include="WpdBasicHardwareDriver.idl" />
- <ResourceCompile Include="WpdBasicHardwareDriver.rc" />
- </ItemGroup>
- <ItemGroup>
- <Inf Exclude="@(Inf)" Include="*.inf" />
- <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
- </ItemGroup>
- <ItemGroup>
- <None Exclude="@(None)" Include="*.txt;*.htm;*.html" />
- <None Exclude="@(None)" Include="*.ico;*.cur;*.bmp;*.dlg;*.rct;*.gif;*.jpg;*.jpeg;*.wav;*.jpe;*.tiff;*.tif;*.png;*.rc2" />
- <None Exclude="@(None)" Include="*.def;*.bat;*.hpj;*.asmx" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-</Project> \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.vcxproj.Filters b/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.vcxproj.Filters
deleted file mode 100644
index 2b0c894d..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdBasicHardwareDriver.vcxproj.Filters
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
- <UniqueIdentifier>{87BC3193-63DE-407F-9D36-4672BA568413}</UniqueIdentifier>
- </Filter>
- <Filter Include="Header Files">
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- <UniqueIdentifier>{34A617F5-BA38-4A42-80E9-F38C652127D4}</UniqueIdentifier>
- </Filter>
- <Filter Include="Resource Files">
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
- <UniqueIdentifier>{B731F5B5-20D6-4344-A6C6-344B616EDE83}</UniqueIdentifier>
- </Filter>
- <Filter Include="Driver Files">
- <Extensions>inf;inv;inx;mof;mc;</Extensions>
- <UniqueIdentifier>{A6935631-CF1A-44E0-978B-A8A0D1F3E7D6}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="Device.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Driver.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Queue.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="RS232Connection.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="RS232Target.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Stdafxsrc.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="WpdBaseDriver.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="WpdBasicHardwareDriver.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="WpdCapabilities.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="WpdObjectEnum.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="WpdObjectProperties.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <Midl Include="WpdBasicHardwareDriver.idl">
- <Filter>Source Files</Filter>
- </Midl>
- <None Include="WpdBasicHardwareDriver.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <Inf Include="WpdBasicHardwareDriver.inx">
- <Filter>Driver Files</Filter>
- </Inf>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="WpdBasicHardwareDriver.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/WpdCapabilities.cpp b/wpd/WpdBasicHardwareDriver/WpdCapabilities.cpp
deleted file mode 100644
index e14c53c2..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdCapabilities.cpp
+++ /dev/null
@@ -1,505 +0,0 @@
-#include "stdafx.h"
-
-#include "WpdCapabilities.tmh"
-
-const PROPERTYKEY g_SupportedCommands[] =
-{
- // WPD_CATEGORY_OBJECT_ENUMERATION
- WPD_COMMAND_OBJECT_ENUMERATION_START_FIND,
- WPD_COMMAND_OBJECT_ENUMERATION_FIND_NEXT,
- WPD_COMMAND_OBJECT_ENUMERATION_END_FIND,
-
- // WPD_CATEGORY_OBJECT_PROPERTIES
- WPD_COMMAND_OBJECT_PROPERTIES_GET_SUPPORTED,
- WPD_COMMAND_OBJECT_PROPERTIES_GET,
- WPD_COMMAND_OBJECT_PROPERTIES_GET_ALL,
- WPD_COMMAND_OBJECT_PROPERTIES_SET,
- WPD_COMMAND_OBJECT_PROPERTIES_GET_ATTRIBUTES,
- WPD_COMMAND_OBJECT_PROPERTIES_DELETE,
-
- // WPD_CATEGORY_CAPABILITIES
- WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_COMMANDS,
- WPD_COMMAND_CAPABILITIES_GET_COMMAND_OPTIONS,
- WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FUNCTIONAL_CATEGORIES,
- WPD_COMMAND_CAPABILITIES_GET_FUNCTIONAL_OBJECTS,
- WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_EVENTS,
- WPD_COMMAND_CAPABILITIES_GET_EVENT_OPTIONS,
-};
-
-const GUID g_SupportedFunctionalCategories[] =
-{
- WPD_FUNCTIONAL_CATEGORY_DEVICE,
- FUNCTIONAL_CATEGORY_SENSOR_SAMPLE, // Our device's functional category
-};
-
-const GUID g_SupportedEvents[] =
-{
- EVENT_SENSOR_READING_UPDATED,
-};
-
-WpdCapabilities::WpdCapabilities()
-{
-
-}
-
-WpdCapabilities::~WpdCapabilities()
-{
-
-}
-
-HRESULT WpdCapabilities::DispatchWpdMessage(_In_ REFPROPERTYKEY Command,
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
-
- if (Command.fmtid != WPD_CATEGORY_CAPABILITIES)
- {
- hr = E_INVALIDARG;
- CHECK_HR(hr, "This object does not support this command category %ws",CComBSTR(Command.fmtid));
- }
-
- if (hr == S_OK)
- {
- if (IsEqualPropertyKey(Command, WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_COMMANDS))
- {
- hr = OnGetSupportedCommands(pParams, pResults);
- CHECK_HR(hr, "Failed to get supported commands");
- }
- else if (IsEqualPropertyKey(Command, WPD_COMMAND_CAPABILITIES_GET_COMMAND_OPTIONS))
- {
- hr = OnGetCommandOptions(pParams, pResults);
- CHECK_HR(hr, "Failed to get command options");
- }
- else if (IsEqualPropertyKey(Command, WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FUNCTIONAL_CATEGORIES))
- {
- hr = OnGetFunctionalCategories(pParams, pResults);
- CHECK_HR(hr, "Failed to get functional categories");
- }
- else if (IsEqualPropertyKey(Command, WPD_COMMAND_CAPABILITIES_GET_FUNCTIONAL_OBJECTS))
- {
- hr = OnGetFunctionalObjects(pParams, pResults);
- CHECK_HR(hr, "Failed to get functional objects");
- }
- else if (IsEqualPropertyKey(Command, WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_EVENTS))
- {
- hr = OnGetSupportedEvents(pParams, pResults);
- CHECK_HR(hr, "Failed to get supported events");
- }
- else if (IsEqualPropertyKey(Command, WPD_COMMAND_CAPABILITIES_GET_EVENT_OPTIONS))
- {
- hr = OnGetEventOptions(pParams, pResults);
- CHECK_HR(hr, "Failed to get event options");
- }
- else
- {
- hr = E_NOTIMPL;
- CHECK_HR(hr, "This object does not support this command id %d", Command.pid);
- }
- }
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_COMMANDS
- * command.
- *
- * The parameters sent to us are:
- * - none.
- *
- * The driver should:
- * - Return all commands supported by this driver as an
- * IPortableDeviceKeyCollection in WPD_PROPERTY_CAPABILITIES_SUPPORTED_COMMANDS.
- * This includes custom commands, if any.
- *
- * Note that certain commands require a "command target" to function correctly.
- * (e.g. delete object command) It is understood that not all objects are necessarily
- * valid targets (e.g. you cannot delete the device object).
- */
-HRESULT WpdCapabilities::OnGetSupportedCommands(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- CComPtr<IPortableDeviceKeyCollection> pCommands;
- UNREFERENCED_PARAMETER(pParams);
-
- // CoCreate a collection to store the supported commands.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceKeyCollection,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceKeyCollection,
- (VOID**) &pCommands);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceKeyCollection");
- }
-
- // Add the supported commands to the collection.
- if (hr == S_OK)
- {
- for (DWORD dwIndex = 0; dwIndex < ARRAYSIZE(g_SupportedCommands); dwIndex++)
- {
- hr = pCommands->Add(g_SupportedCommands[dwIndex]);
- CHECK_HR(hr, "Failed to add supported command at index %d", dwIndex);
- if (FAILED(hr))
- {
- break;
- }
- }
- }
-
- // Set the WPD_PROPERTY_CAPABILITIES_SUPPORTED_COMMANDS value in the results.
- if (hr == S_OK)
- {
- hr = pResults->SetIUnknownValue(WPD_PROPERTY_CAPABILITIES_SUPPORTED_COMMANDS, pCommands);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_CAPABILITIES_SUPPORTED_COMMANDS");
- }
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_CAPABILITIES_GET_COMMAND_OPTIONS
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_CAPABILITIES_COMMAND: a collection of property keys containing a single value,
- * which identifies the specific command options are requested to return.
- *
- * The driver should:
- * - Return an IPortableDeviceValues in WPD_PROPERTY_CAPABILITIES_COMMAND_OPTIONS, containing
- * the relevant options. If no options are available for this command, the driver should
- * return an IPortableDeviceValues with no elements in it.
- */
-HRESULT WpdCapabilities::OnGetCommandOptions(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- PROPERTYKEY Command = WPD_PROPERTY_NULL;
- CComPtr<IPortableDeviceValues> pOptions;
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the command whose options have been requested
- if (hr == S_OK)
- {
- hr = pParams->GetKeyValue(WPD_PROPERTY_CAPABILITIES_COMMAND, &Command);
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_CAPABILITIES_COMMAND");
- }
-
- // CoCreate a collection to store the command options.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**) &pOptions);
- CHECK_HR(hr, "Failed to CoCreateInstance CLSID_PortableDeviceValues");
- }
-
- // Add command options to the collection
- if (hr == S_OK)
- {
- // If your driver supports command options, then they should be added here
- // to the command options collection 'pOptions'.
- }
-
- // Set the WPD_PROPERTY_CAPABILITIES_COMMAND_OPTIONS value in the results.
- if (hr == S_OK)
- {
- hr = pResults->SetIUnknownValue(WPD_PROPERTY_CAPABILITIES_COMMAND_OPTIONS, pOptions);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_CAPABILITIES_COMMAND_OPTIONS");
- }
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FUNCTIONAL_CATEGORIES
- * command.
- *
- * The parameters sent to us are:
- * - none.
- *
- * The driver should:
- * - Return an IPortableDevicePropVariantCollection (of type VT_CLSID) in
- * WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES, containing
- * the supported functional categories for this device.
- */
-HRESULT WpdCapabilities::OnGetFunctionalCategories(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- CComPtr<IPortableDevicePropVariantCollection> pFunctionalCategories;
-
- UNREFERENCED_PARAMETER(pParams);
-
- // CoCreate a collection to store the supported functional categories.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDevicePropVariantCollection,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDevicePropVariantCollection,
- (VOID**) &pFunctionalCategories);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDevicePropVariantCollection");
- }
-
- // Add the supported functional categories to the collection.
- if (hr == S_OK)
- {
- for (DWORD dwIndex = 0; dwIndex < ARRAYSIZE(g_SupportedFunctionalCategories); dwIndex++)
- {
- PROPVARIANT pv = {0};
- PropVariantInit(&pv);
- // Don't call PropVariantClear, since we did not allocate the memory for these GUIDs
-
- pv.vt = VT_CLSID;
- pv.puuid = (GUID*) &g_SupportedFunctionalCategories[dwIndex];
-
- hr = pFunctionalCategories->Add(&pv);
- CHECK_HR(hr, "Failed to add supported functional category at index %d", dwIndex);
- if (FAILED(hr))
- {
- break;
- }
- }
- }
-
- // Set the WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES value in the results.
- if (hr == S_OK)
- {
- hr = pResults->SetIUnknownValue(WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES, pFunctionalCategories);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES");
- }
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_CAPABILITIES_GET_FUNCTIONAL_OBJECTS
- * command. It is sent when the caller is interesting in finding the object IDs for all
- * functional objects belonging to the specified functional category.
- * Note: the number of functional objects is expected to be very small (less than 8 for the
- * whole device).
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORY - a GUID value containing the category
- * the caller is looking for. If the value is WPD_FUNCTIONAL_CATEGORY_ALL, then the driver
- * must return all functional objects, no matter which category they belong to.
- *
- * The driver should:
- * - Return an IPortableDevicePropVariantCollection (of type VT_LPWSTR) in
- * WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_OBJECTS, containing
- * the ids of the functional objects who belong to the specified functional category.
- * If there are no objects in the specified category, the driver should return an
- * empty collection.
- */
-HRESULT WpdCapabilities::OnGetFunctionalObjects(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- GUID guidFunctionalCategory = GUID_NULL;
- CComPtr<IPortableDevicePropVariantCollection> pFunctionalObjects;
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the functional category whose functional object identifiers have been requested
- if (hr == S_OK)
- {
- hr = pParams->GetGuidValue(WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORY, &guidFunctionalCategory);
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORY");
- }
-
- // CoCreate a collection to store the supported functional object identifiers.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDevicePropVariantCollection,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDevicePropVariantCollection,
- (VOID**) &pFunctionalObjects);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDevicePropVariantCollection");
- }
-
- // Add the supported functional object identifiers for the specified functional
- // category to the collection.
- if (hr == S_OK)
- {
- PROPVARIANT pv = {0};
- PropVariantInit(&pv);
- // Don't call PropVariantClear, since we did not allocate the memory for these object identifiers
-
- // Add WPD_DEVICE_OBJECT_ID to the functional object identifiers collection
- if (hr == S_OK)
- {
-
- if ((guidFunctionalCategory == WPD_FUNCTIONAL_CATEGORY_DEVICE) ||
- (guidFunctionalCategory == WPD_FUNCTIONAL_CATEGORY_ALL))
- {
- pv.vt = VT_LPWSTR;
- pv.pwszVal = WPD_DEVICE_OBJECT_ID;
- hr = pFunctionalObjects->Add(&pv);
- CHECK_HR(hr, "Failed to add device object ID");
- }
- }
-
- // Add FUNCTIONAL_CATEGORY_SENSOR_SAMPLE to the functional object
- // identifiers collection
- if (hr == S_OK)
- {
- if ((guidFunctionalCategory == FUNCTIONAL_CATEGORY_SENSOR_SAMPLE) ||
- (guidFunctionalCategory == WPD_FUNCTIONAL_CATEGORY_ALL))
- {
- pv.vt = VT_LPWSTR;
- pv.pwszVal = SENSOR_OBJECT_ID;
- hr = pFunctionalObjects->Add(&pv);
- CHECK_HR(hr, "Failed to add sensor object ID");
- }
- }
- }
-
- // Set the WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_OBJECTS value in the results.
- if (hr == S_OK)
- {
- hr = pResults->SetIUnknownValue(WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_OBJECTS, pFunctionalObjects);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_OBJECTS");
- }
-
- return hr;
-}
-
-
-/**
- * This method is called when we receive a WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_EVENTS
- * command.
- *
- * The parameters sent to us are:
- * - none.
- *
- * The driver should:
- * - Return all events supported by this driver should be returned as an
- * IPortableDeviceKeyCollection in WPD_PROPERTY_CAPABILITIES_SUPPORTED_EVENTS.
- * That includes custom commands, if any.
- */
-HRESULT WpdCapabilities::OnGetSupportedEvents(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- CComPtr<IPortableDevicePropVariantCollection> pEvents;
- UNREFERENCED_PARAMETER(pParams);
-
- // CoCreate a collection to store the supported events.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDevicePropVariantCollection,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDevicePropVariantCollection,
- (VOID**) &pEvents);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDevicePropVariantCollection");
- }
-
- // Add the supported events to the collection.
- if (hr == S_OK)
- {
- // populate the supported events collection
- for (DWORD dwIndex = 0; dwIndex < ARRAYSIZE(g_SupportedEvents); dwIndex++)
- {
- PROPVARIANT pv = {0};
- PropVariantInit(&pv);
- // Don't call PropVariantClear, since we did not allocate the memory for these GUIDs
-
- pv.vt = VT_CLSID;
- pv.puuid = (GUID*) &g_SupportedEvents[dwIndex];
-
- hr = pEvents->Add(&pv);
- CHECK_HR(hr, "Failed to add supported event at index %d", dwIndex);
- if (FAILED(hr))
- {
- break;
- }
- }
- }
-
- // Set the WPD_PROPERTY_CAPABILITIES_SUPPORTED_EVENTS value in the results.
- if (hr == S_OK)
- {
- hr = pResults->SetIUnknownValue(WPD_PROPERTY_CAPABILITIES_SUPPORTED_EVENTS, pEvents);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_CAPABILITIES_SUPPORTED_EVENTS");
- }
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_CAPABILITIES_GET_EVENT_OPTIONS
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_CAPABILITIES_EVENT: a GUID value indicating the Event whose options should be returned.
- *
- * The driver should:
- * - Return an IPortableDeviceValues in WPD_PROPERTY_CAPABILITIES_EVENT_OPTIONS, containing
- * the relevant options.
- */
-HRESULT WpdCapabilities::OnGetEventOptions(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- GUID Event = GUID_NULL;
- CComPtr<IPortableDeviceValues> pOptions;
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the event whose options have been requested
- if (hr == S_OK)
- {
- hr = pParams->GetGuidValue(WPD_PROPERTY_CAPABILITIES_EVENT, &Event);
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_CAPABILITIES_EVENT");
- }
-
- // CoCreate a collection to store the event options.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**) &pOptions);
- CHECK_HR(hr, "Failed to CoCreateInstance CLSID_PortableDeviceValues");
- }
-
- // Add event options to the collection
- if (hr == S_OK)
- {
- // Check for the events we support
- if (Event == EVENT_SENSOR_READING_UPDATED)
- {
- // These events are broadcast events
- hr = pOptions->SetBoolValue(WPD_EVENT_OPTION_IS_BROADCAST_EVENT, TRUE);
- CHECK_HR(hr, "Failed to set WPD_EVENT_OPTION_IS_BROADCAST_EVENT");
- }
- }
-
- // Set the WPD_PROPERTY_CAPABILITIES_EVENT_OPTIONS value in the results.
- if (hr == S_OK)
- {
- hr = pResults->SetIUnknownValue(WPD_PROPERTY_CAPABILITIES_EVENT_OPTIONS, pOptions);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_CAPABILITIES_EVENT_OPTIONS");
- }
-
- return hr;
-}
-
-
diff --git a/wpd/WpdBasicHardwareDriver/WpdCapabilities.h b/wpd/WpdBasicHardwareDriver/WpdCapabilities.h
deleted file mode 100644
index b7435830..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdCapabilities.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#pragma once
-
-class WpdCapabilities
-{
-public:
- WpdCapabilities();
- virtual ~WpdCapabilities();
-
- HRESULT Initialize();
-
- HRESULT DispatchWpdMessage(
- _In_ REFPROPERTYKEY Command,
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnGetSupportedCommands(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnGetCommandOptions(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnGetFunctionalCategories(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnGetFunctionalObjects(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnGetSupportedEvents(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnGetEventOptions(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
-};
-
diff --git a/wpd/WpdBasicHardwareDriver/WpdObjectEnum.cpp b/wpd/WpdBasicHardwareDriver/WpdObjectEnum.cpp
deleted file mode 100644
index d804802e..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdObjectEnum.cpp
+++ /dev/null
@@ -1,431 +0,0 @@
-#include "stdafx.h"
-
-#include "WpdObjectEnum.tmh"
-
-WpdObjectEnumerator::WpdObjectEnumerator()
-{
-
-}
-
-WpdObjectEnumerator::~WpdObjectEnumerator()
-{
-
-}
-
-HRESULT WpdObjectEnumerator::Initialize(_In_ WpdBaseDriver* pBaseDriver)
-{
- m_pBaseDriver = pBaseDriver;
- return S_OK;
-}
-
-HRESULT WpdObjectEnumerator::DispatchWpdMessage(_In_ REFPROPERTYKEY Command,
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
-
- if (Command.fmtid != WPD_CATEGORY_OBJECT_ENUMERATION)
- {
- hr = E_INVALIDARG;
- CHECK_HR(hr, "This object does not support this command category %ws",CComBSTR(Command.fmtid));
- }
-
- if (hr == S_OK)
- {
- if (Command.pid == WPD_COMMAND_OBJECT_ENUMERATION_START_FIND.pid)
- {
- hr = OnStartFind(pParams, pResults);
- CHECK_HR(hr, "Failed to begin enumeration");
- }
- else if (Command.pid == WPD_COMMAND_OBJECT_ENUMERATION_FIND_NEXT.pid)
- {
- hr = OnFindNext(pParams, pResults);
- if(FAILED(hr))
- {
- CHECK_HR(hr, "Failed to find next object");
- }
- }
- else if (Command.pid == WPD_COMMAND_OBJECT_ENUMERATION_END_FIND.pid)
- {
- hr = OnEndFind(pParams, pResults);
- CHECK_HR(hr, "Failed to end enumeration");
- }
- else
- {
- hr = E_NOTIMPL;
- CHECK_HR(hr, "This object does not support this command id %d", Command.pid);
- }
- }
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_OBJECT_ENUMERATION_START_FIND
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_OBJECT_ENUMERATION_PARENT_ID: the parent where we should start
- * the enumeration.
- * - WPD_PROPERTY_OBJECT_ENUMERATION_FILTER: the filter to use when doing
- * enumeration. Since this parameter is optional, it may not exist.
- * This driver currently ignores the filter parameter.
- *
- * The driver should:
- * - Create a new context for this enumeration.
- * - Set the string identifier in WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT for the newly created enumeration context.
- * This value will be passed back during OnFindNext and OnEndFind.
- */
-HRESULT WpdObjectEnumerator::OnStartFind(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- LPWSTR wszParentID = NULL;
- ContextMap* pContextMap = NULL;
- CAtlStringW strEnumContext;
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the object identifier of the parent where the enumeration is starting from.
- hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_ENUMERATION_PARENT_ID, &wszParentID);
- if (hr != S_OK)
- {
- hr = E_INVALIDARG;
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_ENUMERATION_PARENT_ID");
- }
-
- // Get the client context map so we can store an enumeration context for this enumeration
- // operation.
- if (hr == S_OK)
- {
- hr = pParams->GetIUnknownValue(PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP, (IUnknown**)&pContextMap);
- CHECK_HR(hr, "Failed to get PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP");
- }
-
- // Create and initialize a new enumeration context.
- // Add the new enumertion context to the client context map. This context is used to
- // keep track of this particular enumeration operation.
- if (hr == S_OK)
- {
- WpdObjectEnumeratorContext* pEnumeratorContext = new WpdObjectEnumeratorContext();
- if (pEnumeratorContext != NULL)
- {
- // Initialize the enumeration context
- InitializeEnumerationContext(pEnumeratorContext, wszParentID);
-
- // Add the enumeration context to the client context map.
- pContextMap->Add(pEnumeratorContext, strEnumContext);
-
- // Release the context because Add AddRef's it
- SAFE_RELEASE(pEnumeratorContext);
- }
- else
- {
- hr = E_OUTOFMEMORY;
- CHECK_HR(hr, "Failed to allocate enumeration context");
- }
- }
-
- // Set the WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT value in the results.
- // This context identifier will be passed back during OnFindNext and OnEndFind to allow the driver to access it.
- if (hr == S_OK)
- {
- hr = pResults->SetStringValue(WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT, strEnumContext);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT");
- }
-
- // Free the memory.
- CoTaskMemFree(wszParentID);
- wszParentID = NULL;
-
- SAFE_RELEASE(pContextMap);
-
- return hr;
-}
-
-HRESULT WpdObjectEnumerator::OnFindNext(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- LPWSTR wszEnumContext = NULL;
- DWORD dwNumObjectsRequested = 0;
- ContextMap* pContextMap = NULL;
- WpdObjectEnumeratorContext* pEnumeratorContext = NULL;
- DWORD NumObjectsEnumerated = 0;
-
- CComPtr<IPortableDevicePropVariantCollection> pObjectIDCollection;
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the enumeration context identifier for this enumeration operation.
- // The enumeration context identifier is needed to lookup the specific
- // enumeration context in the client context map for this enumeration operation.
- // NOTE that more than one enumeration may be in progress.
- hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT, &wszEnumContext);
- if (hr != S_OK)
- {
- hr = E_INVALIDARG;
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT");
- }
-
- // Get the number of objects requested for this enumeration call.
- // The driver should always attempt to meet this requested value.
- // If there are fewer children than requested, the driver should return the remaining
- // children and a return code of S_FALSE.
- hr = pParams->GetUnsignedIntegerValue(WPD_PROPERTY_OBJECT_ENUMERATION_NUM_OBJECTS_REQUESTED, &dwNumObjectsRequested);
- if (hr != S_OK)
- {
- hr = E_INVALIDARG;
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_ENUMERATION_NUM_OBJECTS_REQUESTED");
- }
-
- // Get the client context map so we can retrieve the enumeration context for this enumeration
- // operation.
- if (hr == S_OK)
- {
- hr = pParams->GetIUnknownValue(PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP, (IUnknown**)&pContextMap);
- CHECK_HR(hr, "Failed to get PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP");
- }
-
- if (hr == S_OK)
- {
- pEnumeratorContext = (WpdObjectEnumeratorContext*)pContextMap->GetContext(wszEnumContext);
- if (pEnumeratorContext == NULL)
- {
- hr = E_INVALIDARG;
- CHECK_HR(hr, "Missing enumeration context");
- }
- }
-
- // CoCreate a collection to store the object identifiers being returned for this enumeration call.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDevicePropVariantCollection,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDevicePropVariantCollection,
- (VOID**) &pObjectIDCollection);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDevicePropVariantCollection");
- }
-
- // If the enumeration context reports that their are more objects to return, then continue, if not,
- // return an empty results set.
- if ((hr == S_OK) && (pEnumeratorContext != NULL) && (pEnumeratorContext->HasMoreChildrenToEnumerate() == TRUE))
- {
- if (pEnumeratorContext->m_strParentObjectID.CompareNoCase(L"") == 0)
- {
- // We are being asked for the WPD_DEVICE_OBJECT_ID
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, WPD_DEVICE_OBJECT_ID);
- CHECK_HR(hr, "Failed to add 'DEVICE' object ID to enumeration collection");
-
- // Update the the number of children we are returning for this enumeration call
- NumObjectsEnumerated++;
- }
- else if (pEnumeratorContext->m_strParentObjectID.CompareNoCase(WPD_DEVICE_OBJECT_ID) == 0)
- {
-
- // We are being asked for direct children of the WPD_DEVICE_OBJECT_ID
- switch (m_pBaseDriver->m_SensorType)
- {
- case WpdBaseDriver::UNKNOWN:
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, SENSOR_OBJECT_ID);
- break;
- case WpdBaseDriver::COMPASS:
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, COMPASS_SENSOR_OBJECT_ID);
- break;
- case WpdBaseDriver::SENSIRON:
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, TEMP_SENSOR_OBJECT_ID);
- break;
- case WpdBaseDriver::FLEX:
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, FLEX_SENSOR_OBJECT_ID);
- break;
- case WpdBaseDriver::PING:
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, PING_SENSOR_OBJECT_ID);
- break;
- case WpdBaseDriver::PIR:
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, PIR_SENSOR_OBJECT_ID);
- break;
- case WpdBaseDriver::MEMSIC:
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, MEMSIC_SENSOR_OBJECT_ID);
- break;
- case WpdBaseDriver::QTI:
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, QTI_SENSOR_OBJECT_ID);
- break;
- case WpdBaseDriver::PIEZO:
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, PIEZO_SENSOR_OBJECT_ID);
- break;
- case WpdBaseDriver::HITACHI:
- hr = AddStringValueToPropVariantCollection(pObjectIDCollection, HITACHI_SENSOR_OBJECT_ID);
- break;
- default:
- break;
- }
- CHECK_HR(hr, "Failed to add storage object ID to enumeration collection");
-
- // Update the the number of children we are returning for this enumeration call
- NumObjectsEnumerated++;
-
- }
- }
-
- // Set the collection of object identifiers enumerated in the results
- if (hr == S_OK)
- {
- hr = pResults->SetIPortableDevicePropVariantCollectionValue(WPD_PROPERTY_OBJECT_ENUMERATION_OBJECT_IDS, pObjectIDCollection);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_OBJECT_ENUMERATION_OBJECT_IDS");
- }
-
- // If the enumeration context reports that their are no more objects to return then return S_FALSE indicating to the
- // caller that we are finished.
- if (hr == S_OK)
- {
- if (pEnumeratorContext != NULL)
- {
- // Update the number of children we have enumerated and returned to the caller
- pEnumeratorContext->m_ChildrenEnumerated += NumObjectsEnumerated;
-
- // Check the number requested against the number enumerated and set the HRESULT
- // accordingly.
- if (NumObjectsEnumerated < dwNumObjectsRequested)
- {
- // We returned less than the number of objects requested to the caller
- hr = S_FALSE;
- }
- else
- {
- // We returned exactly the number of objects requested to the caller
- hr = S_OK;
- }
- }
- }
-
- // Free the memory.
- CoTaskMemFree(wszEnumContext);
- wszEnumContext = NULL;
-
- SAFE_RELEASE(pContextMap);
- SAFE_RELEASE(pEnumeratorContext);
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_OBJECT_ENUMERATION_END_FIND
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT: the context the driver returned to
- * the client in OnStartFind.
- *
- * The driver should:
- * - Destroy any data associated with this context.
- */
-HRESULT WpdObjectEnumerator::OnEndFind(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- LPWSTR wszEnumContext = NULL;
- ContextMap* pContextMap = NULL;
-
- UNREFERENCED_PARAMETER(pResults);
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the enumeration context identifier for this enumeration operation. We will
- // need this to lookup the specific enumeration context in the client context map.
- hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT, &wszEnumContext);
- if (hr != S_OK)
- {
- hr = E_INVALIDARG;
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT");
- }
-
- // Get the client context map so we can retrieve the enumeration context for this enumeration
- // operation using the WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT property value obtained above.
- if (hr == S_OK)
- {
- hr = pParams->GetIUnknownValue(PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP, (IUnknown**)&pContextMap);
- CHECK_HR(hr, "Failed to get PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP");
- }
-
- // Destroy any data allocated/associated with the enumeration context and then remove it from the context map.
- // We no longer need to keep this context around because the enumeration has been ended.
- if (hr == S_OK)
- {
- pContextMap->Remove(wszEnumContext);
- }
-
- // Free the memory.
- CoTaskMemFree(wszEnumContext);
- wszEnumContext = NULL;
-
- SAFE_RELEASE(pContextMap);
-
- return hr;
-}
-
-// Initialize the enumeration context
-VOID WpdObjectEnumerator::InitializeEnumerationContext(
- _In_ WpdObjectEnumeratorContext* pEnumeratorContext,
- _In_ LPCWSTR wszParentObjectID)
-{
- if (pEnumeratorContext == NULL)
- {
- return;
- }
-
- // Initialize the enumeration context with the parent object identifier
- pEnumeratorContext->m_strParentObjectID = wszParentObjectID;
-
- // Our sample driver has a very simple object structure where we know
- // how many children are under each parent.
- // The eumeration context is initialized below with this information.
- if (pEnumeratorContext->m_strParentObjectID.CompareNoCase(L"") == 0)
- {
- // Clients passing an 'empty' string for the parent are asking for the
- // 'DEVICE' object. We should return 1 child in this case.
- pEnumeratorContext->m_TotalChildren = 1;
- }
- else if (pEnumeratorContext->m_strParentObjectID.CompareNoCase(WPD_DEVICE_OBJECT_ID) == 0)
- {
- // The device object contains 1 child (the storage object).
- pEnumeratorContext->m_TotalChildren = 1;
- }
- // If the sensor objects have children, add them here...
- else
- {
- // The sensor object contains 0 children.
- pEnumeratorContext->m_TotalChildren = 0;
- }
-}
-
-HRESULT WpdObjectEnumerator::AddStringValueToPropVariantCollection(
- _In_ IPortableDevicePropVariantCollection* pCollection,
- _In_ LPCWSTR wszValue)
-{
- HRESULT hr = S_OK;
-
- if ((pCollection == NULL) ||
- (wszValue == NULL))
- {
- hr = E_INVALIDARG;
- return hr;
- }
-
- PROPVARIANT pv = {0};
- PropVariantInit(&pv);
-
- pv.vt = VT_LPWSTR;
- pv.pwszVal = (LPWSTR)wszValue;
-
- // The wszValue will be copied into the collection, keeping the ownership
- // of the string belonging to the caller.
- // Don't call PropVariantClear, since we did not allocate the memory for these string values
-
- hr = pCollection->Add(&pv);
-
- return hr;
-}
diff --git a/wpd/WpdBasicHardwareDriver/WpdObjectEnum.h b/wpd/WpdBasicHardwareDriver/WpdObjectEnum.h
deleted file mode 100644
index e6dc0542..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdObjectEnum.h
+++ /dev/null
@@ -1,107 +0,0 @@
-#pragma once
-
-// This class is used to store the context for a specific enumeration.
-class WpdObjectEnumeratorContext : public IUnknown
-{
-public:
- WpdObjectEnumeratorContext() :
- m_cRef(1),
- m_TotalChildren(0),
- m_ChildrenEnumerated(0)
- {
-
- }
-
- ~WpdObjectEnumeratorContext()
- {
-
- }
-
-public: // IUnknown
- ULONG __stdcall AddRef()
- {
- InterlockedIncrement((long*) &m_cRef);
- return m_cRef;
- }
-
- _At_(this, __drv_freesMem(Mem))
- ULONG __stdcall Release()
- {
- ULONG ulRefCount = m_cRef - 1;
-
- if (InterlockedDecrement((long*) &m_cRef) == 0)
- {
- delete this;
- return 0;
- }
- return ulRefCount;
- }
-
- HRESULT __stdcall QueryInterface(
- REFIID riid,
- void** ppv)
- {
- HRESULT hr = S_OK;
-
- if(riid == IID_IUnknown)
- {
- *ppv = static_cast<IUnknown*>(this);
- AddRef();
- }
- else
- {
- *ppv = NULL;
- hr = E_NOINTERFACE;
- }
-
- return hr;
- }
-
-private:
- DWORD m_cRef;
-
-public:
- BOOL HasMoreChildrenToEnumerate()
- {
- return (m_TotalChildren > m_ChildrenEnumerated)?TRUE:FALSE;
- }
-
-// WpdObjectEnumeratorContext specific data
-public:
- CAtlStringW m_strParentObjectID; // object identifier of the object whose children are being enumerated
- DWORD m_TotalChildren; // number of bytes transferred from the resource to the caller
- DWORD m_ChildrenEnumerated; // number of children returned during the enumeration operation
-};
-
-class WpdObjectEnumerator
-{
-public:
- WpdObjectEnumerator();
- virtual ~WpdObjectEnumerator();
-
- HRESULT Initialize(_In_ WpdBaseDriver* pBaseDriver);
-
- HRESULT DispatchWpdMessage(_In_ REFPROPERTYKEY Command,
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnStartFind(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnFindNext(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnEndFind(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
-private:
- WpdBaseDriver* m_pBaseDriver;
-
- VOID InitializeEnumerationContext(
- _In_ WpdObjectEnumeratorContext* pEnumeratorContext,
- _In_ LPCWSTR wszParentObjectID);
-
- HRESULT AddStringValueToPropVariantCollection(
- _In_ IPortableDevicePropVariantCollection* pCollection,
- _In_ LPCWSTR wszValue);
-};
diff --git a/wpd/WpdBasicHardwareDriver/WpdObjectProperties.cpp b/wpd/WpdBasicHardwareDriver/WpdObjectProperties.cpp
deleted file mode 100644
index 927b8a19..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdObjectProperties.cpp
+++ /dev/null
@@ -1,1314 +0,0 @@
-#include "stdafx.h"
-
-#include "WpdObjectProperties.tmh"
-
-const PROPERTYKEY g_SupportedCommonProperties[] =
-{
- WPD_OBJECT_ID,
- WPD_OBJECT_PERSISTENT_UNIQUE_ID,
- WPD_OBJECT_PARENT_ID,
- WPD_OBJECT_NAME,
- WPD_OBJECT_FORMAT,
- WPD_OBJECT_CONTENT_TYPE,
- WPD_OBJECT_CAN_DELETE,
-};
-
-const PROPERTYKEY g_SupportedDeviceProperties[] =
-{
- WPD_DEVICE_FIRMWARE_VERSION,
- WPD_DEVICE_POWER_LEVEL,
- WPD_DEVICE_POWER_SOURCE,
- WPD_DEVICE_PROTOCOL,
- WPD_DEVICE_MODEL,
- WPD_DEVICE_SERIAL_NUMBER,
- WPD_DEVICE_SUPPORTS_NON_CONSUMABLE,
- WPD_DEVICE_MANUFACTURER,
- WPD_DEVICE_FRIENDLY_NAME,
- WPD_DEVICE_TYPE,
- WPD_FUNCTIONAL_OBJECT_CATEGORY,
-};
-
-const PROPERTYKEY g_SupportedSensorProperties[] =
-{
- SENSOR_READING,
- SENSOR_UPDATE_INTERVAL,
- WPD_FUNCTIONAL_OBJECT_CATEGORY,
-};
-
-
-WpdObjectProperties::WpdObjectProperties() :
- m_dwUpdateInterval(0),
- m_llSensorReading(0)
-{
-
-}
-
-WpdObjectProperties::~WpdObjectProperties()
-{
- m_pBaseDriver = NULL;
-}
-
-HRESULT WpdObjectProperties::Initialize(_In_ WpdBaseDriver* pBaseDriver)
-{
- m_pBaseDriver = pBaseDriver;
- return S_OK;
-}
-
-HRESULT WpdObjectProperties::DispatchWpdMessage(
- _In_ REFPROPERTYKEY Command,
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
-
- if (Command.fmtid != WPD_CATEGORY_OBJECT_PROPERTIES)
- {
- hr = E_INVALIDARG;
- CHECK_HR(hr, "This object does not support this command category %ws",CComBSTR(Command.fmtid));
- }
-
- if (hr == S_OK)
- {
- if (IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET_SUPPORTED))
- {
- hr = OnGetSupportedProperties(pParams, pResults);
- CHECK_HR(hr, "Failed to get supported properties");
- }
- else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET))
- {
- hr = OnGetPropertyValues(pParams, pResults);
- if(FAILED(hr))
- {
- CHECK_HR(hr, "Failed to get properties");
- }
- }
- else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET_ALL))
- {
- hr = OnGetAllPropertyValues(pParams, pResults);
- if(FAILED(hr))
- {
- CHECK_HR(hr, "Failed to get all properties");
- }
- }
- else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_SET))
- {
- hr = OnSetPropertyValues(pParams, pResults);
- if(FAILED(hr))
- {
- CHECK_HR(hr, "Failed to set properties");
- }
- }
- else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET_ATTRIBUTES))
- {
- hr = OnGetPropertyAttributes(pParams, pResults);
- if(FAILED(hr))
- {
- CHECK_HR(hr, "Failed to get property attributes");
- }
- }
- else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_DELETE))
- {
- hr = OnDeleteProperties(pParams, pResults);
- if(FAILED(hr))
- {
- CHECK_HR(hr, "Failed to delete properties");
- }
- }
- else
- {
- hr = E_NOTIMPL;
- CHECK_HR(hr, "This object does not support this command id %d", Command.pid);
- }
- }
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_OBJECT_PROPERTIES_GET_SUPPORTED
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID: identifies the object whose supported properties have
- * been requested.
- *
- * - WPD_PROPERTY_OBJECT_PROPERTIES_FILTER: the filter to use when returning supported properties.
- * Since this parameter is optional, it may not exist.
- * ! This driver currently ignores the filter parameter. !
- *
- * The driver should:
- * - Return supported property keys for the specified object in WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS
- */
-HRESULT WpdObjectProperties::OnGetSupportedProperties(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- LPWSTR wszObjectID = NULL;
- CComPtr<IPortableDeviceKeyCollection> pKeys;
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the object identifier whose supported properties have been requested
- hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID, &wszObjectID);
- if (hr != S_OK)
- {
- hr = E_INVALIDARG;
- CHECK_HR(hr, "Missing string value for WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID");
- }
-
- // CoCreate a collection to store the supported property keys.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceKeyCollection,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceKeyCollection,
- (VOID**) &pKeys);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceKeyCollection");
- }
-
- // Add supported property keys for the specified object to the collection
- if (hr == S_OK)
- {
- hr = AddSupportedPropertyKeys(wszObjectID, pKeys);
- CHECK_HR(hr, "Failed to add supported property keys for object '%ws'", wszObjectID);
- }
-
- // Set the WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS value in the results.
- if (hr == S_OK)
- {
- hr = pResults->SetIPortableDeviceKeyCollectionValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS, pKeys);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS");
- }
-
- // Free the memory.
- CoTaskMemFree(wszObjectID);
- wszObjectID = NULL;
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_OBJECT_PROPERTIES_GET
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID: identifies the object whose property values have been requested.
- * - WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS: a collection of property keys, identifying which
- * specific property values we are requested to return.
- *
- * The driver should:
- * - Return all requested property values in WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES. If any property read failed, the corresponding value should be
- * set to type VT_ERROR with the 'scode' member holding the HRESULT reason for the failure.
- * - S_OK should be returned if all properties were read successfully.
- * - S_FALSE should be returned if any property read failed.
- * - Any error return indicates that the driver did not fill in any results, and the caller will
- * not attempt to unpack any property values.
- */
-HRESULT WpdObjectProperties::OnGetPropertyValues(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- LPWSTR wszObjectID = NULL;
- CComPtr<IPortableDeviceValues> pValues;
- CComPtr<IPortableDeviceKeyCollection> pKeys;
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the object identifier whose property values have been requested
- if (hr == S_OK)
- {
- hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID, &wszObjectID);
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID");
- }
-
- // Get the list of property keys for the property values the caller wants to retrieve from the specified object
- if (hr == S_OK)
- {
- hr = pParams->GetIPortableDeviceKeyCollectionValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS, &pKeys);
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS");
- }
-
- // CoCreate a collection to store the property values.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**) &pValues);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
- }
-
- // Read the specified properties on the specified object and add the property values to the collection.
- if (hr == S_OK)
- {
- hr = GetPropertyValuesForObject(wszObjectID, pKeys, pValues);
- CHECK_HR(hr, "Failed to get property values for object '%ws'", wszObjectID);
- }
-
- // S_OK or S_FALSE can be returned from GetPropertyValuesForObject( ).
- // S_FALSE means that 1 or more property values could not be retrieved successfully.
- // The value for the specified property should be set to an error HRESULT of
- // the reason why the property could not be read.
- // (e.g. If the property being requested is not supported on the object then an error of
- // HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) should be set as the value.
- if (SUCCEEDED(hr))
- {
- // Set the WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES value in the results.
- HRESULT hrTemp = S_OK;
- hrTemp = pResults->SetIPortableDeviceValuesValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES, pValues);
- CHECK_HR(hrTemp, ("Failed to set WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES"));
-
- if(FAILED(hrTemp))
- {
- hr = hrTemp;
- }
- }
-
- // Free the memory.
- CoTaskMemFree(wszObjectID);
- wszObjectID = NULL;
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_OBJECT_PROPERTIES_GET_ALL
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID: identifies the object whose property values have been requested.
- *
- * The driver should:
- * - Return all property values in WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES. If any property read failed, the corresponding value should be
- * set to type VT_ERROR with the 'scode' member holding the HRESULT reason for the failure.
- * - S_OK should be returned if all properties were read successfully.
- * - S_FALSE should be returned if any property read failed.
- * - Any error return indicates that the driver did not fill in any results, and the caller will
- * not attempt to unpack any property values.
- */
-HRESULT WpdObjectProperties::OnGetAllPropertyValues(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- LPWSTR wszObjectID = NULL;
- CComPtr<IPortableDeviceValues> pValues;
- CComPtr<IPortableDeviceKeyCollection> pKeys;
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the object identifier whose property values have been requested
- if (hr == S_OK)
- {
- hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID, &wszObjectID);
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID");
- }
-
- // CoCreate a collection to store the property values.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**) &pValues);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
- }
-
- // CoCreate a collection to store the property keys we are going to use
- // to request the property values of.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceKeyCollection,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceKeyCollection,
- (VOID**) &pKeys);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceKeyCollection");
- }
-
- // First we make a request for ALL supported property keys for the specified object.
- // Next, we delegate to our helper function GetPropertyValuesForObject( ) passing
- // the entire property key collection. This will reuse existing implementation
- // in our driver to perform the GetAllPropertyValues operation.
- if (hr == S_OK)
- {
- hr = AddSupportedPropertyKeys(wszObjectID, pKeys);
- CHECK_HR(hr, "Failed to get ALL supported properties for object '%ws'", wszObjectID);
- if (hr == S_OK)
- {
- hr = GetPropertyValuesForObject(wszObjectID, pKeys, pValues);
- CHECK_HR(hr, "Failed to get property values for object '%ws'", wszObjectID);
- }
- }
-
- // S_OK or S_FALSE can be returned from GetPropertyValuesForObject( ).
- // S_FALSE means that 1 or more property values could not be retrieved successfully.
- // The value for the specified property key should be set to the error HRESULT of
- // the reason why the property could not be read.
- // (i.e. an error of HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) if a property value was
- // requested and is not supported by the specified object.)
- if (SUCCEEDED(hr))
- {
- // Set the WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES value in the results
- HRESULT hrTemp = S_OK;
- hrTemp = pResults->SetIPortableDeviceValuesValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES, pValues);
- CHECK_HR(hrTemp, ("Failed to set WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES"));
-
- if(FAILED(hrTemp))
- {
- hr = hrTemp;
- }
- }
-
- // Free the memory.
- CoTaskMemFree(wszObjectID);
- wszObjectID = NULL;
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_OBJECT_PROPERTIES_SET
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID: identifies the object whose property values we want to return.
- * - WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES: an IPortableDeviceValues of values, identifying which
- * specific property values we are requested to write.
- *
- * The driver should:
- * - Write all requested property values. For each property, a write result should be returned in the
- * write result property store.
- * - If any property write failed, the corresponding write result value should be
- * set to type VT_ERROR with the 'scode' member holding the HRESULT reason for the failure.
- * - S_OK should be returned if all properties were written successfully.
- * - S_FALSE should be returned if any property write failed.
- * - Any error return indicates that the driver did not write any results, and the caller will
- * not attempt to unpack any property write results.
- */
-HRESULT WpdObjectProperties::OnSetPropertyValues(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- HRESULT hrResult = S_OK;
- LPWSTR wszObjectID = NULL;
- DWORD cValues = 0;
- CAtlStringW strObjectID;
-
- CComPtr<IPortableDeviceValues> pValues;
- CComPtr<IPortableDeviceValues> pWriteResults;
- CComPtr<IPortableDeviceValues> pEventParams;
-
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the object identifier whose property values are being set
- if (hr == S_OK)
- {
- hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID, &wszObjectID);
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID");
- }
-
- // Get the caller-supplied property values requested to be set on the object
- if (hr == S_OK)
- {
- strObjectID = wszObjectID;
-
- hr = pParams->GetIPortableDeviceValuesValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES, &pValues);
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES");
- }
-
- // CoCreate a collection to store the property set operation results.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**) &pWriteResults);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
- }
-
- // Set the property values on the specified object
- if (hr == S_OK)
- {
- // Since this driver does not support setting any properties, all property set operation
- // results will be set to E_ACCESSDENIED.
- if (hr == S_OK)
- {
- hr = pValues->GetCount(&cValues);
- CHECK_HR(hr, "Failed to get total number of values");
- }
-
- if (hr == S_OK)
- {
- for (DWORD dwIndex = 0; dwIndex < cValues; dwIndex++)
- {
- PROPERTYKEY Key = WPD_PROPERTY_NULL;
- PROPVARIANT Value = {0};
-
- PropVariantInit(&Value);
-
- hr = pValues->GetAt(dwIndex, &Key, &Value);
- CHECK_HR(hr, "Failed to get PROPERTYKEY at index %d", dwIndex);
-
- if (hr == S_OK)
- {
- // TODO: Add other ...OBJECT_ID strings where applicable
- if (
- (strObjectID.CompareNoCase(SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(TEMP_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(FLEX_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(PIR_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(PING_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(QTI_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(MEMSIC_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(HITACHI_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(PIEZO_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(COMPASS_SENSOR_OBJECT_ID) == 0)
- )
- {
- if (IsEqualPropertyKey(Key, SENSOR_UPDATE_INTERVAL))
- {
- if (Value.vt == VT_UI4)
- {
- hr = SendUpdateIntervalToDevice(Value.ulVal);
- CHECK_HR(hr, "Failed to send the new SENSOR_UPDATE_INTERVAL %d on the device", Value.ulVal);
- }
- else
- {
- // property failed to be set as it is an invalid vartype
- hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
- CHECK_HR(hr, "Failed to update the SENSOR_UPDATE_INTERVAL because the vartype is invalid. Expected VT_UI4, got %d", Value.vt);
- }
-
- // An error has occurred, set the overall result to S_FALSE
- if (hr != S_OK)
- {
- hrResult = S_FALSE;
- }
-
- hr = pWriteResults->SetErrorValue(Key, hr);
- CHECK_HR(hr, "Failed to set error result value of SENSOR_UPDATE_INTERVAL for '%ws'", wszObjectID);
- }
- else
- {
- // Other properties for the sensor object are read only
- hr = pWriteResults->SetErrorValue(Key, E_ACCESSDENIED);
- CHECK_HR(hr, "Failed to set error result value at index %d for '%ws'", dwIndex, wszObjectID);
- hrResult = S_FALSE;
- }
- }
- else
- {
- // Properties for all other objects are read only
- hr = pWriteResults->SetErrorValue(Key, E_ACCESSDENIED);
- CHECK_HR(hr, "Failed to set error result value at index %d for '%ws'", dwIndex, wszObjectID);
- hrResult = S_FALSE;
- }
- }
-
- PropVariantClear(&Value);
-
- } // end for
- } // end if
- }
-
- // At least one property failed to be set
- if (hrResult != S_OK)
- {
- hr = hrResult;
- }
-
- if (SUCCEEDED(hr))
- {
- // Set the WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_WRITE_RESULTS value in the results
- HRESULT hrTemp = pResults->SetIPortableDeviceValuesValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_WRITE_RESULTS, pWriteResults);
- CHECK_HR(hrTemp, ("Failed to set WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_WRITE_RESULTS"));
-
- // Don't override the S_FALSE hresult that indicates at least one property had failed
- if (hr == S_OK)
- {
- hr = hrTemp;
- }
- }
-
- // Free the memory.
- CoTaskMemFree(wszObjectID);
- wszObjectID = NULL;
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_OBJECT_PROPERTIES_GET_ATTRIBUTES
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID: identifies the object whose property attributes we want to return.
- * - WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS: a collection of property keys containing a single value,
- * which is the key identifying the specific property attributes we are requested to return.
- *
- * The driver should:
- * - Return the requested property attributes. If any property attributes failed to be retrieved,
- * the corresponding value should be set to type VT_ERROR with the 'scode' member holding the
- * HRESULT reason for the failure.
- * - S_OK should be returned if all property attributes were read successfully.
- * - S_FALSE should be returned if any property attribute failed.
- * - Any error return indicates that the driver did not fill in any results, and the caller will
- * not attempt to unpack any property values.
- */
-HRESULT WpdObjectProperties::OnGetPropertyAttributes(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = S_OK;
- LPWSTR wszObjectID = NULL;
- PROPERTYKEY Key = WPD_PROPERTY_NULL;
- CComPtr<IPortableDeviceValues> pAttributes;
-
- // First get ALL parameters for this command. If we cannot get ALL parameters
- // then E_INVALIDARG should be returned and no further processing should occur.
-
- // Get the object identifier whose property attributes have been requested
- if (hr == S_OK)
- {
- hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID, &wszObjectID);
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID");
- }
-
- // Get the list of property keys whose attributes are being requested
- if (hr == S_OK)
- {
- hr = pParams->GetKeyValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS, &Key);
- CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS");
- }
-
- // CoCreate a collection to store the property attributes.
- if (hr == S_OK)
- {
- hr = CoCreateInstance(CLSID_PortableDeviceValues,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IPortableDeviceValues,
- (VOID**) &pAttributes);
- CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
- }
-
- // Get the attributes for the specified properties on the specified object and add them
- // to the collection.
- if (hr == S_OK)
- {
- hr = GetPropertyAttributesForObject(wszObjectID, Key, pAttributes);
- CHECK_HR(hr, "Failed to get property attributes");
- }
-
- if (SUCCEEDED(hr))
- {
- // Set the WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_ATTRIBUTES value in the results
- HRESULT hrTemp = S_OK;
- hrTemp = pResults->SetIPortableDeviceValuesValue(WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_ATTRIBUTES, pAttributes);
- CHECK_HR(hrTemp, ("Failed to set WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_ATTRIBUTES"));
-
- if(FAILED(hrTemp))
- {
- hr = hrTemp;
- }
- }
-
- // Free the memory.
- CoTaskMemFree(wszObjectID);
- wszObjectID = NULL;
-
- return hr;
-}
-
-/**
- * This method is called when we receive a WPD_COMMAND_OBJECT_PROPERTIES_DELETE
- * command.
- *
- * The parameters sent to us are:
- * - WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID: identifies the object whose properties should be deleted.
- * - WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS: a collection of property keys indicating which
- * properties to delete.
- *
- * The driver should:
- * - Delete the specified properties from the object.
- * - S_OK should be returned if all specified properties were successfully deleted.
- * - E_ACCESSDENIED should be returned if the client attempts to delete a property which is not deletable (i.e.
- * WPD_PROPERTY_ATTRIBUTE_CAN_DELETE is FALSE for that property.)
- */
-HRESULT WpdObjectProperties::OnDeleteProperties(
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults)
-{
- HRESULT hr = E_ACCESSDENIED;
-
- UNREFERENCED_PARAMETER(pParams);
- UNREFERENCED_PARAMETER(pResults);
-
- // This driver has no properties which can be deleted.
-
- return hr;
-}
-
-/**
- * This method is called to populate supported PROPERTYKEYs found on objects.
- *
- * The parameters sent to us are:
- * wszObjectID - the object whose supported property keys are being requested
- * pKeys - An IPortableDeviceKeyCollection to be populated with supported PROPERTYKEYs
- *
- * The driver should:
- * Add PROPERTYKEYs pertaining to the specified object.
- */
-HRESULT AddSupportedPropertyKeys(
- _In_ LPCWSTR wszObjectID,
- _In_ IPortableDeviceKeyCollection* pKeys)
-{
- HRESULT hr = S_OK;
- CAtlStringW strObjectID = wszObjectID;
-
- // Add Common PROPERTYKEYs for ALL WPD objects
- AddCommonPropertyKeys(pKeys);
-
- if (strObjectID.CompareNoCase(WPD_DEVICE_OBJECT_ID) == 0)
- {
- // Add the PROPERTYKEYs for the 'DEVICE' object
- AddDevicePropertyKeys(pKeys);
- }
-
- // Add other PROPERTYKEYs for other supported objects...
- // TODO: Add comparison to other ..._OBJECT_IDs where applicable
- if (
- (strObjectID.CompareNoCase(SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(TEMP_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(FLEX_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(PIR_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(PING_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(QTI_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(MEMSIC_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(HITACHI_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(PIEZO_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(COMPASS_SENSOR_OBJECT_ID) == 0)
- )
- {
- // Add the PROPERTYKEYs for the Sensor object
- AddSensorPropertyKeys(pKeys);
- }
-
-
-
- return hr;
-}
-
-/**
- * This method is called to populate common PROPERTYKEYs found on ALL objects.
- *
- * The parameters sent to us are:
- * pKeys - An IPortableDeviceKeyCollection to be populated with PROPERTYKEYs
- *
- * The driver should:
- * Add PROPERTYKEYs pertaining to the ALL objects.
- */
-VOID AddCommonPropertyKeys(
- _In_ IPortableDeviceKeyCollection* pKeys)
-{
- if (pKeys != NULL)
- {
- for (DWORD dwIndex = 0; dwIndex < ARRAYSIZE(g_SupportedCommonProperties); dwIndex++)
- {
- HRESULT hr = S_OK;
- hr = pKeys->Add(g_SupportedCommonProperties[dwIndex] );
- CHECK_HR(hr, "Failed to add common property");
- }
- }
-}
-
-/**
- * This method is called to populate PROPERTYKEYs found on the SENSOR object.
- *
- * The parameters sent to us are:
- * pKeys - An IPortableDeviceKeyCollection to be populated with PROPERTYKEYs
- *
- * The driver should:
- * Add PROPERTYKEYs pertaining to the DEVICE object.
- */
-VOID AddSensorPropertyKeys(
- _In_ IPortableDeviceKeyCollection* pKeys)
-{
- if (pKeys != NULL)
- {
- for (DWORD dwIndex = 0; dwIndex < ARRAYSIZE(g_SupportedSensorProperties); dwIndex++)
- {
- HRESULT hr = S_OK;
- hr = pKeys->Add(g_SupportedSensorProperties[dwIndex] );
- CHECK_HR(hr, "Failed to add sensor property");
- }
- }
-}
-
-/**
- * This method is called to populate common PROPERTYKEYs found on the DEVICE object.
- *
- * The parameters sent to us are:
- * pKeys - An IPortableDeviceKeyCollection to be populated with PROPERTYKEYs
- *
- * The driver should:
- * Add PROPERTYKEYs pertaining to the DEVICE object.
- */
-VOID AddDevicePropertyKeys(
- _In_ IPortableDeviceKeyCollection* pKeys)
-{
- if (pKeys != NULL)
- {
- for (DWORD dwIndex = 0; dwIndex < ARRAYSIZE(g_SupportedDeviceProperties); dwIndex++)
- {
- HRESULT hr = S_OK;
- hr = pKeys->Add(g_SupportedDeviceProperties[dwIndex] );
- CHECK_HR(hr, "Failed to add device property");
- }
- }
-}
-
-
-/**
- * This method is called to populate property values for the object specified.
- *
- * The parameters sent to us are:
- * wszObjectID - the object whose properties are being requested.
- * pKeys - the list of property keys of the properties to request from the object
- * pValues - an IPortableDeviceValues which will contain the property values retreived from the object
- *
- * The driver should:
- * Read the specified properties for the specified object and populate pValues with the
- * results.
- */
-HRESULT WpdObjectProperties::GetPropertyValuesForObject(
- _In_ LPCWSTR wszObjectID,
- _In_ IPortableDeviceKeyCollection* pKeys,
- _In_ IPortableDeviceValues* pValues)
-{
- HRESULT hr = S_OK;
- CAtlStringW strObjectID = wszObjectID;
- DWORD cKeys = 0;
-
- if ((wszObjectID == NULL) ||
- (pKeys == NULL) ||
- (pValues == NULL))
- {
- hr = E_INVALIDARG;
- return hr;
- }
-
- hr = pKeys->GetCount(&cKeys);
- CHECK_HR(hr, "Failed to number of PROPERTYKEYs in collection");
-
- if (hr == S_OK)
- {
- // Get values for the DEVICE object
- if (strObjectID.CompareNoCase(WPD_DEVICE_OBJECT_ID) == 0)
- {
- for (DWORD dwIndex = 0; dwIndex < cKeys; dwIndex++)
- {
- PROPERTYKEY Key = WPD_PROPERTY_NULL;
- hr = pKeys->GetAt(dwIndex, &Key);
- CHECK_HR(hr, "Failed to get PROPERTYKEY at index %d in collection", dwIndex);
-
- if (hr == S_OK)
- {
- // Preset the property value to 'error not supported'. The actual value
- // will replace this value, if read from the device.
- pValues->SetErrorValue(Key, HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED));
-
- // Set DEVICE object properties
- if (IsEqualPropertyKey(Key, WPD_DEVICE_FIRMWARE_VERSION))
- {
- hr = pValues->SetStringValue(WPD_DEVICE_FIRMWARE_VERSION, DEVICE_FIRMWARE_VERSION_VALUE);
- CHECK_HR(hr, "Failed to set WPD_DEVICE_FIRMWARE_VERSION");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_DEVICE_POWER_LEVEL))
- {
- hr = pValues->SetUnsignedIntegerValue(WPD_DEVICE_POWER_LEVEL, DEVICE_POWER_LEVEL_VALUE);
- CHECK_HR(hr, "Failed to set WPD_DEVICE_POWER_LEVEL");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_DEVICE_POWER_SOURCE))
- {
- hr = pValues->SetUnsignedIntegerValue(WPD_DEVICE_POWER_SOURCE, WPD_POWER_SOURCE_EXTERNAL);
- CHECK_HR(hr, "Failed to set WPD_DEVICE_POWER_SOURCE");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_DEVICE_PROTOCOL))
- {
- hr = pValues->SetStringValue(WPD_DEVICE_PROTOCOL, DEVICE_PROTOCOL_VALUE);
- CHECK_HR(hr, "Failed to set WPD_DEVICE_PROTOCOL");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_DEVICE_MODEL))
- {
- hr = pValues->SetStringValue(WPD_DEVICE_MODEL, DEVICE_MODEL_VALUE);
- CHECK_HR(hr, "Failed to set WPD_DEVICE_MODEL");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_DEVICE_SERIAL_NUMBER))
- {
- hr = pValues->SetStringValue(WPD_DEVICE_SERIAL_NUMBER, DEVICE_SERIAL_NUMBER_VALUE);
- CHECK_HR(hr, "Failed to set WPD_DEVICE_SERIAL_NUMBER");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_DEVICE_SUPPORTS_NON_CONSUMABLE))
- {
- hr = pValues->SetBoolValue(WPD_DEVICE_SUPPORTS_NON_CONSUMABLE, DEVICE_SUPPORTS_NONCONSUMABLE_VALUE);
- CHECK_HR(hr, "Failed to set WPD_DEVICE_SUPPORTS_NON_CONSUMABLE");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_DEVICE_MANUFACTURER))
- {
- hr = pValues->SetStringValue(WPD_DEVICE_MANUFACTURER, DEVICE_MANUFACTURER_VALUE);
- CHECK_HR(hr, "Failed to set WPD_DEVICE_MANUFACTURER");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_DEVICE_FRIENDLY_NAME))
- {
- hr = pValues->SetStringValue(WPD_DEVICE_FRIENDLY_NAME, DEVICE_FRIENDLY_NAME_VALUE);
- CHECK_HR(hr, "Failed to set WPD_DEVICE_FRIENDLY_NAME");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_DEVICE_TYPE))
- {
- hr = pValues->SetUnsignedIntegerValue(WPD_DEVICE_TYPE, WPD_DEVICE_TYPE_GENERIC);
- CHECK_HR(hr, "Failed to set WPD_DEVICE_TYPE");
- }
-
- // Set general properties for DEVICE
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_ID))
- {
- hr = pValues->SetStringValue(WPD_OBJECT_ID, WPD_DEVICE_OBJECT_ID);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_ID");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_NAME))
- {
- // Retrieves the "DEVICE" string that identifies the root device
- hr = pValues->SetStringValue(WPD_OBJECT_NAME, WPD_DEVICE_OBJECT_ID);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_NAME");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_PERSISTENT_UNIQUE_ID))
- {
- hr = pValues->SetStringValue(WPD_OBJECT_PERSISTENT_UNIQUE_ID, WPD_DEVICE_OBJECT_ID);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_PERSISTENT_UNIQUE_ID");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_PARENT_ID))
- {
- hr = pValues->SetStringValue(WPD_OBJECT_PARENT_ID, L"");
- CHECK_HR(hr, "Failed to set WPD_OBJECT_PARENT_ID");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_FORMAT))
- {
- hr = pValues->SetGuidValue(WPD_OBJECT_FORMAT, WPD_OBJECT_FORMAT_UNSPECIFIED);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_FORMAT");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_CONTENT_TYPE))
- {
- hr = pValues->SetGuidValue(WPD_OBJECT_CONTENT_TYPE, WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_CONTENT_TYPE");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_CAN_DELETE))
- {
- hr = pValues->SetBoolValue(WPD_OBJECT_CAN_DELETE, FALSE);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_CAN_DELETE");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_FUNCTIONAL_OBJECT_CATEGORY))
- {
- hr = pValues->SetGuidValue(WPD_FUNCTIONAL_OBJECT_CATEGORY, WPD_FUNCTIONAL_CATEGORY_DEVICE);
- CHECK_HR(hr, "Failed to set WPD_FUNCTIONAL_OBJECT_CATEGORY");
- }
- }
- }
- }
- // Retrieve the temperature sensor properties
- else if (
- (strObjectID.CompareNoCase(SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(TEMP_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(FLEX_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(PIR_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(PING_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(QTI_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(MEMSIC_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(HITACHI_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(PIEZO_SENSOR_OBJECT_ID) == 0) ||
- (strObjectID.CompareNoCase(COMPASS_SENSOR_OBJECT_ID) == 0)
- )
- {
- for (DWORD dwIndex = 0; dwIndex < cKeys; dwIndex++)
- {
- PROPERTYKEY Key = WPD_PROPERTY_NULL;
- hr = pKeys->GetAt(dwIndex, &Key);
- CHECK_HR(hr, "Failed to get PROPERTYKEY at index %d in collection", dwIndex);
-
- if (hr == S_OK)
- {
- // Preset the property value to 'error not supported'. The actual value
- // will replace this value, if read from the device.
- pValues->SetErrorValue(Key, HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED));
- if (IsEqualPropertyKey(Key, WPD_OBJECT_ID))
- {
- hr = pValues->SetStringValue(WPD_OBJECT_ID, strObjectID);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_ID");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_PERSISTENT_UNIQUE_ID))
- {
-
- // Retrieve the ID of the sensor using the m_SensorType member of the
- // basedriver that is set during the data-read operation.
- hr = pValues->SetStringValue(WPD_OBJECT_PERSISTENT_UNIQUE_ID, strObjectID);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_PERSISTENT_UNIQUE_ID");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_PARENT_ID))
- {
- hr = pValues->SetStringValue(WPD_OBJECT_PARENT_ID, WPD_DEVICE_OBJECT_ID);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_PARENT_ID");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_NAME))
- {
- // Retrieve the name of the sensor using the m_SensorType member of the
- // basedriver that is set during the data-read operation.
- if (m_pBaseDriver->m_SensorType == 0)
- hr = pValues->SetStringValue(WPD_OBJECT_NAME, SENSOR_OBJECT_NAME_VALUE);
- else if (m_pBaseDriver->m_SensorType == 2)
- hr = pValues->SetStringValue(WPD_OBJECT_NAME, TEMP_SENSOR_OBJECT_NAME_VALUE);
- else if (m_pBaseDriver->m_SensorType == 3)
- hr = pValues->SetStringValue(WPD_OBJECT_NAME, FLEX_SENSOR_OBJECT_NAME_VALUE);
- else if (m_pBaseDriver->m_SensorType == 4)
- hr = pValues->SetStringValue(WPD_OBJECT_NAME, PING_SENSOR_OBJECT_NAME_VALUE);
- else if (m_pBaseDriver->m_SensorType == 5)
- hr = pValues->SetStringValue(WPD_OBJECT_NAME, PIR_SENSOR_OBJECT_NAME_VALUE);
- else if (m_pBaseDriver->m_SensorType == 6)
- hr = pValues->SetStringValue(WPD_OBJECT_NAME, MEMSIC_SENSOR_OBJECT_NAME_VALUE);
- else if (m_pBaseDriver->m_SensorType == 7)
- hr = pValues->SetStringValue(WPD_OBJECT_NAME, QTI_SENSOR_OBJECT_NAME_VALUE);
- else if (m_pBaseDriver->m_SensorType == 8)
- hr = pValues->SetStringValue(WPD_OBJECT_NAME, PIEZO_SENSOR_OBJECT_NAME_VALUE);
- else if (m_pBaseDriver->m_SensorType == 9)
- hr = pValues->SetStringValue(WPD_OBJECT_NAME, HITACHI_SENSOR_OBJECT_NAME_VALUE);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_NAME");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_FORMAT))
- {
- hr = pValues->SetGuidValue(WPD_OBJECT_FORMAT, WPD_OBJECT_FORMAT_UNSPECIFIED);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_FORMAT");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_CONTENT_TYPE))
- {
- hr = pValues->SetGuidValue(WPD_OBJECT_CONTENT_TYPE, WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_CONTENT_TYPE");
- }
-
- else if (IsEqualPropertyKey(Key, WPD_OBJECT_CAN_DELETE))
- {
- hr = pValues->SetBoolValue(WPD_OBJECT_CAN_DELETE, FALSE);
- CHECK_HR(hr, "Failed to set WPD_OBJECT_CAN_DELETE");
- }
-
- else if (IsEqualPropertyKey(Key, SENSOR_READING))
- {
- hr = pValues->SetUnsignedLargeIntegerValue(SENSOR_READING, GetSensorReading());
- CHECK_HR(hr, "Failed to set SENSOR_READING");
- }
-
- else if (IsEqualPropertyKey(Key, SENSOR_UPDATE_INTERVAL))
- {
- hr = pValues->SetUnsignedLargeIntegerValue(SENSOR_UPDATE_INTERVAL, GetUpdateInterval());
- CHECK_HR(hr, "Failed to set SENSOR_UPDATE_INTERVAL");
- }
- else if (IsEqualPropertyKey(Key, WPD_FUNCTIONAL_OBJECT_CATEGORY))
- {
- hr = pValues->SetGuidValue(WPD_FUNCTIONAL_OBJECT_CATEGORY, FUNCTIONAL_CATEGORY_SENSOR_SAMPLE);
- CHECK_HR(hr, "Failed to set WPD_FUNCTIONAL_OBJECT_CATEGORY");
- }
- }
- } // end for
- } // end else if
- }
-
- return hr;
-}
-
-/**
- * This method is called to populate property attributes for the object and property specified.
- *
- * The parameters sent to us are:
- * wszObjectID - the object whose property attributes are being requested.
- * Key - the property whose attributes are being requested
- * pAttributes - an IPortableDeviceValues which will contain the resulting property attributes
- *
- * The driver should:
- * Read the property attributes for the specified property on the specified object and
- * populate pAttributes with the results.
- */
-HRESULT WpdObjectProperties::GetPropertyAttributesForObject(
- _In_ LPCWSTR wszObjectID,
- _In_ REFPROPERTYKEY Key,
- _In_ IPortableDeviceValues* pAttributes)
-{
- HRESULT hr = S_OK;
-
- if ((wszObjectID == NULL) ||
- (pAttributes == NULL))
- {
- hr = E_INVALIDARG;
- return hr;
- }
-
- //
- // Since ALL of our properties have the same attributes, we are ignoring the
- // passed in wszObjectID parameter. This parameter allows you to
- // customize attributes for properties on specific objects. (i.e. WPD_OBJECT_ORIGINAL_FILE_NAME
- // may be READ/WRITE on some objects and READONLY on others. )
- //
-
- if (hr == S_OK)
- {
- hr = pAttributes->SetBoolValue(WPD_PROPERTY_ATTRIBUTE_CAN_DELETE, FALSE);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_CAN_DELETE");
- }
-
- if (hr == S_OK)
- {
- hr = pAttributes->SetBoolValue(WPD_PROPERTY_ATTRIBUTE_CAN_READ, TRUE);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_CAN_READ");
- }
-
- if (hr == S_OK)
- {
- // Allow writes for the update interval property
- if (IsEqualPropertyKey(Key, SENSOR_UPDATE_INTERVAL))
- {
- hr = pAttributes->SetBoolValue(WPD_PROPERTY_ATTRIBUTE_CAN_WRITE, TRUE);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_CAN_WRITE for SENSOR_UPDATE_INTERVAL");
- }
- else
- {
- hr = pAttributes->SetBoolValue(WPD_PROPERTY_ATTRIBUTE_CAN_WRITE, FALSE);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_CAN_WRITE");
- }
- }
-
- if (hr == S_OK)
- {
- hr = pAttributes->SetBoolValue(WPD_PROPERTY_ATTRIBUTE_FAST_PROPERTY, TRUE);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_FAST_PROPERTY");
- }
-
- if (hr == S_OK)
- {
- if (IsEqualPropertyKey(Key, SENSOR_UPDATE_INTERVAL))
- {
- // Form range attributes for the update interval property
- hr = pAttributes->SetUnsignedIntegerValue(WPD_PROPERTY_ATTRIBUTE_FORM, WPD_PROPERTY_ATTRIBUTE_FORM_RANGE);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_RANGE_MIN for SENSOR_UPDATE_INTERVAL");
-
- hr = pAttributes->SetUnsignedIntegerValue(WPD_PROPERTY_ATTRIBUTE_RANGE_MIN, SENSOR_UPDATE_INTERVAL_MIN);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_RANGE_MIN for SENSOR_UPDATE_INTERVAL");
-
- hr = pAttributes->SetUnsignedIntegerValue(WPD_PROPERTY_ATTRIBUTE_RANGE_MAX, SENSOR_UPDATE_INTERVAL_MAX);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_RANGE_MAX for SENSOR_UPDATE_INTERVAL");
-
- hr = pAttributes->SetUnsignedIntegerValue(WPD_PROPERTY_ATTRIBUTE_RANGE_STEP, SENSOR_UPDATE_INTERVAL_STEP);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_RANGE_STEP for SENSOR_UPDATE_INTERVAL");
- }
- else if (IsEqualPropertyKey(Key, SENSOR_READING))
- {
- // Form range attributes for the reading property
- hr = pAttributes->SetUnsignedIntegerValue(WPD_PROPERTY_ATTRIBUTE_FORM, WPD_PROPERTY_ATTRIBUTE_FORM_RANGE);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_RANGE_MIN for SENSOR_READING");
-
- hr = pAttributes->SetUnsignedIntegerValue(WPD_PROPERTY_ATTRIBUTE_RANGE_MIN, SENSOR_READING_MIN);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_RANGE_MIN for SENSOR_READING");
-
- hr = pAttributes->SetUnsignedIntegerValue(WPD_PROPERTY_ATTRIBUTE_RANGE_MAX, SENSOR_READING_MAX);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_RANGE_MAX for SENSOR_READING");
-
- hr = pAttributes->SetUnsignedIntegerValue(WPD_PROPERTY_ATTRIBUTE_RANGE_STEP, SENSOR_READING_STEP);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_RANGE_STEP for SENSOR_READING");
- }
- else
- {
- hr = pAttributes->SetUnsignedIntegerValue(WPD_PROPERTY_ATTRIBUTE_FORM, WPD_PROPERTY_ATTRIBUTE_FORM_UNSPECIFIED);
- CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_FORM");
- }
- }
-
- return hr;
-}
-
-
-/**
- * This method is called to update the sensor reading
- *
- * The parameters sent to us are:
- * dwNewReading - the temperature reading to set
- *
- * The driver should:
- * Update the sensor reading.
- */
-VOID WpdObjectProperties::SetSensorReading(LONGLONG llNewReading)
-{
- // Ensure that this value isn't currently being accessed by another thread
- CComCritSecLock<CComAutoCriticalSection> Lock(m_SensorReadingCriticalSection);
-
- m_llSensorReading = llNewReading;
-}
-
-
-/**
- * This method is called to retrieve the sensor reading
- *
- * The parameters sent to us are:
- *
- * The driver should:
- * Return the saved sensor reading.
- */
-LONGLONG WpdObjectProperties::GetSensorReading()
-{
- // Ensure that this value isn't currently being accessed by another thread
- CComCritSecLock<CComAutoCriticalSection> Lock(m_SensorReadingCriticalSection);
-
- return m_llSensorReading;
-}
-
-
-/**
- * This method is called to set the cached sensor interval
- *
- * The parameters sent to us are:
- * dwNewInterval - the sensor update interval to set
- *
- * The driver should:
- * Update the cached sensor interval property.
- */
-VOID WpdObjectProperties::SetUpdateInterval(DWORD dwNewInterval)
-{
- m_dwUpdateInterval = dwNewInterval;
-}
-
-
-/**
- * This method is called to retrieve the sensor update interval
- *
- * The parameters sent to us are:
- *
- * The driver should:
- * Return the interval property.
- */
-DWORD WpdObjectProperties::GetUpdateInterval()
-{
- return m_dwUpdateInterval;
-}
-
-
-/**
- * This method is called to update the sensor interval on the device
- *
- * The parameters sent to us are:
- * dwNewInterval - the sensor update interval to set
- *
- * The driver should:
- * Update the cached sensor property and send a write request to the device
- */
-HRESULT WpdObjectProperties::SendUpdateIntervalToDevice(DWORD dwNewInterval)
-{
- HRESULT hr = S_OK;
- RS232Target* pDeviceTarget = NULL;
-
- CHAR szInterval[INTERVAL_DATA_LENGTH+1] = {0};
-
- // Check the input value
- if (IsValidUpdateInterval(dwNewInterval) == FALSE)
- {
- hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
- CHECK_HR(hr, "Invalid update interval: %d", dwNewInterval);
- }
-
- // Format a write request with the input value
- if (hr == S_OK)
- {
- hr = StringCchPrintfA(szInterval, ARRAYSIZE(szInterval), "%u", dwNewInterval);
- CHECK_HR(hr, "Failed to convert the new interval to a CHAR string");
- }
-
- // Send the write request to the device
- if (hr == S_OK)
- {
- pDeviceTarget = m_pBaseDriver->GetRS232Target();
-
- if (pDeviceTarget->IsReady())
- {
- hr = pDeviceTarget->SendWriteRequest((BYTE *)szInterval, sizeof(szInterval));
- CHECK_HR(hr, "Failed to send the write request to set the new sensor update interval");
-
- if (hr == S_OK)
- {
- TraceEvents(TRACE_LEVEL_VERBOSE, TRACE_FLAG_DRIVER, "%!FUNC! Sent new interval: %s", szInterval);
- }
- }
- else
- {
- hr = HRESULT_FROM_WIN32(ERROR_NOT_READY);
- CHECK_HR(hr, "Device is not ready to receive write requests");
- }
- }
-
- if (hr == S_OK)
- {
- // Update the cached value on the driver
- SetUpdateInterval(dwNewInterval);
- }
-
- return hr;
-}
-
-
-/**
- * This method is called to check that interval value falls within the accepted range
- * of 2000 to 60000 milliseconds
- *
- * The parameters sent to us are:
- * wszInterval - the sensor update interval to check
- *
- * The driver should:
- * Return TRUE if the interval is within range
- */
-BOOL WpdObjectProperties::IsValidUpdateInterval(DWORD dwInterval)
-{
- if ((dwInterval >= SENSOR_UPDATE_INTERVAL_MIN) &&
- (dwInterval <= SENSOR_UPDATE_INTERVAL_MAX))
- {
- return TRUE;
- }
-
- return FALSE;
-}
-
diff --git a/wpd/WpdBasicHardwareDriver/WpdObjectProperties.h b/wpd/WpdBasicHardwareDriver/WpdObjectProperties.h
deleted file mode 100644
index 1860e0ad..00000000
--- a/wpd/WpdBasicHardwareDriver/WpdObjectProperties.h
+++ /dev/null
@@ -1,111 +0,0 @@
-#pragma once
-
-#define DEVICE_PROTOCOL_VALUE L"Sensor Protocol ver 1.00"
-#define DEVICE_FIRMWARE_VERSION_VALUE L"1.0.0.0"
-#define DEVICE_POWER_LEVEL_VALUE 100
-#define DEVICE_MODEL_VALUE L"RS232 Sensor"
-#define DEVICE_FRIENDLY_NAME_VALUE L"Parallax BS2 Sensor"
-#define DEVICE_MANUFACTURER_VALUE L"Windows Portable Devices Group"
-#define DEVICE_SERIAL_NUMBER_VALUE L"01234567890123-45676890123456"
-#define DEVICE_SUPPORTS_NONCONSUMABLE_VALUE FALSE
-
-#define SENSOR_OBJECT_ID L"Sensor"
-#define SENSOR_OBJECT_NAME_VALUE L"Parallax Sensor"
-#define COMPASS_SENSOR_OBJECT_ID L"Compass"
-#define COMPASS_SENSOR_OBJECT_NAME_VALUE L"HM55B Compass Sensor"
-#define PIR_SENSOR_OBJECT_ID L"PIR"
-#define PIR_SENSOR_OBJECT_NAME_VALUE L"Passive Infra-Red Sensor"
-#define QTI_SENSOR_OBJECT_ID L"QTI"
-#define QTI_SENSOR_OBJECT_NAME_VALUE L"QTI Light Sensor"
-#define FLEX_SENSOR_OBJECT_ID L"Flex"
-#define FLEX_SENSOR_OBJECT_NAME_VALUE L"Flex Force Sensor"
-#define PING_SENSOR_OBJECT_ID L"Ping"
-#define PING_SENSOR_OBJECT_NAME_VALUE L"Ultrasonic Distance Sensor"
-#define PIEZO_SENSOR_OBJECT_ID L"Piezo"
-#define PIEZO_SENSOR_OBJECT_NAME_VALUE L"Piezo Vibration Sensor"
-#define TEMP_SENSOR_OBJECT_ID L"TempHumidity"
-#define TEMP_SENSOR_OBJECT_NAME_VALUE L"Sensiron Temperature and Humidity Sensor"
-#define MEMSIC_SENSOR_OBJECT_ID L"Memsic"
-#define MEMSIC_SENSOR_OBJECT_NAME_VALUE L"Memsic Dual-Axis G-Force Sensor"
-#define HITACHI_SENSOR_OBJECT_ID L"Hitachi"
-#define HITACHI_SENSOR_OBJECT_NAME_VALUE L"Hitachi Tri-Axis G-Force Sensor"
-// INSERT ID and NAME definitions for other sensors here!!
-
-
-GUID GetObjectFormat(CAtlStringW strObjectID);
-GUID GetObjectContentType(CAtlStringW strObjectID);
-HRESULT AddSupportedPropertyKeys(_In_ LPCWSTR wszObjectID,
- _In_ IPortableDeviceKeyCollection* pKeys);
-
-VOID AddCommonPropertyKeys(_In_ IPortableDeviceKeyCollection* pKeys);
-VOID AddDevicePropertyKeys(_In_ IPortableDeviceKeyCollection* pKeys);
-
-VOID AddSensorPropertyKeys(_In_ IPortableDeviceKeyCollection* pKeys); //Required for sensor props
-
-class WpdObjectProperties
-{
-public:
-
- WpdObjectProperties();
- virtual ~WpdObjectProperties();
-
- HRESULT Initialize(_In_ WpdBaseDriver* pBaseDriver);
-
- HRESULT DispatchWpdMessage(_In_ REFPROPERTYKEY Command,
- _In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnGetSupportedProperties(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnGetPropertyValues(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnGetAllPropertyValues(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnSetPropertyValues(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnGetPropertyAttributes(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- HRESULT OnDeleteProperties(_In_ IPortableDeviceValues* pParams,
- _In_ IPortableDeviceValues* pResults);
-
- VOID SetSensorReading(LONGLONG llNewReading);
-
- LONGLONG GetSensorReading();
-
- VOID SetUpdateInterval(DWORD dwNewInterval);
-
- DWORD GetUpdateInterval();
-
- HRESULT SendUpdateIntervalToDevice(DWORD dwNewInterval);
-
- BOOL IsValidUpdateInterval(DWORD dwInterval);
-
-private:
-
- HRESULT GetPropertyValuesForObject(_In_ LPCWSTR wszObjectID,
- _In_ IPortableDeviceKeyCollection* pKeys,
- _In_ IPortableDeviceValues* pValues);
-
- HRESULT GetPropertyAttributesForObject(_In_ LPCWSTR wszObjectID,
- _In_ REFPROPERTYKEY Key,
- _In_ IPortableDeviceValues* pAttributes);
-
-
-private:
- WpdBaseDriver* m_pBaseDriver;
-
- // This critical section protects the sensor reading from concurrent access
- // by the application (which reads it) and the read request callback (which updates it)
- CComAutoCriticalSection m_SensorReadingCriticalSection;
- LONGLONG m_llSensorReading;
-
- // A critical section is not needed for the update interval because it is accessed
- // by the client application, and set/get requests from the application arrive serially
- // through the sequential WDF queue.
- DWORD m_dwUpdateInterval;
-};
diff --git a/wpd/WpdBasicHardwareDriver/firmware/compass_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/compass_wpd_enabled.bs2
deleted file mode 100644
index 335d2c7e..00000000
--- a/wpd/WpdBasicHardwareDriver/firmware/compass_wpd_enabled.bs2
+++ /dev/null
@@ -1,94 +0,0 @@
-' Compass_wpd_enabled.bs2
-'
-' Displays x (N/S) and y (W/E) axis measurements along with the direction the
-' Compass Module is pointing, measured in degrees clockwise from north.
-'
-' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
-' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-' PARTICULAR PURPOSE.
-'
-' Copyright (c) Microsoft Corporation. All rights reserved
-'
-' {$STAMP BS2}
-' {$PBASIC 2.5}
-' ============================================================================
-
-' -----[ Pins/Constants/Variables ]-------------------------------------------
-DinDout PIN 6 ' P6 transceives to/from Din/Dout
-Clk PIN 5 ' P5 sends pulses to HM55B's Clk
-En PIN 4 ' P4 controls HM55B's /EN(ABLE)
-
-Reset CON %0000 ' Reset command for HM55B
-Measure CON %1000 ' Start measurement command
-Report CON %1100 ' Get status/axis values command
-Ready CON %1100 ' 11 -> Done, 00 -> no errors
-NegMask CON %1111100000000000 ' For 11-bit negative to 16-bits
-
-x VAR Word ' x-axis data
-y VAR Word ' y-axis data
-status VAR Nib ' Status flags
-angle VAR Word ' Store angle measurement
-
-SensorID VAR Byte 'Sensor identifier = 5 for PIR
-ElementSize VAR Byte 'Size (in bytes) of each element
-ElementCount VAR Byte 'Count of elements in packet
-Padding VAR Byte 'Padding for the 8-byte element
-
-SensorID = 1
-ElementSize = 1
-ElementCount = 3 '3-bytes for compass data;
-
-NewInterval VAR Word 'New interval requested by user
-Interval VAR Word 'Interval value utlized by firmware
-
-LFD CON $10 'Linefeed character
-
-Interval = 200 '.20 of a second interval
-NewInterval = 200
-
-' -----[ Main Routine ]-------------------------------------------------------
-
-Main:
- GOSUB PollSensor 'Was motion detected?
- GOSUB RetrieveInterval 'Retrieve units data
-
-' -----[ Subroutines ]--------------------------------------------------------
-
-Timeout:
- SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC3 angle, DEC5 Interval,LFD]
- GOTO Main
-
-PollSensor: ' Compass module subroutine
-
- HIGH En: LOW En ' Send reset command to HM55B
- SHIFTOUT DinDout,clk,MSBFIRST,[Reset\4]
-
- HIGH En: LOW En ' HM55B start measurement command
- SHIFTOUT DinDout,clk,MSBFIRST,[Measure\4]
- status = 0 ' Clear previous status flags
-
- DO ' Status flag checking loop
- HIGH En: LOW En ' Measurement status command
- SHIFTOUT DinDout,clk,MSBFIRST,[Report\4]
- SHIFTIN DinDout,clk,MSBPOST,[Status\4] ' Get Status
- LOOP UNTIL status = Ready ' Exit loop when status is ready
-
- SHIFTIN DinDout,clk,MSBPOST,[x\11,y\11] ' Get x & y axis values
- HIGH En ' Disable module
-
- IF (y.BIT10 = 1) THEN y = y | NegMask ' Store 11-bits as signed word
- IF (x.BIT10 = 1) THEN x = x | NegMask ' Repeat for other axis
-
- angle = x ATN -y ' Convert x and y to brads
- angle = angle */ 360 ' Convert brads to degrees
-
- RETURN
-
-
-RetrieveInterval:
- SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval
- IF NewInterval >= 10 AND NewInterval <= 60000 THEN
- Interval = NewInterval
- ENDIF
- RETURN \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/firmware/flex_force_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/flex_force_wpd_enabled.bs2
deleted file mode 100644
index 9b9e5b2c..00000000
--- a/wpd/WpdBasicHardwareDriver/firmware/flex_force_wpd_enabled.bs2
+++ /dev/null
@@ -1,60 +0,0 @@
-' Flex_force_wpd_enabled.bs2
-'
-' Displays R/C Discharge Time in BASIC Stamp DEBUG Window
-'
-' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
-' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-' PARTICULAR PURPOSE.
-'
-' Copyright (c) Microsoft Corporation. All rights reserved
-'
-' {$STAMP BS2}
-' {$PBASIC 2.5}
-' =========================================================================
-
-' -----[ Declarations ]----------------------------------------------------
-
-rawForce VAR Word ' Stores raw output
-sensorPin CON 15 ' Flexiforce sensor circuit
-
-' -----[ Main Routine ]----------------------------------------------------
-
-SensorID VAR Byte 'Sensor identifier = 5 for PIR
-ElementSize VAR Byte 'Size (in bytes) of each element
-ElementCount VAR Byte 'Count of elements in packet
-Padding VAR Byte 'Padding for the 8-byte element
-
-SensorID = 3
-ElementSize = 1
-ElementCount = 5 '4-bytes for pressure data; 5 for interval
-
-NewInterval VAR Word 'New interval requested by user
-Interval VAR Word 'Interval value utlized by firmware
-
-Interval = 200
-NewInterval = 200
-
-LFD CON $10 'Linefeed character
-
-Main:
-
- GOSUB PollSensor 'Was motion detected?
- GOSUB RetrieveInterval 'Retrieve units data
-
-Timeout:
- SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC5 rawForce, DEC5 Interval, LFD]
- GOTO Main
-
-PollSensor:
- HIGH sensorPin ' Discharge the capacitor
- PAUSE 2
- RCTIME sensorPin,1,rawForce ' Measure RC charge time
- RETURN
-
-RetrieveInterval:
- SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval
- IF NewInterval >= 10 AND NewInterval <= 60000 THEN
- Interval = NewInterval
- ENDIF
- RETURN
diff --git a/wpd/WpdBasicHardwareDriver/firmware/h48c_3-axis_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/h48c_3-axis_wpd_enabled.bs2
deleted file mode 100644
index daba0fc9..00000000
--- a/wpd/WpdBasicHardwareDriver/firmware/h48c_3-axis_wpd_enabled.bs2
+++ /dev/null
@@ -1,175 +0,0 @@
-' h48c_3-axis_wpd_enabled.bs2
-'
-' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
-' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-' PARTICULAR PURPOSE.
-'
-' Copyright (c) Microsoft Corporation. All rights reserved
-'
-' {$STAMP BS2}
-' {$PBASIC 2.5}
-'
-' =========================================================================
-
-' -----[ Program Description ]---------------------------------------------
-'
-' Test program for the H48C 3-Axis Accelerometer module.
-'
-' Connections:
-'
-' +------------+
-' | * |
-' CLK | o o | Vdd (+5v)
-' | +--+ |
-' DIO [ o | | o | CS\
-' | +--+ |
-' Vss | o o | 0G (free-fall indication)
-' | |
-' +------------+
-'
-' How it Works:
-'
-' An onboard MCP3204 12-bit ADC is used to read the VRef, X-, Y-, and
-' Z-axis outputs from the Hitachi H48C accelerometer. The reference
-' voltage output from H48C is 1.65 volts (3.3 / 2).
-'
-' After reading the reference voltage and an output channel the g-force
-' for the channel is calculated with this formula:
-'
-' axis - vref 3.3
-' G = ----------- x ------
-' 4095 0.3663
-'
-' For use in the program the forumla can be simplified to:
-'
-' G = (axis - vref) x 0.0022
-'
-' To allow the display of fractional g-force in the integer system of the
-' BASIC Stamp we multiply 0.0022 by 100 -- this will allow us to display
-' g-force in 0.01g units.
-
-
-
-' -----[ I/O Definitions ]-------------------------------------------------
-
-Dio PIN 15 ' data to/from module
-Clk PIN 14 ' clock output
-CS PIN 13 ' active-low chip select
-
-
-' -----[ Constants ]-------------------------------------------------------
-
-XAxis CON 0 ' adc channels
-YAxis CON 1
-ZAxis CON 2
-VRef CON 3
-
-Cnt2Mv CON $CE4C ' counts to millivolts
- ' 0.80586 with **
-GfCnv CON $3852 ' g-force conversion
- ' 0.22 with **
-
-' -----[ Variables ]-------------------------------------------------------
-
-axis VAR Nib ' axis selection
-rvCount VAR Word ' ref voltage adc counts
-axCount VAR Word ' axis voltage adc counts
-mVolts VAR Word ' millivolts
-Gforce VAR Word ' axis g-force
-
-xGforce VAR Word ' x-axis force
-yGforce VAR Word ' y-axis force
-zGforce VAR Word ' z-axis force
-
-dValue VAR Word ' display value
-dPad VAR Nib ' display pad
-
-' Below lines are WPD additions
-
-SensorID VAR Byte 'Sensor identifier = 9 for Hitachi
-ElementCount VAR Byte 'Count of elements in packet
-ElementSize VAR Byte 'Size (in bytes) of each element
-
-
-NewInterval VAR Word 'New interval requested by user
-Interval VAR Word 'Interval value utlized by firmware
-
-SensorID = 9
-ElementSize = 4 'Each element contains a sign byte, followed by a G-force integer value, followed by a G-force fraction (in hundredths).
-ElementCount = 3 'Each element corresponds to one of the three axis (X, Y, and Z)
-
-Interval = 2000
-NewInterval = 2000
-
-
-' -----[ EEPROM Data ]-----------------------------------------------------
-
-
-' -----[ Initialization ]--------------------------------------------------
-
-Reset:
- HIGH CS ' deselect module
-
-' -----[ Program Code ]----------------------------------------------------
-
-Main:
- GOSUB GetGforces 'Retrieves G-forces along 3 axis
- GOSUB RetrieveInterval 'Retrieves event-interval data
-
- Timeout:
- SEROUT 16, 16780, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC1(xGforce.BIT15), DEC1(ABS xGforce/100),DEC2(ABS xGforce),DEC1(yGforce.BIT15),DEC1(ABS yGforce/100),DEC2(ABS yGforce),DEC1(zGforce.BIT15),DEC1(ABS zGforce/100),DEC2(ABS zGforce),DEC5 Interval ]
- GOTO Main
-
- GOTO Main
-
-
-' -----[ Subroutines ]-----------------------------------------------------
-
-' Retrieves the event-interval property from the WPD driver
-RetrieveInterval:
- SERIN 16, 16780, Interval, Timeout, [DEC NewInterval] 'Retrieve interval
- IF NewInterval >= 10 AND NewInterval <= 60000 THEN
- Interval = NewInterval
- ENDIF
-
-' Retrieves G forces along all three axis
-GetGforces:
- FOR axis = XAxis TO ZAxis ' loop through each axis
- GOSUB Get_H48C ' read vRef & axis counts
- ' calculate g-force
- ' -- "Gforce" is signed word
- IF (axCount >= rvCount) THEN
- Gforce = (axCount - rvCount) ** GfCnv ' positive g-force
- ELSE
- Gforce = -((rvCount - axCount) ** GfCnv) ' negative g-force
- ENDIF
- IF (axis = XAxis) THEN
- xGforce = Gforce
- ENDIF
- IF (axis = YAxis) THEN
- yGforce = Gforce
- ENDIF
- IF (axis = ZAxis) THEN
- zGforce = Gforce
- ENDIF
- NEXT
- RETURN
-
-' Reads VRef and selected H48C axis through an MCP3204 ADC
-' -- pass axis (0 - 2) in "axis"
-' -- returns reference voltage counts in "rvCount"
-' -- returns axis voltage counts in "axCounts"
-
-Get_H48C:
- LOW CS
- SHIFTOUT Dio, Clk, MSBFIRST, [%11\2, VRef\3] ' select vref register
- SHIFTIN Dio, Clk, MSBPOST, [rvCount\13] ' read ref voltage counts
- HIGH CS
- PAUSE 1
- LOW CS
- SHIFTOUT Dio, Clk, MSBFIRST, [%11\2, axis\3] ' select axis
- SHIFTIN Dio, Clk, MSBPOST, [axCount\13] ' read axis voltage counts
- HIGH CS
- RETURN
-
diff --git a/wpd/WpdBasicHardwareDriver/firmware/memsic2125_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/memsic2125_wpd_enabled.bs2
deleted file mode 100644
index 80449357..00000000
--- a/wpd/WpdBasicHardwareDriver/firmware/memsic2125_wpd_enabled.bs2
+++ /dev/null
@@ -1,107 +0,0 @@
-' memsic2125_wpd_enabled.bs2
-'
-' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
-' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-' PARTICULAR PURPOSE.
-'
-' Copyright (c) Microsoft Corporation. All rights reserved
-'
-' {$STAMP BS2}
-' {$PBASIC 2.5}
-'
-' =========================================================================
-
-' -----[ Program Description ]---------------------------------------------
-'
-' Read the pulse outputs from a Memsic 2125 accelerometer and converts to
-' G-force
-'
-' g = ((t1 / 10 ms) - 0.5) / 12.5%
-'
-' www.memsic.com
-
-
-' -----[ Revision History ]------------------------------------------------
-
-
-' -----[ I/O Definitions ]-------------------------------------------------
-
-Xin PIN 8 ' X input from Memsic 2125
-Yin PIN 9 ' Y input from Memsic 2125
-
-
-' -----[ Constants ]-------------------------------------------------------
-
-' Set scale factor for PULSIN
-
-#SELECT $STAMP
- #CASE BS2, BS2E
- Scale CON $200 ' 2.0 us per unit
- #CASE BS2SX
- Scale CON $0CC ' 0.8 us per unit
- #CASE BS2P
- Scale CON $0C0 ' 0.75 us per unit
- #CASE BS2PE
- Scale CON $1E1 ' 1.88 us per unit
-#ENDSELECT
-
-HiPulse CON 1 ' measure high-going pulse
-LoPulse CON 0
-
-' -----[ Variables ]-------------------------------------------------------
-
-xRaw VAR Word ' pulse from Memsic 2125
-xmG VAR Word ' g force (1000ths)
-
-yRaw VAR Word
-ymG VAR Word
-
-'disp VAR Byte ' displacement (0.0 - 0.99)
-
-
-' Below lines are WPD additions
-
-SensorID VAR Byte 'Sensor identifier = 1 for memsic
-ElementSize VAR Byte 'Size (in bytes) of each element
-ElementCount VAR Byte 'Count of elements in packet
-
-NewInterval VAR Word 'New interval requested by user
-Interval VAR Word 'Interval value utlized by firmware
-
-SensorID = 6
-ElementSize = 1
-ElementCount = 6 '6-bytes for g-force
-
-LFD CON $10 'Linefeed character
-
-Interval = 100 '.10 of a second interval
-NewInterval = 100
-
-' -----[ Program Code ]----------------------------------------------------
-
-Main:
- GOSUB Read_G_Force 'reads G-force
- GOSUB RetrieveInterval 'Retrieve units data
-
- Timeout:
- SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC1(xmG.BIT15), DEC1(ABS xmG/1000),DEC1(ABS xmG/10),DEC1(ymG.BIT15),DEC1(ABS ymG/1000),DEC1(ABS ymG/10),DEC5 Interval,LFD]
- GOTO Main
-
-
- RetrieveInterval:
- SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval
- IF NewInterval >= 10 AND NewInterval <= 60000 THEN
- Interval = NewInterval
- ENDIF
-
-' -----[ Subroutines ]-----------------------------------------------------
-
-Read_G_Force:
- PULSIN Xin, HiPulse, xRaw ' read pulse output
- xRaw = xRaw */ Scale ' convert to uSecs
- xmG = ((xRaw / 10) - 500) * 8 ' calc 1/1000 g
- PULSIN Yin, HiPulse, yRaw
- yRaw = yRaw */ Scale
- ymG = ((yRaw / 10) - 500) * 8
- RETURN \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/firmware/piezo_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/piezo_wpd_enabled.bs2
deleted file mode 100644
index ff5a7b55..00000000
--- a/wpd/WpdBasicHardwareDriver/firmware/piezo_wpd_enabled.bs2
+++ /dev/null
@@ -1,55 +0,0 @@
-' Piezo_wpd_enabled.bs2
-'
-' This program demonstrates using the LDT0 as a switch/trigger
-'
-' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
-' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-' PARTICULAR PURPOSE.
-'
-' Copyright (c) Microsoft Corporation. All rights reserved
-'
-' {$STAMP BS2}
-' {$PBASIC 2.5}
-' =========================================================================
-
-SensorID VAR Byte 'Sensor identifier = 8 for piezo
-ElementSize VAR Byte 'Size (in bytes) of each element
-ElementCount VAR Byte 'Count of elements in packet
-bVibration VAR Byte 'Vibration-detection variable (single element for PIR)
-Padding VAR Byte 'Padding for the 8-byte element
-
-SensorID = 8
-ElementSize = 1
-ElementCount = 1 '1-byte for motion data; 5 for interval
-
-NewInterval VAR Word 'New interval requested by user
-Interval VAR Word 'Interval value utlized by firmware
-
-Interval = 500
-NewInterval = 500
-
-LFD CON $10 'Linefeed character
-
-
-' -----[ Program Code ]----------------------------------------------------
-
-Main:
-
- GOSUB PollSensor 'Was motion detected?
- GOSUB RetrieveInterval 'Retrieve units data
-
-Timeout:
- SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC1 bVibration, DEC5 Interval, LFD]
- GOTO Main
-
-PollSensor:
- bVibration = IN0 ' Assign status of P0 to bMotion
- RETURN
-
-RetrieveInterval:
- SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval
- IF NewInterval >= 10 AND NewInterval <= 60000 THEN
- Interval = NewInterval
- ENDIF
- RETURN
diff --git a/wpd/WpdBasicHardwareDriver/firmware/ping_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/ping_wpd_enabled.bs2
deleted file mode 100644
index e2af29a7..00000000
--- a/wpd/WpdBasicHardwareDriver/firmware/ping_wpd_enabled.bs2
+++ /dev/null
@@ -1,57 +0,0 @@
-' Ping_wpd_enabled.bs2
-'
-' Measure distance with Ping))) sensor and display in both in & cm
-'
-' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
-' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-' PARTICULAR PURPOSE.
-'
-' Copyright (c) Microsoft Corporation. All rights reserved
-'
-' {$STAMP BS2}
-' {$PBASIC 2.5}
-' =========================================================================
-
-' Conversion constants for room temperature measurements.
-CmConstant CON 2260
-cmDistance VAR Word
-time VAR Word
-SensorID VAR Byte 'Sensor identifier = 5 for PIR
-ElementSize VAR Byte 'Size (in bytes) of each element
-ElementCount VAR Byte 'Count of elements in packet
-Padding VAR Byte 'Padding for the 8-byte element
-
-SensorID = 4
-ElementSize = 1
-ElementCount = 5 '4-bytes for pressure data; 5 for interval
-
-NewInterval VAR Word 'New interval requested by user
-Interval VAR Word 'Interval value utlized by firmware
-
-
-LFD CON $10 'Linefeed character
-
-Interval = 200 '.20 of a second interval
-NewInterval = 200
-
-Main:
- GOSUB PollSensor 'Was motion detected?
- GOSUB RetrieveInterval 'Retrieve units data
-
-Timeout:
- SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC5 cmDistance, DEC5 Interval,LFD]
-GOTO Main
-
-PollSensor:
- PULSOUT 0, 5
- PULSIN 0, 1, time
- cmDistance = cmConstant ** time
-RETURN
-
-RetrieveInterval:
- SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval
- IF NewInterval >= 10 AND NewInterval <= 60000 THEN
- Interval = NewInterval
- ENDIF
-RETURN \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/firmware/pir_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/pir_wpd_enabled.bs2
deleted file mode 100644
index 259c5025..00000000
--- a/wpd/WpdBasicHardwareDriver/firmware/pir_wpd_enabled.bs2
+++ /dev/null
@@ -1,50 +0,0 @@
-' Pir_wpd_enabled.bs2
-'
-' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
-' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-' PARTICULAR PURPOSE.
-'
-' Copyright (c) Microsoft Corporation. All rights reserved
-'
-' {$STAMP BS2}
-' {$PBASIC 2.5}
-' =========================================================================
-
-SensorID VAR Byte 'Sensor identifier = 5 for PIR
-ElementSize VAR Byte 'Size (in bytes) of each element
-ElementCount VAR Byte 'Count of elements in packet
-bMotion VAR Byte 'Motion-detection variable (single element for PIR)
-Padding VAR Byte 'Padding for the 8-byte element
-
-SensorID = 5
-ElementSize = 1
-ElementCount = 1 '1-byte for motion data; 5 for interval
-
-NewInterval VAR Word 'New interval requested by user
-Interval VAR Word 'Interval value utlized by firmware
-
-LFD CON $10 'Linefeed character
-
-Interval = 500 '.500 of a second interval
-NewInterval = 500
-
-Main:
-
- GOSUB PollSensor 'Was motion detected?
- GOSUB RetrieveInterval 'Retrieve units data
-
-Timeout:
- SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC1 bMotion, DEC5 Interval,LFD]
- GOTO Main
-
-PollSensor:
- bMotion = IN0 ' Assign status of P0 to bMotion
- RETURN
-
-RetrieveInterval:
- SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval
- IF NewInterval >= 10 AND NewInterval <= 60000 THEN
- Interval = NewInterval
- ENDIF
- RETURN \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/firmware/qti_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/qti_wpd_enabled.bs2
deleted file mode 100644
index fdfdff7c..00000000
--- a/wpd/WpdBasicHardwareDriver/firmware/qti_wpd_enabled.bs2
+++ /dev/null
@@ -1,63 +0,0 @@
-' Qti_wpd_enabled.bs2
-'
-' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
-' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-' PARTICULAR PURPOSE.
-'
-' Copyright (c) Microsoft Corporation. All rights reserved
-'
-' {$STAMP BS2}
-' {$PBASIC 2.5}
-' =========================================================================
-
-' -----[ I/O Definitions ]------------------------------------------------------
-LineSnsrPwr CON 10 ' line sensor power
-LineSnsrIn CON 9 ' line sensor input
-
-' -----[ Constants ]------------------------------------------------------------
-'CLREOL CON 11 ' clear to end of line (DEBUG)
-
-' -----[ Variables ]------------------------------------------------------------
-Sense VAR Word ' sensor raw reading
-
-SensorID VAR Byte 'Sensor identifier = 5 for PIR
-ElementSize VAR Byte 'Size (in bytes) of each element
-ElementCount VAR Byte 'Count of elements in packet
-Padding VAR Byte 'Padding for the 8-byte element
-NewInterval VAR Word 'New interval requested by user
-Interval VAR Word 'Interval value utlized by firmware
-
-SensorID = 7
-ElementSize = 1
-ElementCount = 4 '4-bytes for sensor data
-Interval = 200
-NewInterval = 200
-
-LFD CON $10 'Linefeed character
-
-' -----[ Main Code ]------------------------------------------------------------
-Main:
-
- GOSUB PollSensor 'Retrieve sensor value
- GOSUB RetrieveInterval 'Retrieve units data
-
-Timeout:
- SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC4 Sense, DEC5 Interval, LFD]
- GOTO Main
-
-PollSensor:
- HIGH LineSnsrPwr ' activate sensor
- HIGH LineSnsrIn ' discharge QTI cap
- PAUSE 1
- RCTIME LineSnsrIn, 1, Sense ' read sensor value
- LOW LineSnsrPwr ' deactivate sensor
-RETURN
-
-RetrieveInterval:
- SERIN 16, 16468, Interval, Timeout, [DEC NewInterval] 'Retrieve interval
- IF NewInterval >= 10 AND NewInterval <= 60000 THEN
- Interval = NewInterval
- ENDIF
- RETURN
-
diff --git a/wpd/WpdBasicHardwareDriver/firmware/temp_humidity_wpd_enabled.bs2 b/wpd/WpdBasicHardwareDriver/firmware/temp_humidity_wpd_enabled.bs2
deleted file mode 100644
index bc2982f7..00000000
--- a/wpd/WpdBasicHardwareDriver/firmware/temp_humidity_wpd_enabled.bs2
+++ /dev/null
@@ -1,225 +0,0 @@
-' Temp_humidity_wpd_enabled.BS2
-' This program demonstrates the interface and conversion of SHT11/15 data
-' to usable program values. This program uses advanced math features of
-' PBASIC, specifically the ** operator.
-'
-' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
-' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-' PARTICULAR PURPOSE.
-'
-' Copyright (c) Microsoft Corporation. All rights reserved
-'
-' {$STAMP BS2}
-' {$PBASIC 2.5}
-
-'
-' =========================================================================
-' -------------------------------------------------------------------------
-' I/O Definitions
-' -------------------------------------------------------------------------
-ShtData PIN 1 ' bi-directional data
-Clock PIN 0
-' -------------------------------------------------------------------------
-' Constants
-' -------------------------------------------------------------------------
-ShtTemp CON %00011 ' read temperature
-ShtHumi CON %00101 ' read humidity
-ShtStatW CON %00110 ' status register write
-ShtStatR CON %00111 ' status register read
-ShtReset CON %11110 ' soft reset
-Ack CON 0
-NoAck CON 1
-No CON 0
-Yes CON 1
-DegSym CON 186 ' degrees symbol for DEBUG
-' -------------------------------------------------------------------------
-' Variables
-' -------------------------------------------------------------------------
-ioByte VAR Byte ' data from/to SHT11
-ackBit VAR Bit ' ack/nak from/to SHT11
-toDelay VAR Byte ' timeout delay timer
-timeOut VAR Bit ' timeout status
-soT VAR Word ' temp counts from SHT11
-tC VAR Word ' temp - Celcius
-tF VAR Word ' temp - Fahrenheit
-soRH VAR Word ' humidity counts
-rhLin VAR Word ' humidity; linearized
-rhTrue VAR Word ' humidity; compensated
-status VAR Byte ' status byte
-
-'-------------------------------------------------------------------------
-' WPD Variables
-'-------------------------------------------------------------------------
-SensorID VAR Byte 'Sensor identifier = 2 for Sensiron Temp/Humidity
-ElementSize VAR Byte 'Size (in bytes) of each element
-ElementCount VAR Byte 'Count of elements in packet
-Padding VAR Byte 'Padding for the 8-byte element
-
-SensorID = 2
-ElementSize = 1
-ElementCount = 7 '4-bytes for temp, 3-bytes for relative humidity
-
-NewInterval VAR Word 'New interval requested by user
-Interval VAR Word 'Interval value utlized by firmware
-
-LFD CON $10 'Linefeed character
-
-Interval = 2000
-NewInterval = 2000
-
-' -------------------------------------------------------------------------
-' EEPROM Data
-' -------------------------------------------------------------------------
-' -------------------------------------------------------------------------
-' Initialization
-' -------------------------------------------------------------------------
-Initialize:
-GOSUB SHT_Connection_Reset ' reset device connection
-' -------------------------------------------------------------------------
-' Program Code
-' -------------------------------------------------------------------------
-Main:
- GOSUB SHT_Measure_Temp 'Retrieve temperature
- GOSUB SHT_Measure_Humidity 'Retrieve humidity
- GOSUB RetrieveInterval 'Retrieve interval data
-
-SendData:
- SEROUT 16, 16468, [DEC1 SensorID, DEC1 ElementSize, DEC1 ElementCount, DEC4 (tF), DEC3 (rhTrue), DEC5 Interval, LFD]
- GOTO Main
-
-RetrieveInterval:
- SERIN 16, 16468, Interval, SendData, [DEC NewInterval] 'Retrieve interval
- IF NewInterval >= 10 AND NewInterval <= 60000 THEN
- Interval = NewInterval
- ENDIF
-RETURN
-
-' -------------------------------------------------------------------------
-' Subroutines
-' -------------------------------------------------------------------------
-' connection reset: 9 clock cyles with ShtData high, then start sequence
-'
-SHT_Connection_Reset:
-SHIFTOUT ShtData, Clock, LSBFIRST, [$FFF\9]
-' generates SHT11 "start" sequence
-' _____ _____
-' ShtData |_______|
-' ___ ___
-' Clock ___| |___| |___
-'
-SHT_Start:
-INPUT ShtData ' let pull-up take high
-LOW Clock
-HIGH Clock
-LOW ShtData
-LOW Clock
-HIGH Clock
-INPUT ShtData
-LOW Clock
-RETURN
-' measure temperature
-' -- celcius = raw * 0.01 - 40
-' -- fahrenheit = raw * 0.018 - 40
-'
-SHT_Measure_Temp:
-GOSUB SHT_Start ' alert device
-ioByte = ShtTemp ' temperature command
-GOSUB SHT_Write_Byte ' send command
-GOSUB SHT_Wait ' wait for measurement
-ackBit = Ack ' another read follows
-GOSUB SHT_Read_Byte ' get MSB
-soT.HIGHBYTE = ioByte
-ackBit = NoAck ' last read
-GOSUB SHT_Read_Byte ' get LSB
-soT.LOWBYTE = ioByte
-' Note: Conversion factors are multiplied by 10 to return the
-' temperature values in tenths of degrees
-tC = soT ** $1999 - 400 ' convert to tenths C
-tF = soT ** $2E14 - 400 ' convert to tenths F
-RETURN
-' measure humidity
-'
-SHT_Measure_Humidity:
-GOSUB SHT_Start ' alert device
-ioByte = ShtHumi ' humidity command
-GOSUB SHT_Write_Byte ' send command
-GOSUB SHT_Wait ' wait for measurement
-ackBit = Ack ' another read follows
-GOSUB SHT_Read_Byte ' get MSB
-soRH.HIGHBYTE = ioByte
-ackBit = NoAck ' last read
-GOSUB SHT_Read_Byte ' get LSB
-soRH.LOWBYTE = ioByte
-' linearize humidity
-' rhLin = (soRH * 0.0405) - (soRH^2 * 0.0000028) - 4
-'
-' for the BASIC Stamp:
-' rhLin = (soRH * 0.0405) - (soRH * 0.002 * soRH * 0.0014) - 4
-'
-' Conversion factors are multiplied by 10 to return tenths
-'
-rhLin = (soRH ** $67AE) - (soRH ** $83 * soRH ** $5B) - 40
-' temperature compensated humidity
-' rhTrue = (tc - 25) * (soRH * 0.00008 + 0.01) + rhLin
-'
-' Conversion factors are multiplied by 10 to return tenths
-' -- simplified
-'
-rhTrue = (tC - 250) * (soRH ** $34) + rhLin
-RETURN
-' sends "status"
-'
-SHT_Write_Status:
-GOSUB SHT_Start ' alert device
-ioByte = ShtStatW ' write to status reg cmd
-GOSUB SHT_Write_Byte ' send command
-ioByte = status
-GOSUB SHT_Write_Byte
-RETURN
-' returns "status"
-'
-SHT_Read_Status:
-GOSUB SHT_Start ' alert device
-ioByte = ShtStatW ' write to status reg cmd
-GOSUB SHT_Read_Byte ' send command
-ackBit = NoAck ' only one byte to read
-GOSUB SHT_Read_Byte
-RETURN
-' sends "ioByte"
-' returns "ackBit"
-'
-SHT_Write_Byte:
-SHIFTOUT ShtData, Clock, MSBFIRST, [ioByte] ' send byte
-SHIFTIN ShtData, Clock, LSBPRE, [ackBit\1] ' get ack bit
-RETURN
-' returns "ioByte"
-' sends "ackBit"
-'
-SHT_Read_Byte:
-SHIFTIN ShtData, Clock, MSBPRE, [ioByte] ' get byte
-SHIFTOUT ShtData, Clock, LSBFIRST, [ackBit\1] ' send ack bit
-INPUT ShtData ' release data line
-RETURN
-' wait for device to finish measurement (pulls data line low)
-' -- timeout after ~1/4 second
-'
-SHT_Wait:
-INPUT ShtData ' data line is input
-timeOut = No ' assume no timeout
-FOR toDelay = 1 TO 250 ' wait ~1/4 second
-IF (ShtData = 0) THEN EXIT
-PAUSE 1
-NEXT
-IF (toDelay = 250) THEN timeOut = Yes ' loop completed = timeout
-RETURN
-
-' reset SHT11/15 with soft reset
-'
-SHT_Soft_Reset:
-GOSUB SHT_Connection_Reset ' reset the connection
-ioByte = ShtReset ' reset command
-ackBit = NoAck ' only one byte to send
-GOSUB SHT_Write_Byte ' send it
-PAUSE 11 ' wait at least 11 ms
-RETURN \ No newline at end of file
diff --git a/wpd/WpdBasicHardwareDriver/resource.h b/wpd/WpdBasicHardwareDriver/resource.h
deleted file mode 100644
index 21979556..00000000
--- a/wpd/WpdBasicHardwareDriver/resource.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-#define IDR_WpdBasicHardwareDriver 101
-
diff --git a/wpd/WpdBasicHardwareDriver/stdafx.h b/wpd/WpdBasicHardwareDriver/stdafx.h
deleted file mode 100644
index 56150a64..00000000
--- a/wpd/WpdBasicHardwareDriver/stdafx.h
+++ /dev/null
@@ -1,320 +0,0 @@
-#pragma once
-
-#include "resource.h"
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#define STRSAFE_NO_DEPRECATE
-
-#include <stdio.h>
-#include <tchar.h>
-
-#include <atlbase.h>
-#include <atlcom.h>
-#include <atlcoll.h>
-#include <atlstr.h>
-#include <strsafe.h>
-
-// This driver is entirely user-mode
-_Analysis_mode_(_Analysis_code_type_user_code_);
-
-//
-// Driver specific tracing #defines
-
-//
-// TODO: Change these values to be appropriate for your driver.
-//
-#define MYDRIVER_TRACING_ID L"Microsoft\\WPD\\BasicHardwareDriver"
-
-//
-// TODO: Choose a different trace control GUID
-//
-
-#define WPP_CONTROL_GUIDS \
- WPP_DEFINE_CONTROL_GUID(BasicHardwareDriverCtlGuid,(80068de5,197d,4db6,b77c,29ee3cca4537), \
- WPP_DEFINE_BIT(TRACE_FLAG_ALL) \
- WPP_DEFINE_BIT(TRACE_FLAG_DEVICE) \
- WPP_DEFINE_BIT(TRACE_FLAG_DRIVER) \
- WPP_DEFINE_BIT(TRACE_FLAG_QUEUE) \
- )
-
-#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \
- WPP_LEVEL_LOGGER(flags)
-
-#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \
- (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)
-
-//
-// This comment block is scanned by the trace preprocessor to define our
-// TraceEvents function.
-//
-// begin_wpp config
-// FUNC Trace{FLAG=TRACE_FLAG_ALL}(LEVEL, MSG, ...);
-// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...);
-// end_wpp
-
-//
-// This comment block is scanned by the trace preprocessor to define our
-// CHECK_HR function.
-//
-//
-// begin_wpp config
-// USEPREFIX (CHECK_HR,"%!STDPREFIX!");
-// FUNC CHECK_HR{FLAG=TRACE_FLAG_ALL}(hrCheck, MSG, ...);
-// USESUFFIX (CHECK_HR, " hr= %!HRESULT!", hrCheck);
-// end_wpp
-
-//
-// PRE macro: The name of the macro includes the condition arguments FLAGS and EXP
-// define in FUNC above
-//
-#define WPP_FLAG_hrCheck_PRE(FLAGS, hrCheck) {if(hrCheck != S_OK) {
-
-//
-// POST macro
-// The name of the macro includes the condition arguments FLAGS and EXP
-// define in FUNC above
-#define WPP_FLAG_hrCheck_POST(FLAGS, hrCheck) ; } }
-
-//
-// The two macros below are for checking if the event should be logged and for
-// choosing the logger handle to use when calling the ETW trace API
-//
-#define WPP_FLAG_hrCheck_ENABLED(FLAGS, hrCheck) WPP_FLAG_ENABLED(FLAGS)
-#define WPP_FLAG_hrCheck_LOGGER(FLAGS, hrCheck) WPP_FLAG_LOGGER(FLAGS)
-
-
-#include <PortableDevice.h>
-#include <PortableDeviceTypes.h>
-#include <PortableDeviceClassExtension.h>
-
-#include <initguid.h> // Required to access the DEFINE_GUID macro
-#include <propkeydef.h> // Required to access the DEFINE_PROPERTYKEY macro
-
-// {CDD18979-A7B0-4D5E-9EB2-0A826805CBBD}
-DEFINE_PROPERTYKEY(PRIVATE_SAMPLE_DRIVER_WUDF_DEVICE_OBJECT, 0xCDD18979, 0xA7B0, 0x4D5E, 0x9E, 0xB2, 0x0A, 0x82, 0x68, 0x05, 0xCB, 0xBD, 2);
-// {9BD949E5-59CF-41AE-90A9-BE1D044F578F}
-DEFINE_PROPERTYKEY(PRIVATE_SAMPLE_DRIVER_WPD_SERIALIZER_OBJECT, 0x9BD949E5, 0x59CF, 0x41AE, 0x90, 0xA9, 0xBE, 0x1D, 0x04, 0x4F, 0x57, 0x8F, 2);
-// {4DF6C8C7-2CE5-457C-9F53-EFCECAA95C04}
-DEFINE_PROPERTYKEY(PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP, 0x4DF6C8C7, 0x2CE5, 0x457C, 0x9F, 0x53, 0xEF, 0xCE, 0xCA, 0xA9, 0x5C, 0x04, 2);
-
-/****************************************************************************
-* This section defines the Functional Category associated with the sensor object
-****************************************************************************/
-
-//
-// FUNCTIONAL_CATEGORY_SENSOR_SAMPLE
-// Indicates this object encapsulates sensor functionality on the device
-DEFINE_GUID (FUNCTIONAL_CATEGORY_SENSOR_SAMPLE, 0x09b93609, 0xd5c1,0x497b,0xb2, 0x52, 0xb4, 0x92, 0xcb, 0x5e, 0xfe, 0x52);
-
-
-/****************************************************************************
-* This section defines all Commands, Parameters and Options associated with:
-* SENSOR_PROPERTIES_V1
-*
-* This category is for properties common to all sensor objects.
-****************************************************************************/
-DEFINE_GUID (SENSOR_PROPERTIES_V1, 0xa7ef4367, 0x6550, 0x4055, 0xb6, 0x6f, 0xbe, 0x6f, 0xda, 0xcf, 0x4e, 0x9f);
-
-//
-// SENSOR_READING
-// [ VT_UI4 ] Indicates the sensor reading in degrees Kelvin.
-DEFINE_PROPERTYKEY(SENSOR_READING, 0xa7ef4367, 0x6550, 0x4055, 0xb6, 0x6f, 0xbe, 0x6f, 0xda, 0xcf, 0x4e, 0x9f, 2);
-//
-// SENSOR_UPDATE_INTERVAL
-// [ VT_UI4 ] Indicates the sensor update interval in milliseconds.
-DEFINE_PROPERTYKEY(SENSOR_UPDATE_INTERVAL, 0xa7ef4367, 0x6550, 0x4055, 0xb6, 0x6f, 0xbe, 0x6f, 0xda, 0xcf, 0x4e, 0x9f, 3);
-
-/****************************************************************************
-* This section defines all Events associated with the sensor object
-****************************************************************************/
-//
-// EVENT_SENSOR_READING_UPDATED
-// This event is sent after a new sensor reading is available on the device.
-DEFINE_GUID (EVENT_SENSOR_READING_UPDATED, 0xada23b0b, 0xce13, 0x4e11, 0x9d, 0x2f, 0x15, 0xfe, 0x10, 0xd6, 0x63, 0x37);
-
-
-//
-// Macro Definitions
-//
-
-#ifndef SAFE_RELEASE
- #define SAFE_RELEASE(p) if( NULL != p ) { ( p )->Release(); p = NULL; }
-#endif
-
-class ContextMap : public IUnknown
-{
-public:
- ContextMap() :
- m_cRef(1)
- {
-
- }
-
- ~ContextMap()
- {
- CComCritSecLock<CComAutoCriticalSection> Lock(m_CriticalSection);
-
- IUnknown* pUnk = NULL;
- POSITION elementPosition = NULL;
-
- elementPosition = m_Map.GetStartPosition();
- while(elementPosition != NULL)
- {
- pUnk = m_Map.GetNextValue(elementPosition);
- if(pUnk != NULL)
- {
- pUnk->Release();
- }
- }
- }
-
-public: // IUnknown
- ULONG __stdcall AddRef()
- {
- InterlockedIncrement((long*) &m_cRef);
- return m_cRef;
- }
-
- _At_(this, __drv_freesMem(Mem))
- ULONG __stdcall Release()
- {
- ULONG ulRefCount = m_cRef - 1;
-
- if (InterlockedDecrement((long*) &m_cRef) == 0)
- {
- delete this;
- return 0;
- }
- return ulRefCount;
- }
-
- HRESULT __stdcall QueryInterface(
- REFIID riid,
- void** ppv)
- {
- HRESULT hr = S_OK;
-
- if(riid == IID_IUnknown)
- {
- *ppv = static_cast<IUnknown*>(this);
- AddRef();
- }
- else
- {
- *ppv = NULL;
- hr = E_NOINTERFACE;
- }
- return hr;
- }
-
-
-public: // Context accessor methods
-
- // If successful, this method AddRef's the context and returns
- // a context key
- HRESULT Add(
- _In_ IUnknown* pContext,
- _Out_ CAtlStringW& key)
- {
- CComCritSecLock<CComAutoCriticalSection> Lock(m_CriticalSection);
- HRESULT hr = S_OK;
- GUID guidContext = GUID_NULL;
- CComBSTR bstrContext;
- key = L"";
-
- // Create a unique context key
- hr = CoCreateGuid(&guidContext);
- if (hr == S_OK)
- {
- bstrContext = guidContext;
- if(bstrContext.Length() > 0)
- {
- key = bstrContext;
- }
- else
- {
- hr = E_OUTOFMEMORY;
- }
- }
-
- if (hr == S_OK)
- {
- // Insert this into the map
- POSITION elementPosition = m_Map.SetAt(key, pContext);
- if(elementPosition != NULL)
- {
- // AddRef since we are holding onto it
- pContext->AddRef();
- }
- else
- {
- hr = E_OUTOFMEMORY;
- }
- }
- return hr;
- }
-
- void Remove(
- _In_ const CAtlStringW& key)
- {
- CComCritSecLock<CComAutoCriticalSection> Lock(m_CriticalSection);
- // Get the element
- IUnknown* pContext = NULL;
-
- if (m_Map.Lookup(key, pContext) == true)
- {
- // Remove the entry for it
- m_Map.RemoveKey(key);
-
- // Release it
- pContext->Release();
- }
- }
-
- // Returns the context pointer. If not found, return value is NULL.
- // If non-NULL, caller is responsible for Releasing when it is done,
- // since this method will AddRef the context.
- IUnknown* GetContext(
- _In_ const CAtlStringW& key)
- {
- CComCritSecLock<CComAutoCriticalSection> Lock(m_CriticalSection);
- // Get the element
- IUnknown* pContext = NULL;
-
- if (m_Map.Lookup(key, pContext) == true)
- {
- // AddRef
- pContext->AddRef();
- }
- return pContext;
- }
-
-private:
- CComAutoCriticalSection m_CriticalSection;
- CAtlMap<CAtlStringW, IUnknown*> m_Map;
- DWORD m_cRef;
-};
-
-HRESULT UpdateDeviceFriendlyName(
- _In_ IPortableDeviceClassExtension* pPortableDeviceClassExtension,
- _In_ LPCWSTR wszDeviceFriendlyName);
-
-
-// Forward declaration of WpdBaseDriver as it is accessed by other classes
-class WpdBaseDriver;
-
-#include "WpdBasicHardwareDriver.h"
-#include "RS232Connection.h"
-#include "RS232Target.h"
-#include "WpdObjectEnum.h"
-#include "WpdObjectProperties.h"
-#include "WpdCapabilities.h"
-#include "WpdBaseDriver.h"
-#include "Device.h"
-#include "Driver.h"
-#include "Queue.h"
-
-extern HINSTANCE g_hInstance;
-