Converts Bluetooth address from string to byte array representation.
final int len = btaddr.length() / 2;
if (len != BTADDR_SIZE) {
throw new IllegalArgumentException("Incorrect address size");
}
byte[] bytes = new byte[len];
try {
for (int i = 0; i < len; i++) {
String s = btaddr.substring(i * 2, i * 2 + 2);
bytes[len - 1 - i] = (byte)Integer.parseInt(s, 16);
}
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Incorrect address value");
}
return bytes;