다음과 같이 작성을 하였는데요
블루투스로 넘오는값을 확인하려고 hex으로 변환하려고 하는데 어디서 수정을 해야 될지 모르겠어서
이렇게 질문 남깁니다.
public void run() {
int bytes; // bytes returned from read() 읽기()에서 반환된 바이트
while (true) {
try {
// InputStream에서 데이터를 읽는다
bytes = mmInStream.available();
byte[] buffer = new byte[mmInStream.available()]; // mmInStream.available들어오는 값만큼만 출력
if(bytes != 0) {
Arrays.fill(buffer, (byte)0x00);
bytes = mmInStream.read(buffer);
// pause and wait for rest of data. Adjust this depending on your sending speed.
// 나머지 데이터를 일시 중지하고 기다립니다. 전송 속도에 따라 이 설정을 조정합니다.*/
bytes = mmInStream.available(); // how many bytes are ready to be read? 읽을 준비가 된 바이트 수
bytes = mmInStream.read(buffer,0,buffer.length); // record how many bytes we actually read 실제로 읽은 바이트 수를 기록합니다.
mHandler.obtainMessage(Constants.MESSAGE_READ, byteArrayOutputStream.size(), -1, buffer)
.sendToTarget(); // Send the obtained bytes to the UI activity 보유한 바이트를 UI활동에 보내기
}
} catch (IOException e) {
Log.e(TAG, "disconnected", e);
connectionLost();
break;
}
}
}