제가 현재 안드로이드 폰과 노트북을 블루투스로 연결하여 파일 전송하는 것을 구현하고 있습니다.
소스는 BluetoothChat을 약간 수정했습니다.
문제는 블루투스 연결 시 디바이스를 검색하고 연결 시도까지 되지만 자꾸 연결 실패라는 결과가 나옵니다.
로그는 아래와 같습니다.
05-18 20:28:21.828: D/BluetoothService(2924): Bluetooth is available
05-18 20:28:21.828: I/BluetoothService(2924): Check the enabled Bluetooth
05-18 20:28:21.828: D/BluetoothService(2924): Bluetooth Enable Now
05-18 20:28:21.828: D/BluetoothService(2924): Scan Device
05-18 20:28:21.828: I/ActivityManager(2924): Timeline: Activity_launch_request id:com.example.smarthelmet time:50416823
05-18 20:28:21.828: I/ViewRootImpl(2924): ViewRoot's Touch Event : Touch UP
05-18 20:28:21.948: I/ActivityManager(2924): Timeline: Activity_idle id: android.os.BinderProxy@42a89e28 time:50416941
05-18 20:28:22.328: I/ViewRootImpl(2924): ViewRoot's Touch Event : Touch Down
05-18 20:28:22.378: I/ViewRootImpl(2924): ViewRoot's Touch Event : Touch UP
05-18 20:28:22.448: D/DeviceListActivity(2924): User selected device : 40:F0:2F:E1:2A:15
05-18 20:28:22.478: D/Main(2924): onActivityResult()-1
05-18 20:28:22.478: D/BluetoothService(2924): Get Device Info
05-18 20:28:22.478: D/BluetoothService(2924): address : 40:F0:2F:E1:2A:15
05-18 20:28:22.478: D/BluetoothService(2924): connect to : 40:F0:2F:E1:2A:15
05-18 20:28:22.478: E/BluetoothService(2924): setState() 1 -> 2
05-18 20:28:22.488: I/BluetoothService(2924): BEGIN mConnectThread
05-18 20:28:22.498: W/BluetoothAdapter(2924): getBluetoothService() called with no BluetoothManagerCallback
05-18 20:28:22.508: D/BluetoothSocket(2924): connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[63]}
05-18 20:28:22.558: I/ActivityManager(2924): Timeline: Activity_idle id: android.os.BinderProxy@429b3468 time:50417551
05-18 20:28:24.158: E/BluetoothService(2924): Connection Failed
05-18 20:28:24.158: E/BluetoothService(2924): setState() 2 -> 1
05-18 20:28:24.158: D/BluetoothService(2924): start
05-18 20:28:24.158: E/BluetoothService(2924): setState() 1 -> 1
로그를 보시면 디바이스를 정상적으로 검색하고 연결시도 (State가 0에서 2로 바뀜)를 진행 중
getBluetoothService() called with no BluetoothManagerCallback과
connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[63]}
을 뿜으면서 Connection Failed가 되고 State가 2에서 1(STATE_LISTEN)으로 바뀌어 고정됩니다.
이 문제에 대해서 여러가지 글들을 찾아봤는데 다 영문이라서 그런지 해석이 좀 애매해져서
여기다가 글을 올리게 되었습니다. 이 문제의 원인에 대해서 아시는 고수분들 답변 부탁드립니다.