Skip to content

Instantly share code, notes, and snippets.

@akexorcist
Last active November 3, 2016 22:33
Show Gist options
  • Save akexorcist/475fca29999b4a9f14f4b2629dc86074 to your computer and use it in GitHub Desktop.
Save akexorcist/475fca29999b4a9f14f4b2629dc86074 to your computer and use it in GitHub Desktop.
BluetoothSPP HotFix
// BluetoothService.java
// Line 358
while(mmInStream.available() > 0) {
int data = mmInStream.read();
arr_byte.add(data);
if(mmInStream.available() == 0) {
buffer = new byte[arr_byte.size()];
for (int i = 0; i < arr_byte.size(); i++) {
buffer[i] = arr_byte.get(i).byteValue();
}
// Send the obtained bytes to the UI Activity
mHandler.obtainMessage(BluetoothState.MESSAGE_READ
, buffer.length, -1, buffer).sendToTarget();
arr_byte = new ArrayList<Integer>();
}
}
// BluetoothService.java
// Line 358
int data = mmInStream.read();
if(data == 0x0A) {
} else if(data == 0x0D) {
buffer = new byte[arr_byte.size()];
for(int i = 0 ; i < arr_byte.size() ; i++) {
buffer[i] = arr_byte.get(i).byteValue();
}
// Send the obtained bytes to the UI Activity
mHandler.obtainMessage(BluetoothState.MESSAGE_READ
, buffer.length, -1, buffer).sendToTarget();
arr_byte = new ArrayList<Integer>();
} else {
arr_byte.add(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment