Custom MTP formats in WPD

The list of supported WPD formats is available in MSDN here. But what if your MTP device supports a brand new format that isn’t in the supported list? WPD does allow a way to reference custom/vendor extended formats. If you take a closer look at the GUID values in PortableDevice.h for all those object formats,…

2

MTP array properties (AINT*/AUINT*) in WPD

MTP allows for a wide range of array-based data types ranging from an array of bytes (AINT8/AUINT8) to an array of GUIDs (AINT128/AUINT128). Check out section 3.2.1 and 3.2.2 in the MTP specification for a complete list and definition. Unfortunately the WPD API is restricted in the kind of arrays it can expose. Specifically, the…

1

Accessing MTP vendor extended properties through WPD

Apart from the standard device and object properties defined in the MTP specification, device vendors are free to add their own properties. The codes for these properties must lie in the vendor-extension range as defined by the MTP spec in section 3.3.1. Specifically, the range for vendor-extended device properties is 0xD000-0xD3FF and the range for vendor-extended…

0

Setting WPD properties

The IPortableDeviceProperties::SetValues API can be used to set WPD object properties. The documentation covers the API parameters as well, so we’ll skip to the meatier sample. The SetValues API can be used to set multiple properties at the same time. You can, of course, also just set one property at a time. For illustration, we’ll set…

1

How to check if a WPD property can be modified

We’ll create a little helper function that we can use to figure out if a WPD object property can be modified. All WPD object properties have attributes on them. The MSDN documentation provides a complete list of attributes here. We’ll take a look at the WPD_PROPERTY_ATTRIBUTE_CAN_WRITE attribute since the value of that attribute decides if…

0

Sending MTP commands through WPD (Part 3 – data from device)

Let’s use the GetDevicePropValue command (MTP spec – section D.2.21) to illustrate this. GetDevicePropValue takes one parameter – the device property code that we want to retrieve the current value for. We’ll retrieve the BatteryLevel device property (MTP spec – section C.2.2) which is of type UINT8. From the WPD API, we will need this sequence of…

1

Sending MTP commands through WPD (Part 2 – data to the device)

We’ll pick the SetDevicePropValue MTP command (MTP spec – section D.2.22) to illustrate this example. This command requires the device property code as a parameter. We’ll try setting the DateTime property (MTP spec – section C.2.18). The DateTime property is of type STRING and we’ve already covered in a previous post on how MTP strings…

2

Save Often!

One of the problems of living on the cutting edge is that it tends to make you bleed. I have a post-RC1 Vista build on my main desktop. And I was impressed by the fact that I hadn’t required a single reboot in over three weeks. I worked yesterday on putting together a long post…

1

Creating an MTP string

In some of our later examples, we’ll have to send MTP strings to the device. MTP strings are defined in the MTP spec in section 3.2.3. Briefly, the first byte is the number of Unicode characters to follow (including the NULL terminator), the remaining bytes are the characters. The conversion is pretty simple and is…

1

Listening to MTP events

MTP devices can fire events as well. These events are used to educate the PC (or the initiator) about any change in device status. Think of a scenario where you connect a camera extension to an MTP cellphone. The configuration of the cellphone has now changed since it supports camera settings. The device can inform…

1