• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2020 The Chromium OS Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 #ifndef CRAS_BT_BATTERY_PROVIDER_H_
7 #define CRAS_BT_BATTERY_PROVIDER_H_
8 
9 #include <dbus/dbus.h>
10 #include <stdbool.h>
11 
12 #include "cras_bt_adapter.h"
13 
14 /* Object to represent a battery that is exposed to BlueZ. */
15 struct cras_bt_battery {
16 	char *address;
17 	char *object_path;
18 	char *device_path;
19 	uint32_t level;
20 	struct cras_bt_battery *next;
21 };
22 
23 /* Object to register as battery provider so that bluetoothd will monitor
24  * battery objects that we expose.
25  */
26 struct cras_bt_battery_provider {
27 	const char *object_path;
28 	const char *interface;
29 	DBusConnection *conn;
30 	bool is_registered;
31 	struct cras_observer_client *observer;
32 	struct cras_bt_battery *batteries;
33 };
34 
35 /* Registers battery provider to bluetoothd. This is used when a Bluetooth
36  * adapter got enumerated.
37  * Args:
38  *    conn - The D-Bus connection.
39  *    adapter - The enumerated bluetooth adapter.
40  */
41 int cras_bt_register_battery_provider(DBusConnection *conn,
42 				      const struct cras_bt_adapter *adapter);
43 
44 /* Resets internal state of battery provider. */
45 void cras_bt_battery_provider_reset();
46 
47 #endif /* CRAS_BT_BATTERY_PROVIDER_H_ */
48