1 /**
2  ****************************************************************************************
3  *
4  * @file bass_task.h
5  *
6  * @brief Header file - Battery Service Server Role Task.
7  *
8  * Copyright (C) RivieraWaves 2009-2016
9  *
10  *
11  ****************************************************************************************
12  */
13 
14 
15 #ifndef _BASS_TASK_H_
16 #define _BASS_TASK_H_
17 
18 /**
19  ****************************************************************************************
20  * @addtogroup BAPSTASK Task
21  * @ingroup BAPS
22  * @brief Battery 'Profile' Task.
23  *
24  * The BAPS_TASK is responsible for handling the messages coming in and out of the
25  * @ref BAPS block of the BLE Host.
26  *
27  * @{
28  ****************************************************************************************
29  */
30 
31 /*
32  * INCLUDE FILES
33  ****************************************************************************************
34  */
35 #include "prf_types.h"
36 #include "rwip_task.h" // Task definitions
37 
38 /*
39  * DEFINES
40  ****************************************************************************************
41  */
42 
43 #define BAS_BATTERY_LVL_MAX               (100)
44 
45 
46 ///Maximal number of BAS that can be added in the DB
47 #define BASS_NB_BAS_INSTANCES_MAX         (2)
48 
49 
50 /*
51  * TYPE DEFINITIONS
52  ****************************************************************************************
53  */
54 
55 
56 /// Messages for Battery Server
57 enum bass_msg_id
58 {
59     /// Start the Battery Server - at connection used to restore bond data
60     BASS_ENABLE_REQ = TASK_FIRST_MSG(TASK_ID_BASS),
61     /// Confirmation of the Battery Server start
62     BASS_ENABLE_RSP,
63     /// Battery Level Value Update Request
64     BASS_BATT_LEVEL_UPD_REQ,
65     /// Inform APP if Battery Level value has been notified or not
66     BASS_BATT_LEVEL_UPD_RSP,
67     /// Inform APP that Battery Level Notification Configuration has been changed - use to update bond data
68     BASS_BATT_LEVEL_NTF_CFG_IND,
69 };
70 
71 /// Features Flag Masks
72 enum bass_features
73 {
74     /// Battery Level Characteristic doesn't support notifications
75     BAS_BATT_LVL_NTF_NOT_SUP,
76     /// Battery Level Characteristic support notifications
77     BAS_BATT_LVL_NTF_SUP,
78 };
79 
80 
81 /*
82  * APIs Structures
83  ****************************************************************************************
84  */
85 
86 /// Parameters for the database creation
87 struct bass_db_cfg
88 {
89     /// Number of BAS to add
90     uint8_t bas_nb;
91     /// Features of each BAS instance
92     uint8_t features[BASS_NB_BAS_INSTANCES_MAX];
93     /// Battery Level Characteristic Presentation Format - Should not change during connection
94     struct prf_char_pres_fmt batt_level_pres_format[BASS_NB_BAS_INSTANCES_MAX];
95 };
96 
97 /// Parameters of the @ref BASS_ENABLE_REQ message
98 struct bass_enable_req
99 {
100     /// connection index
101     uint8_t  conidx;
102     /// Notification Configuration
103     uint8_t  ntf_cfg;
104     /// Old Battery Level used to decide if notification should be triggered
105     uint8_t  old_batt_lvl[BASS_NB_BAS_INSTANCES_MAX];
106 };
107 
108 /// Parameters of the @ref BASS_ENABLE_RSP message
109 struct bass_enable_rsp
110 {
111     /// connection index
112     uint8_t conidx;
113     ///status
114     uint8_t status;
115 };
116 
117 ///Parameters of the @ref BASS_BATT_LEVEL_UPD_REQ message
118 struct bass_batt_level_upd_req
119 {
120     /// BAS instance
121     uint8_t bas_instance;
122     /// Battery Level
123     uint8_t batt_level;
124 };
125 
126 ///Parameters of the @ref BAPS_BATT_LEVEL_UPD_RSP message
127 struct bass_batt_level_upd_rsp
128 {
129     ///status
130     uint8_t status;
131 };
132 
133 ///Parameters of the @ref BASS_BATT_LEVEL_NTF_CFG_IND message
134 struct bass_batt_level_ntf_cfg_ind
135 {
136     /// connection index
137     uint8_t  conidx;
138     ///Notification Configuration
139     uint8_t  ntf_cfg;
140 };
141 
142 /// @} BASSTASK
143 
144 #endif /* _BASS_TASK_H_ */
145