아두이노와 안드로이드 간의 블루투스 통신을 블루투스 터미널 앱 테스트 후
제작한 앱 테스트를 진행을 하였는데요.
로그 캣 창에 다음과 같이 출력이 되었습니다.
Content_Main received : C����������������������������
Content_Main received : C����������������������������
Content_Main received : C����������������������������
D/Content_Main: Content_Main received : urrent spe�������������������
Content_Main received : urrent spe����������������������
Content_Main received : urrent spe����������������������
수신부 코드
void OnBluetoothMessage(String p_received) {
Log.d("Content_Main","Content_Main received : "+p_received );
Log.d("Content_Main","Content_Main received : "+p_received );
Log.d("Content_Main","Content_Main received : "+p_received );
Calendar calendar = Calendar.getInstance(); // 캘린더 동기화 선언
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.KOREA); // 한국 날짜형식으로 변경
String formattedDate = simpleDateFormat.format(calendar.getTime());
databaseReference = FirebaseDatabase.getInstance().getReference();
databaseReference.child("데이터").child(formattedDate).setValue(mRead); // 데이터 베이스에 센서 데이터라는 경로에 mRead_X값 저장
databaseReference.child("타이머").child(formattedDate).setValue(mMinutes);
}
메세지 수신
@Override
public void handleMessage(Message p_message) {
try{
switch (p_message.what){
case Constants.MESSAGE_WRITE :
break;
case Constants.MESSAGE_READ : // 메시지 수신
//callback.onReceivedMsg(ByteReader.readByte(getApplicationContext(),(byte[])p_message.obj));
callback.onReceivedMsg(new String((byte[]) p_message.obj, "UTF-8"));
break;
case Constants.MESSAGE_DEVICE_NAME: // 연결된 장치정보 수신
String tmp_deviceAddress = p_message.getData().getString(Constants.DEVICE_ADDRESS);
String tmp_deviceName = p_message.getData().getString(Constants.DEVICE_NAME);
if(tmp_deviceAddress != null && tmp_deviceName != null){
connectionInfo.setDeviceInfo(tmp_deviceName, tmp_deviceAddress);
}
break;
case Constants.MESSAGE_STATE_CHANGE : // 블루투스 연결 상태변경 수신
bluetoothState = p_message.arg1;
if(bluetoothState == BluetoothManager.STATE_CONNECTED){
callback.onConnected();
}else if(bluetoothState == BluetoothManager.STATE_FAILED){
callback.onConnectFailed();
}
break;
}
앱에서 문제 인거 같은데 어떻게 수정을 해야 할까요?