Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

接收器读取bug #20

Open
houyuehai opened this issue May 24, 2019 · 1 comment
Open

接收器读取bug #20

houyuehai opened this issue May 24, 2019 · 1 comment

Comments

@houyuehai
Copy link

try {
if (mmInStream.read()<=0){
continue;
}else {
Thread.sleep(1000);
}
bytes = mmInStream.read(buffer);
if (bytes > 0) {
byte[] data = Arrays.copyOf(buffer, bytes);
if (mBluetoothListener != null) {
((BluetoothListener) mBluetoothListener).onReadData(mmSocket.getRemoteDevice(), data);
}
}

@houyuehai
Copy link
Author

mmInStream.read()<=0这里的read()其实已经读取了一个字符了。所以 Arrays.copyOf(buffer,bytes),会少一个byte。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant