2012-09-18 184 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(); 

}