summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothGatt.java
diff options
context:
space:
mode:
authorAndre Eisenbach <andre@broadcom.com>2014-03-25 06:31:50 -0700
committerZhihai Xu <zhihaixu@google.com>2014-03-25 18:02:06 -0700
commit91057ef842c47e70f4b97fafc950bed6c4382f03 (patch)
tree7044da5f58de1ed202f2a549bb4b8ac97147bdc0 /framework/java/android/bluetooth/BluetoothGatt.java
parent47878be5c835261f3aad0a73b73beed8a427e6d1 (diff)
LE: Add API to configure MTU for a given connection (3/4)
bug:13571470 Change-Id: I3619617eaf864701a35f7802bc71805784d768d0
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothGatt.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothGatt.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothGatt.java b/framework/java/android/bluetooth/BluetoothGatt.java
index ae6ad3b4f2..bbd0439e51 100644
--- a/framework/java/android/bluetooth/BluetoothGatt.java
+++ b/framework/java/android/bluetooth/BluetoothGatt.java
@@ -561,6 +561,23 @@ public final class BluetoothGatt implements BluetoothProfile {
public void onAdvertiseStateChange(int state, int status) {
if (DBG) Log.d(TAG, "onAdvertiseStateChange() - state = "
+ state + " status=" + status);
+ }
+
+ /**
+ * Callback invoked when the MTU for a given connection changes
+ * @hide
+ */
+ public void onConfigureMTU(String address, int mtu, int status) {
+ if (DBG) Log.d(TAG, "onConfigureMTU() - Device=" + address +
+ " mtu=" + mtu + " status=" + status);
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+ try {
+ mCallback.onConfigureMTU(BluetoothGatt.this, mtu, status);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception in callback", ex);
+ }
}
};
@@ -1148,6 +1165,36 @@ public final class BluetoothGatt implements BluetoothProfile {
}
/**
+ * Configure the MTU used for a given connection.
+ *
+ * <p>When performing a write request operation (write without response),
+ * the data sent is truncated to the MTU size. This function may be used
+ * to request a larget MTU size to be able to send more data at once.
+ *
+ * <p>A {@link BluetoothGattCallback#onConfigureMTU} callback will indicate
+ * whether this operation was successful.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ *
+ * @return true, if the new MTU value has been requested successfully
+ * @hide
+ */
+ public boolean configureMTU(int mtu) {
+ if (DBG) Log.d(TAG, "configureMTU() - device: " + mDevice.getAddress()
+ + " mtu: " + mtu);
+ if (mService == null || mClientIf == 0) return false;
+
+ try {
+ mService.configureMTU(mClientIf, mDevice.getAddress(), mtu);
+ } catch (RemoteException e) {
+ Log.e(TAG,"",e);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
* Not supported - please use {@link BluetoothManager#getConnectedDevices(int)}
* with {@link BluetoothProfile#GATT} as argument
*