• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
22 namespace bluetooth {
23 namespace hearing_aid {
24 
25 enum class ConnectionState {
26   DISCONNECTED = 0,
27   CONNECTING,
28   CONNECTED,
29   DISCONNECTING
30 };
31 
32 class HearingAidCallbacks {
33  public:
34   virtual ~HearingAidCallbacks() = default;
35 
36   /** Callback for profile connection state change */
37   virtual void OnConnectionState(ConnectionState state,
38                                  const RawAddress& address) = 0;
39 
40   /** Callback for device being available. Is executed when devices are loaded
41    * from storage on stack bringup, and when new device is connected to profile.
42    * Main purpose of this callback is to keep its users informed of device
43    * capabilities and hiSyncId.
44    */
45   virtual void OnDeviceAvailable(uint8_t capabilities, uint64_t hiSyncId,
46                                  const RawAddress& address) = 0;
47 };
48 
49 class HearingAidInterface {
50  public:
51   virtual ~HearingAidInterface() = default;
52 
53   /** Register the Hearing Aid callbacks */
54   virtual void Init(HearingAidCallbacks* callbacks) = 0;
55 
56   /** Connect to Hearing Aid */
57   virtual void Connect(const RawAddress& address) = 0;
58 
59   /** Disconnect from Hearing Aid */
60   virtual void Disconnect(const RawAddress& address) = 0;
61 
62   /** Add a hearing aid device to white list */
63   virtual void AddToWhiteList(const RawAddress& address) = 0;
64 
65   /** Set the volume */
66   virtual void SetVolume(int8_t volume) = 0;
67 
68   /** Closes the interface. */
69   virtual void Cleanup(void) = 0;
70 
71   /* Called when Hearing Aid is unbonded. */
72   virtual void RemoveDevice(const RawAddress& address) = 0;
73 };
74 
75 }  // namespace hearing_aid
76 }  // namespace bluetooth
77 
78 #endif /* ANDROID_INCLUDE_BT_HEARING_AID_H */
79