2013-04-27 184 views

回答

0

您可以創建一個Java應用程序作爲藍牙服務器並使用它與您的藍牙客戶端應用程序測試。

您需要Bluecove library這一點,這裏是一個示例代碼片段:

UUID serialUUID = new UUID("1101", true); 
String SERVICE_URL = "btspp://localhost:" + serialUUID 
     + ";name=My Bluetooth Server;authorize=false;authenticate=false"; 

StreamConnectionNotifier connectionNotifier = 
          (StreamConnectionNotifier) Connector.open(SERVICE_URL); 

System.out.println("Server is waiting for client ... \n URL=" + SERVICE_URL); 

// Wait until client connects i.e. a blocking method 
StreamConnection connection = connectionNotifier.acceptAndOpen(); 

RemoteDevice remoteDevice = RemoteDevice.getRemoteDevice(connection); 
System.out.println("Client connected: "+remoteDevice.getBluetoothAddress()); 

// Communicate with the device using the below I/O streams 
InputStream iStream = connection.openInputStream(); 
OutputStream oStream = connection.openOutputStream(); 
+0

感謝您的答覆。我有e USB CC2540 BLE套件。我可以使用它嗎? – 2013-04-27 23:49:23

+0

你可以試試它,只要確保它可以在你的電腦上運行,例如安裝並可以配對。然後嘗試Java代碼 – iTech 2013-04-27 23:51:17

+0

感謝您的幫助:) – 2013-04-27 23:53:51

相關問題