diff options
author | Andre Eisenbach <andre@broadcom.com> | 2013-08-06 19:57:48 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2013-08-14 00:48:24 -0700 |
commit | f46b21aa99fb3bbe4c8b446ff1d362c38f972099 (patch) | |
tree | 86b6c433f4ada076d86b4f1f5c1a0afdc9f78c9a /core/java/android/bluetooth/BluetoothGatt.java | |
parent | 25b9cf953bd3e97f726f8c27d7a752b27c9a2373 (diff) | |
download | frameworks_base-f46b21aa99fb3bbe4c8b446ff1d362c38f972099.zip frameworks_base-f46b21aa99fb3bbe4c8b446ff1d362c38f972099.tar.gz frameworks_base-f46b21aa99fb3bbe4c8b446ff1d362c38f972099.tar.bz2 |
LE: Add peripheral role support (1/4)
Initial stack support for the LE peripheral role.
Change-Id: I6222493488822b4289b90888ccc97ad9306f54d1
Diffstat (limited to 'core/java/android/bluetooth/BluetoothGatt.java')
-rw-r--r-- | core/java/android/bluetooth/BluetoothGatt.java | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java index 1ad7bf2..a8c310b 100644 --- a/core/java/android/bluetooth/BluetoothGatt.java +++ b/core/java/android/bluetooth/BluetoothGatt.java @@ -553,6 +553,14 @@ public final class BluetoothGatt implements BluetoothProfile { Log.w(TAG, "Unhandled exception in callback", ex); } } + + /** + * Listen command status callback + * @hide + */ + public void onListen(int status) { + if (DBG) Log.d(TAG, "onListen() - status=" + status); + } }; /*package*/ BluetoothGatt(Context context, IBluetoothGatt iGatt, BluetoothDevice device) { @@ -685,6 +693,63 @@ public final class BluetoothGatt implements BluetoothProfile { return true; } + /** + * Starts or stops sending of advertisement packages to listen for connection + * requests from a central devices. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. + * + * @param start Start or stop advertising + */ + /*package*/ void listen(boolean start) { + if (DBG) Log.d(TAG, "listen() - start: " + start); + if (mService == null || mClientIf == 0) return; + + try { + mService.clientListen(mClientIf, start); + } catch (RemoteException e) { + Log.e(TAG,"",e); + } + } + + /** + * Sets the advertising data contained in the adv. response packet. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. + * + * @param advData true to set adv. data, false to set scan response + * @param includeName Inlucde the name in the adv. response + * @param includeTxPower Include TX power value + * @param minInterval Minimum desired scan interval (optional) + * @param maxInterval Maximum desired scan interval (optional) + * @param appearance The appearance flags for the device (optional) + * @param manufacturerData Manufacturer specific data including company ID (optional) + */ + /*package*/ void setAdvData(boolean advData, boolean includeName, boolean includeTxPower, + Integer minInterval, Integer maxInterval, + Integer appearance, Byte[] manufacturerData) { + if (DBG) Log.d(TAG, "setAdvData()"); + if (mService == null || mClientIf == 0) return; + + byte[] data = new byte[0]; + if (manufacturerData != null) { + data = new byte[manufacturerData.length]; + for(int i = 0; i != manufacturerData.length; ++i) { + data[i] = manufacturerData[i]; + } + } + + try { + mService.setAdvData(mClientIf, !advData, + includeName, includeTxPower, + minInterval != null ? minInterval : 0, + maxInterval != null ? maxInterval : 0, + appearance != null ? appearance : 0, data); + } catch (RemoteException e) { + Log.e(TAG,"",e); + } + } + /** * Disconnects an established connection, or cancels a connection attempt * currently in progress. |