1/******************************************************************************
2 *
3 *  Copyright (C) 1999-2012 Broadcom Corporation
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19#ifndef SRVC_BATTERY_INT_H
20#define SRVC_BATTERY_INT_H
21
22#include "bt_target.h"
23#include "gatt_api.h"
24#include "srvc_api.h"
25
26#ifndef BA_MAX_INT_NUM
27#define BA_MAX_INT_NUM 4
28#endif
29
30#define BATTERY_LEVEL_SIZE 1
31
32typedef struct {
33  uint8_t app_id;
34  uint16_t ba_level_hdl;
35  uint16_t clt_cfg_hdl;
36  uint16_t rpt_ref_hdl;
37  uint16_t pres_fmt_hdl;
38
39  tBA_CBACK* p_cback;
40
41  uint16_t pending_handle;
42  uint8_t pending_clcb_idx;
43  uint8_t pending_evt;
44
45} tBA_INST;
46
47typedef struct {
48  tBA_INST battery_inst[BA_MAX_INT_NUM];
49  uint8_t inst_id;
50  bool enabled;
51
52} tBATTERY_CB;
53
54/* Global GATT data */
55extern tBATTERY_CB battery_cb;
56
57extern bool battery_valid_handle_range(uint16_t handle);
58
59extern uint8_t battery_s_write_attr_value(uint8_t clcb_idx,
60                                          tGATT_WRITE_REQ* p_value,
61                                          tGATT_STATUS* p_status);
62extern uint8_t battery_s_read_attr_value(uint8_t clcb_idx, uint16_t handle,
63                                         tGATT_VALUE* p_value, bool is_long,
64                                         tGATT_STATUS* p_status);
65
66#endif
67