안녕하세요 안드로이드펍 가족님들.
현재 블루투스로 아스키코드값을 받아서 처리하는부분을 하늗네요.
하이퍼터미널에서 한 20바이트정도 쳤는데
이게 한번에 오는것이 아니라 반정도오고 다시 반이오고이런시긍로 되어있습니다.
저는 이걸 한꺼번에 모아서 처리할수없나요?
바이트안에 특정 코드를 번째를 검색해서 처리를해야하는데
방법이 없는건가요.
public void run() {
Log.e(TAG, "BEGIN mConnectedThread");
byte[] buffer = new byte[1024];
int bytes;
// Keep listening to the InputStream while connected
while (true) {
try {
// InputStream으로부터 값을 받는 읽는 부분(값을 받는다)
bytes = mmInStream.read(buffer);
String readMessage = new String(buffer, 0, bytes);
if(buffer[18]==0x0d && buffer[19]==0x0a){
if(Const.g_handler!=null){
Const.g_handler.obtainMessage(Const.MESSAGE_INIT, bytes, -1, buffer).sendToTarget();
}
}
if(Const.g_handler!=null){
// Const.g_handler.obtainMessage(Const.MESSAGE_INIT, bytes, -1, buffer).sendToTarget();
Const.g_handler.obtainMessage(Const.MESSAGE_READ, bytes, -1, buffer).sendToTarget();
}
} catch (IOException e) {
Log.e(TAG, "disconnected", e);
if(Const.g_handler!=null){
Const.g_handler.obtainMessage(Const.MESSAGE_DISCONNECT).sendToTarget();
// Const.g_handler.sendMessage(message);
}
connectionLost();
break;
}
}
}