2012-05-03 2 views
4

컴퓨터에서 실행중인 서버와 안드로이드 블루투스 응용 프로그램의 연결을 포함하는 블루투스 응용 프로그램에서 작업하고 있습니다. 이 서버는 Blue-Cove API를 사용하여 만든 블루투스 애플리케이션이기도합니다.android and PC bluetooth applications 사이의 연결

내 모바일 앱과 컴퓨터 서버 응용 프로그램을 연결할 수 없다는 문제가 있습니다.

try { 
      // Connect the device through the socket. This will block 
      // until it succeeds or throws an exception 
      mySocket = myDevice.createRfcommSocketToServiceRecord(MY_UUID); 
      mySocket.connect(); 
      toast = Toast.makeText(context, "Connection established", thisClass.duration); 
      toast.show(); 
      } catch (IOException connectException) { 
      // Unable to connect; close the socket and get out 
      try { 
       mySocket.close(); 
       toast = Toast.makeText(context, "Connection not established", thisClass.duration); 
       toast.show(); 
      } catch (IOException closeException) { } 
      return; 
     } 

인 문제 나 어떤 아마도 내가 그 안에 실종 :

여기 내 안드로이드 응용 프로그램에 대한 코드입니다. 또한 socket.connect() 메서드에 대한 이해가 모호합니다. 이 점에 대해 친절히 도와주세요.

답변

5

방금 ​​비슷한 응용 프로그램에서 작업을 마쳤으며 연결에 문제가있었습니다. 좀 더 많은 코드를 보는 데 도움이되지만 위의 발췌 내용은 내가 따라간 예제와 같습니다. 먼저 MY_UUID가 연결하려는 PC에 있는지 확인합니다.

내 예제 (클라이언트와 서버 모두)는 내 블로그 http://digitalhacksblog.blogspot.com/2012/05/android-example-bluetooth-simple-spp.html에 게시했습니다.

희망이 도움이됩니다.