1 package org.minetti.astrodevice.server.usb.jni; 2 3 import org.minetti.astrodevice.server.usb.object.UsbDeviceSignature; 4 5 /** 6 * Object responsible for interfacing with the native library (<code>usb.dll</code> for MS Windows 7 * and <code>usb.so</code> for Linux and Mac OS X). 8 * @author Jean-Philippe MINETTI 9 */ 10 public final class UsbLibrary { 11 12 static { 13 System.loadLibrary("astroDeviceServer-usb"); 14 } 15 16 /** 17 * Starts the monitoring of connection/disconnection of devices. 18 */ 19 public native void startPlugMonitoring (); 20 21 /** 22 * Stops the monitoring of connection/disconnection of devices. 23 */ 24 public native void stopPlugMonitoring (); 25 26 /** 27 * Handles an USB device connection. 28 * @param vendorId Vendor ID of USB device (must be between 0 and 65535). This corresponds to 29 * <code>idVendor</code> field of USB specification (assigned by the USB-IF). 30 * @param productId Product ID of USB device (must be between 0 and 65535). This corresponds to 31 * <code>idProduct</code> field of USB specification (assigned by the manufacturer). 32 * @param manufacturerName Manufacturer name of USB device (must be less or equal than 127 33 * characters). This corresponds to string indexed by the <code>iManufacturer</code> 34 * field of USB specification. 35 * @param productName Product name of USB device (must be less or equal than 127 characters). 36 * This corresponds to string indexed by the <code>iProduct</code> field of USB 37 * specification. 38 * @param productVersion Product version of USB device (must be between 0 and 65535). This 39 * corresponds to <code>bcdDevice</code> field of USB specification (assigned by the 40 * manufacturer). 41 * @param serialNumber Serial number of USB device (must be less or equal than 127 characters). 42 * This corresponds to string indexed by the <code>iSerialNumber</code> field of USB 43 * specification. 44 * @param deviceClass Class code of USB device (must be between 0 and 255). This corresponds to 45 * <code>bDeviceClass</code> field of USB specification (assigned by the USB-IF). 46 * @param deviceSubClass Subclass code of USB device (must be between 0 and 255). This 47 * corresponds to <code>bDeviceSubClass</code> field of USB specification (assigned 48 * by the USB-IF). 49 * @param deviceProtocol Protocol code of USB device (must be between 0 and 255). This 50 * corresponds to <code>bDeviceProtocol</code> field of USB specification (assigned 51 * by the USB-IF). 52 */ 53 @SuppressWarnings("unused") 54 private void handleConnection (final int vendorId, final int productId, final String manufacturerName, final String productName, final int productVersion, 55 final String serialNumber, final short deviceClass, final short deviceSubClass, final short deviceProtocol) { 56 final UsbDeviceSignature deviceSignature = new UsbDeviceSignature(vendorId, productId, manufacturerName, productName, productVersion, serialNumber, deviceClass, deviceSubClass, deviceProtocol); 57 58 // TODO 59 60 } 61 62 /** 63 * Handles an USB device disconnection. 64 * @param vendorId Vendor ID of USB device (must be between 0 and 65535). This corresponds to 65 * <code>idVendor</code> field of USB specification (assigned by the USB-IF). 66 * @param productId Product ID of USB device (must be between 0 and 65535). This corresponds to 67 * <code>idProduct</code> field of USB specification (assigned by the manufacturer). 68 * @param manufacturerName Manufacturer name of USB device (must be less or equal than 127 69 * characters). This corresponds to string indexed by the <code>iManufacturer</code> 70 * field of USB specification. 71 * @param productName Product name of USB device (must be less or equal than 127 characters). 72 * This corresponds to string indexed by the <code>iProduct</code> field of USB 73 * specification. 74 * @param productVersion Product version of USB device (must be between 0 and 65535). This 75 * corresponds to <code>bcdDevice</code> field of USB specification (assigned by the 76 * manufacturer). 77 * @param serialNumber Serial number of USB device (must be less or equal than 127 characters). 78 * This corresponds to string indexed by the <code>iSerialNumber</code> field of USB 79 * specification. 80 * @param deviceClass Class code of USB device (must be between 0 and 255). This corresponds to 81 * <code>bDeviceClass</code> field of USB specification (assigned by the USB-IF). 82 * @param deviceSubClass Subclass code of USB device (must be between 0 and 255). This 83 * corresponds to <code>bDeviceSubClass</code> field of USB specification (assigned 84 * by the USB-IF). 85 * @param deviceProtocol Protocol code of USB device (must be between 0 and 255). This 86 * corresponds to <code>bDeviceProtocol</code> field of USB specification (assigned 87 * by the USB-IF). 88 */ 89 @SuppressWarnings("unused") 90 private void handleDisconnection (final int vendorId, final int productId, final String manufacturerName, final String productName, final int productVersion, 91 final String serialNumber, final short deviceClass, final short deviceSubClass, final short deviceProtocol) { 92 final UsbDeviceSignature deviceSignature = new UsbDeviceSignature(vendorId, productId, manufacturerName, productName, productVersion, serialNumber, deviceClass, deviceSubClass, deviceProtocol); 93 94 // TODO 95 96 } 97 98 /** 99 * Loads the device tree. 100 * @param builder Builder of device tree. 101 */ 102 public native void loadDeviceTree (final UsbDeviceTreeBuilder builder); 103 104 }