안드로이드 개발 질문/답변
(글 수 45,052)
블루투스 연결 관련 질문 입니다.
블루투스 장치 address를 직접 입력하여 연결 합니다.
그런데 A,B 두가지의 블루투스 모듈이 있는데 A모듈은 연결이 되는데 B모듈은 연결이 안됩니다.(B모듈은 안드로이드 핸드폰 설정에서 직접 페어링을 맺어야지만 연결이 됩니다.)
socket.connect()부분에서 연결이 안됩니다. 특별한 에러는 없고, 눈에 띄는 에러는 아래와 같습니다.
ERROR/DTUN_HCID(2638): discovery unsuccessful!
원인이 뭘까요 ㅠ.ㅠ
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.startDiscovery();
if(mBluetoothAdapter == null){
return TIMEOUT;
}
mBluetoothAdapter.startDiscovery();
if(mBluetoothAdapter == null){
return TIMEOUT;
}
if(!mBluetoothAdapter.isEnabled()){
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
btDevice = mBluetoothAdapter.getRemoteDevice(address);
try{
socket = btDevice.createRfcommSocketToServiceRecord(UUID_SPP);
socket.connect();
socketState = true;
}catch(IOException e){
try {
socket.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
2010.10.19 10:56:34
A, B 모듈 둘다 SSP를 지원하는지 확인해보세요.
아마도 A는 SSP를 지원할 것 같고, B는 지원하지 않을 것 같내요.
A는 BT 2.1또는 그 상위 버전, B는 아마도 2.0 이나 그 이하 버전 일 것 같아요.
B를 페어링 할 때, 핸드폰 설정에서, 핀코드 입력하셨나요? 아마도 하셨을 것 같구요.
A도 한번 핸드폰 설정에서 페어링 해보시고, 둘다 핀코드 입력하는지 확인해보세요.
A는 핀코드 입력없이 페어링이 될 확률이 높습니다.
BT 2.0 부터 이하 버전은 핀코드 입력해야 페어링 됩니다.
2010.10.19 14:22:34
B모듈 연결할 때, '비밀번호를 확인하세요' 하고 숫자가 나오나요?
안드로이드 폰하고, B모듈하고 연결할 때, 숫자가 나오고,
폰에 표시된 숫자와, B모듈에 표시된 숫자가 일치하는 것을 보고,
사용자가 페어링을 확인하는 방식이면, numeric comparision이 맞을 것 같습니다.
just work는 블루투스 헤드셋처럼 LCD나 키패드 등이 전혀 없을 때,
아무런 사용자 확인없이 인증하는 방식입니다.
블루투스 장치간에 연결시에 사용되는 인증은 블루투스 스택안에서 동작하는 것이여서,
안드로이드 API로는 변경이 어려울 것 같은대, 안타깝습니다.
2010.10.19 14:45:22
블루투스 2.0 까지는 장치연결시에 핀코드가 꼭 필요했구요,
2.1 에서 SSP가 도입되면서, SSP(Secure Simple Paring)의 인증방식이 4가지가 추가되었습니다.
2.1 기기간에 연결시에 SSP의 just work 으로 인증하게 되면,
사용자의 아무런 입력없이 장치가 연결되구요,
SSP의 numeric comparision 으로 인증을 하게 되면 위에 처럼 양쪽 블루투스 장치에
표시되는 숫자를 사용자가 읽어 보고 동일하면, '수락'을 눌러서 인증하게 됩니다.
저도 스펙 잘 모르는대, 스펙 설명하고 있내요. ㅋㅋ
질문에 답변은 아니지만, 문제 이해하시는대 도움되셨기를 바랍니다.
2010.10.19 17:52:14
참고하세요. 전 퇴근해야겠어요.
http://en.wikipedia.org/wiki/BluetoothNumeric comparison: If both devices have a display and at least one can accept a binary Yes/No user input, they may use Numeric Comparison. This method displays a 6-digit numeric code on each device. The user should compare the numbers to ensure they are identical. If the comparison succeeds, the user(s) should confirm pairing on the device(s) that can accept an input. This method provides MITM protection, assuming the user confirms on both devices and actually performs the comparison properly.



