简体   繁体   中英

Pairing to a CC2540 Bluetooth LE Device

I am trying to connect to a BLE devices based on CC2540 from TI (I have the keyfob from TI, and another device from connectblue OLP425) with my Motorola RAZR, the only succes I had so far is an app named Propagation on the market that I don't have access to the sources.

I tried to connect to the device with this code but the biggest thing I don't understand is the UUID,

I downloaded an app on a iPad 3 and I found a device has the following 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();
    }

All I get is a Service discovery failed in logcat

In almost all the example everyone is using

00000000-0000-1000-8000-00805f9b34fb

If I go further in the app it syas that the battery service is UUID 0x180f

I would just like to create an app the read the value of this service which is a simple decimal value

anyone has any succes pairing with a BLE device in the past?

thank you

Jonathan

I've been able to connect to my CC2540 with the Heart Rate Monitor. I flashed the firmware using the CCDebugger and using 0000180d-0000-1000-8000-00805f9b34fbas the UUID i've been able to read a value.

Using the Motorola_BLE_profile sample app with some modifications.

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();

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM