Device Error Codes
The InvokeAction and QueryStateVariable methods return HRESULT values that might indicate a device error (that is, an error that is received from a UPnP-certified device). If an error is received from a device, the method (InvokeAction or QueryStateVariable) returns an HRESULT value that is based on the device error code, as explained in this topic. Because a conversion is applied to the device error code to produce an HRESULT value, you cannot read the device error code directly from the HRESULT value.
There are both standard and non-standard device error codes. The standard codes have the same meaning across all UPnP-certified devices and have values that are less than 600. The non-standard codes are vendor-specific and have values ranging from 600 through 899.
Whether or not the device error code is standard determines how the HRESULT value is generated:
- A standard device error code is mapped to an HRESULT value.
- A non-standard device error code is embedded in the HRESULT value by applying a formula.
If the HRESULT value is greater than or equal to UPNP_E_ACTION_SPECIFIC_BASE (0x80040300) and less than or equal to UPNP_E_ACTION_SPECIFIC_MAX (0x8004042B), the device error code is nonstandard — use the formula in the following section to determine the error code. Otherwise, the device error code is standard — use the table in the Mapping for Standard Device Error Codes section, which provides the mapping from the HRESULT value to the device error code.
For a text description of the error after a call to IUPnPService::InvokeAction, set the pvarRetVal parameter to an empty array. Upon return, this parameter will contain a text description of the error, if any occurred.
Use the following formula if UPNP_E_ACTION_SPECIFIC_BASE ≤ HRESULT ≤UPNP_E_ACTION_SPECIFIC_MAX.
Device Error Code = (HRESULT - UPNP_E_ACTION_SPECIFIC_BASE) + FAULT_ACTION_SPECIFIC_BASE
Substituting the actual numeric values, the equation is: Device Error Code = (HRESULT - 0x80040300) + 0x0258
Use the following mapping if HRESULT < UPNP_E_ACTION_SPECIFIC_BASE.
|HRESULT value||Device Error Code||Actual value|
Device error codes are specified in UPnP Device Architecture version 1.0. The constants mentioned in this topic are defined in the files Upnp.h and Upnp.idl.