Answer the question
In order to leave comments, you need to log in
Android, bluetooth, HEX, send multiple bytes in one packet?
private boolean connected = false;
private BluetoothSocket sock;
private InputStream in;
private OutputStream out;
zee = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(
"XX:XX:XX:XX:XX:XX");
m = zee.getClass().getMethod("createRfcommSocket",
new Class[] { int.class });
sock = (BluetoothSocket) m.invoke(zee, Integer.valueOf(1));
sock.connect();
in = sock.getInputStream();
out = sock.getOutputStream();
char[] test = { 0x55, 0x0, 0x0, 0x0, 0x0, 0x50, 0x2, 0x0,
0x30, 0xD7 };
for(int k=0; k < test.lenght; k++){
new DataOutputStream(sock.getOutputStream()).writeByte(test[k]);
}
for(int k=0; k < test.lenght; k++){
new DataOutputStream(sock.getOutputStream()).writeByte(test[k]);
}
Answer the question
In order to leave comments, you need to log in
Have a look at other OutputStream methods:
docs.oracle.com/javase/7/docs/api/java/io/OutputSt...
write(byte [] b) - Writes b.length bytes from the specified byte array to this output stream .
write(byte [] b, int off, int len) - Writes len bytes from the specified byte array starting at offset off to this output stream.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question