2

Follwoing is the code android uses to get the connection summary(to display the connection status labels)

      private int getConnectionSummary() {
      ...........................
      ...........................
      for (LocalBluetoothProfile profile : cachedDevice.getProfiles()) {
            int connectionStatus = cachedDevice.getProfileConnectionState(profile);

            switch (connectionStatus) {
                case BluetoothProfile.STATE_CONNECTING:
                case BluetoothProfile.STATE_DISCONNECTING:
                    return Utils.getConnectionStateSummary(connectionStatus);

                case BluetoothProfile.STATE_CONNECTED:
                    profileConnected = true;
                    break;

                case BluetoothProfile.STATE_DISCONNECTED:
                    if (profile.isProfileReady()) {
                        if (profile instanceof A2dpProfile) {
                            a2dpNotConnected = true;
                        } else if (profile instanceof HeadsetProfile) {
                            headsetNotConnected = true;
                        }
                    }
                    break;
            }
        }

As you can see from the code above, they obtain the connection status for a Classic device using the following line of code:

int connectionStatus = cachedDevice.getProfileConnectionState(profile);

The android system calls the getConnectionSummary() method irrespective of whether a Classic or Bluetooth Low energy device is trying to connect; but unlike a classic device, since we do not have a method by which we can get the connectionStatus for a bluetooth Low energy device, we are unable to update the connection status correctly for a Low energy device.

Full source for this class can be found here

Any help is much appreciated.

user1400538
  • 855
  • 5
  • 24
  • 42

1 Answers1

0

What is the Bluetooth Low energy development kit you are using ?

As of now Android doesn't have native API's for Bluetooth Low energy devices. you may have to use third party APIs like the BLE From Broadcomm or TI or CSR.

http://code.google.com/p/broadcom-ble/

Motorola bluetooth Low energy APIs http://developer.motorola.com/docs/bluetooth-low-energy-api/

You can look at this page for more information on selecting a Development Kit. BTLE (Bluetooth Low energy) development kit - must have proximity profile

Community
  • 1
  • 1
m4n07
  • 2,267
  • 12
  • 50
  • 65
  • I already have few profiles implemented with the jar's provided by a vendor. And I understand when a profile is connected, disconnected etc. But while Android system call the method I mentioned above, I do not have a way out by which I get the connection status for a BLE device, unlike what they do for classic device in that method. – user1400538 Sep 27 '12 at 09:38
  • Can you please elaborate on your requirement ? why you need to use this function ? can you try the 3rd party APIs – m4n07 Sep 27 '12 at 09:50