1f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray/* 2f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Copyright (C) 2015, The Android Open Source Project 3f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * 4f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Licensed under the Apache License, Version 2.0 (the "License"); 5f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * you may not use this file except in compliance with the License. 6f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * You may obtain a copy of the License at 7f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * 8f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * http://www.apache.org/licenses/LICENSE-2.0 9f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * 10f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Unless required by applicable law or agreed to in writing, software 11f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * distributed under the License is distributed on an "AS IS" BASIS, 12f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * See the License for the specific language governing permissions and 14f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * limitations under the License. 15f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 16f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 17f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray/** 18f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Binder IPC API for talking with the Bluetooth service and perform high-level 19f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * operations on the adapter. 20f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 21f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Ugurayinterface IBluetooth { 22f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 23f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Returns true if the Bluetooth adapter is powered and ready to use. This 24f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * is equivalent to "getState() == ADAPTER_STATE_ON". 25f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 26f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray boolean isEnabled(); 27f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 28f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 29f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Returns the current Bluetooth adapter state. The return value can be one of 30f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * the following: 31f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * 32f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * - ADAPTER_STATE_OFF = 10 33f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * - ADAPTER_STATE_TURNING_ON = 11 34f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * - ADAPTER_STATE_ON = 12 35f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * - ADAPTER_STATE_TURNING_OFF = 13 36f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 37f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray int getState(); 38f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 39f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 40f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Turns on the Bluetooth radio. This function initiates the procedure to 41f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * bring the adapter state from ADAPTER_STATE_OFF to ADAPTER_STATE_ON. Returns 42f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * false, if the state is not ADAPTER_STATE_OFF or if there is an error while 43f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * initiating the operation. On success, the adapter state will be 44f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * asynchronously updated to ADAPTER_STATE_TURNING_ON and eventually to 45f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * ADAPTER_STATE_ON. Callers can monitor the status of this call by observing 46f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * the IBluetoothCallback.onBluetoothStateChange callback. 47f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 48f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray boolean enable(); 49f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 50f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 51f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Turns off the Bluetooth radio. This function initiates the procedure to 52f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * bring the adapter state from ADAPTER_STATE_ON to ADAPTER_STATE_OFF. Returns 53f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * false, if the state is not ADAPTER_STATE_ON or if there is an error while 54f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * initiating the operation. On success, the adapter state will be 55f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * asynchronously updated to ADAPTER_STATE_TURNING_OFF and eventually to 56f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * ADAPTER_STATE_OFF. Callers can monitor the status of this call by observing 57f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * the IBluetoothCallback.onBluetoothStateChange callback. 58f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 59f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray boolean disable(); 60f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 61f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 62f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Returns the identity Bluetooth Device Address (BD_ADDR) assigned to the 63f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * underlying Bluetooth controller. Returns a string of the form 64f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * "XX:XX:XX:XX:XX:XX", where each "X" is a hexadecimal digit. Returns 65f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * "00:00:00:00:00:00" if the address is not known, which is usually the case 66f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * before the adapter is enabled for the first time. 67f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 68f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray String getAddress(); 69f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 70f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 71f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Sets the name assigned to the Bluetooth adapter. This is the name that will 72f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * be seen by remote devices during discovery. Returns false if the operation 73f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * fails. 74f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 75f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray boolean setName(in String name); 76f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 77f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 78f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Returns the current name assigned to the Bluetooth adapter. This is the 79f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * name that is seen by remote devices during discovery. If the controller has 80f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * not been initialized yet (before the first time it gets enabled), this will 81f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * return "not-initialized". 82f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 83f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray String getName(); 84f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 85f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 86f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Registers a callback receiver which can be used to listen to state updates 87f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * from the adapter. The Bluetooth daemon will automatically register this if 88f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * the owning process dies. 89f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 90f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray void registerCallback(in IBluetoothCallback callback); 91f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 92f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 93f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Unregisters a previously registered callback. 94f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 95f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray void unregisterCallback(in IBluetoothCallback callback); 96f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 97f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 98f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Returns true, if the multi-advertisement feature is supported. Returns 99f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * false, if this device can only advertise a single instance. 100f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 101f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray boolean isMultiAdvertisementSupported(); 102f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 103f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 104f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Returns a binder that can be used to interact with Low-Energy features. 105f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 106f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray IBluetoothLowEnergy getLowEnergyInterface(); 107f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 108f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 109900c9dc00243990f96922dee904728be1732276fArman Uguray * Returns a binder that can be used to interact with GATT client-role 110900c9dc00243990f96922dee904728be1732276fArman Uguray * features. 111900c9dc00243990f96922dee904728be1732276fArman Uguray */ 112900c9dc00243990f96922dee904728be1732276fArman Uguray IBluetoothGattClient getGattClientInterface(); 113900c9dc00243990f96922dee904728be1732276fArman Uguray 114900c9dc00243990f96922dee904728be1732276fArman Uguray /** 115f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Returns a binder that can be used to interact with GATT server-role 116f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * features. 117f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 118f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray IBluetoothGattServer getGattServerInterface(); 119f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray} 120