This depends on what the target of the message
buffer will be.
Since you are getting decimal values from a String you can use the Integer.parseInt
method with a radix of 10, then cast to a byte
:
byte message[] = new byte[] { (byte)java.lang.Integer.parseInt("0", 10),
(byte)java.lang.Integer.parseInt("166", 10),
(byte)java.lang.Integer.parseInt("2", 10),
(byte)java.lang.Integer.parseInt("252", 10),
(byte)java.lang.Integer.parseInt("255", 10)
};
If you simply want to send the data over the bulk pipe then you would send it as follows:
bulkTransfer(outEndpoint, message, message.length, 1000);
Control requests typically target some function on the USB device itself and is vendor defined. If you need to send the buffer as a control request you would send it as follows:
controlTransfer(USB_DIR_OUT, VENDOR_DEFINED_REQUEST, VENDOR_DEFINED_VALUE, USB_INTERFACE_INDEX, message, message.length, 1000);