Code example for UsbDevice

Methods: getDeviceClass, getDeviceId, getDeviceName, getInterface, getInterfaceCount, getProductId, getVendorId

0
	} 
 
	private void setDevice(UsbDevice device) {
		appendLogText("setDevice " + device);
		 
		appendLogText("getDeviceClass: "+device.getDeviceClass());
		//TODO: finish the mapping 
		switch (device.getDeviceClass()) {
		case UsbConstants.USB_CLASS_APP_SPEC:
			appendLogText("getDeviceClass: USB_CLASS_APP_SPEC "); 
			break; 
		case UsbConstants.USB_CLASS_PER_INTERFACE:
			appendLogText("getDeviceClass: USB_CLASS_PER_INTERFACE"); 
			break; 
		} 
	 
		appendLogText("getDeviceId:" + device.getDeviceId());
		appendLogText("getDeviceName:" + device.getDeviceName());
		appendLogText("getVendorId:" + device.getVendorId());
		appendLogText("getProductId:" + device.getProductId());
 
		if (device.getInterfaceCount() != 1) {
			appendLogText("could not find interface"); 
			return; 
		} 
		UsbInterface intf = device.getInterface(0);
		// device should have one endpoint 
		if (intf.getEndpointCount() != 1) {
			appendLogText("could not find endpoint"); 
			return; 
		}