1 /* 2 * Copyright 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_INCLUDE_BT_HEARING_AID_H 18 #define ANDROID_INCLUDE_BT_HEARING_AID_H 19 20 #include <hardware/bluetooth.h> 21 #include <raw_address.h> 22 23 namespace bluetooth { 24 namespace hearing_aid { 25 26 enum class ConnectionState { 27 DISCONNECTED = 0, 28 CONNECTING, 29 CONNECTED, 30 DISCONNECTING 31 }; 32 33 class HearingAidCallbacks { 34 public: 35 virtual ~HearingAidCallbacks() = default; 36 37 /** Callback for profile connection state change */ 38 virtual void OnConnectionState(ConnectionState state, 39 const RawAddress& address) = 0; 40 41 /** Callback for device being available. Is executed when devices are loaded 42 * from storage on stack bringup, and when new device is connected to profile. 43 * Main purpose of this callback is to keep its users informed of device 44 * capabilities and hiSyncId. 45 */ 46 virtual void OnDeviceAvailable(uint8_t capabilities, uint64_t hiSyncId, 47 const RawAddress& address) = 0; 48 }; 49 50 class HearingAidInterface { 51 public: 52 virtual ~HearingAidInterface() = default; 53 54 /** Register the Hearing Aid callbacks */ 55 virtual void Init(HearingAidCallbacks* callbacks) = 0; 56 57 /** Connect to Hearing Aid */ 58 virtual void Connect(const RawAddress& address) = 0; 59 60 /** Disconnect from Hearing Aid */ 61 virtual void Disconnect(const RawAddress& address) = 0; 62 63 /** Add a hearing aid device to acceptlist */ 64 virtual void AddToAcceptlist(const RawAddress& address) = 0; 65 66 /** Set the volume */ 67 virtual void SetVolume(int8_t volume) = 0; 68 69 /** Closes the interface. */ 70 virtual void Cleanup(void) = 0; 71 72 /* Called when Hearing Aid is unbonded. */ 73 virtual void RemoveDevice(const RawAddress& address) = 0; 74 }; 75 76 } // namespace hearing_aid 77 } // namespace bluetooth 78 79 #endif /* ANDROID_INCLUDE_BT_HEARING_AID_H */ 80