2012-09-18 185 views
1

我試圖用我的摩托羅拉RAZR連接到基於TI的CC2540(我有TI的keyfob和connectblue OLP425的另一個設備)的BLE設備,這是我擁有的唯一成功設備遠遠不是一個名爲「Propagation」的應用程序,我無法訪問這些來源。與CC2540藍牙LE設備配對

我試圖連接到這個代碼,但我不明白的最重要的事情該設備是UUID,

我下載了一個iPad 3的一個應用,我發現了一個設備具有以下UUID 00000000 -0000-0000-ff31-1a064f8c5966

private static final UUID SPP_UUID = UUID.fromString("00000000-0000-0000-ff31-1a064f8c5966"); 
BluetoothDevice bd =BluetoothAdapter.getDefaultAdapter().getBondedDevices().iterator().next(); 
//I only have I device paired that is the Bluetooth Low Energy Device so using the first Device returned by the iterator is fine. 
    try { 
     BluetoothSocket bs = bd.createRfcommSocketToServiceRecord(UUID); 
     bs.connect(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

我得到的是logcat的

未能在所有的每個人幾乎例如服務發現使用

00000000-0000-1000-8000-00805f9b34fb

如果我在應用走得更遠它syas電池服務UUID 0x180f

我只是想創建一個應用程序閱讀本服務的價值這是一個簡單的十進制值

任何人都有與BLE設備在過去的任何成功配對?

謝謝

喬納森

+0

告訴你的代碼是用於連接到傳統的藍牙設備。這對LE來說不起作用。 – TJD

+0

謝謝,我發現摩托羅拉API的connectLe和connectGatt功能,我還沒有成功,但我會繼續努力。 – gimpycpu

回答

0

我已經能夠連接到我的CC2540與心率監測儀。 我使用CCDebugger閃存固件,並使用0000180d-0000-1000-8000-00805f9b34fbas UUID,我已經能夠讀取一個值。

使用Motorola_BLE_profile示例應用程序進行一些修改。

primaryServices = mGattService.getGattPrimaryServices(device); 
if (primaryServices == null) { 
    String message = "Connection failed !"; 
    Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); 
    return; 
} 
for (i = 0; i < primaryServices.length; i++) { 
    Log.v(TAG, "primary service " + primaryServices[i]); 
    if (primaryServices[i].equalsIgnoreCase(hrmUUID)) { 
    try { 
     status = mGattService.connectGatt(device, hrmUUID, callback1); 
     if (status == true){ 
     mDevice = device; 
     mLeState = CONNECTING; 
     BluetoothLeReceiver.isDevicePickerPending = false; 
     } else { 
     String message = "Connection failed !"; 
     Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); 
     } 

} catch (Exception e) { 
    Log.e(TAG,"Exception while calling gatt Connect"); 
} 
return; 
if (i == primaryServices.length) { 
Log.v(TAG,"Primary Service not found"); 
String message = "Connection failed !"; 
Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); 

}