从蓝牙套接字接收字节时遇到问题。我正在尝试发送由arduino创建的消息 - 几个单字节值,即0x41,0x05,0xFF(...)到我的手机与android。它工作正常,直到其中一个值为零(0x00)。传输一直持续到新消息出现。有人遇到过这种情况吗?
我的“阅读器”在单独的线程中工作,processBuffer()执行应该接收的数据:
public void run() {
while(stop == false){
try {
bytes = InStream.read(readbuffer);
for (int i = 0; i < bytes; i++){
Log.d("FRAME", "Read bytes "+readbuffer[i]);
}
Log.d("FRAME", "Read number of bytes "+bytes);
processBuffer(bytes);
} catch (Exception e){
Log.d("BT_debug", "Cannot read bytes");
Log.d("BT_debug", "iterator: "+iterator);
e.printStackTrace();
break;
}
}
}