ias_c.h
Go to the documentation of this file.
1 /**
2 *****************************************************************************************
3 *
4 * @file ias_c.h
5 *
6 * @brief Immediate Alert Service Client API
7 *
8 *****************************************************************************************
9 * @attention
10 #####Copyright (c) 2019 GOODIX
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 * Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 * Neither the name of GOODIX nor the names of its contributors may be used
21 to endorse or promote products derived from this software without
22 specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35 *****************************************************************************************
36 */
37
38 /**
39 * @addtogroup BLE_SRV BLE Services
40 * @{
41 */
42
43 /**
44 * @defgroup BLE_SDK_IAS_C Immediate Alert Service Client (IAS_C)
45 * @{
46 * @brief Immediate Alert Service Client module.
47 *
48 * @details The Immediate Alert Service Client contains the APIs and types, which can be used by the
49 * application to discovery of Immediate Alert Service of peer and interact with it.
50 *
51 * The application must provide an event handler to register, then call \ref ias_client_init().
52 * After Immediate Alert Service Client discoveries peer Immediate Alert Service, application can call
53 * \ref ias_c_alert_level_set() to set alert level on peer.
54 */
55
56 #ifndef __IAS_C_H__
57 #define __IAS_C_H__
58
59 #include "gr_includes.h"
60 #include "ble_prf_types.h"
61 #include "custom_config.h"
62 #include <stdint.h>
63 #include <stdbool.h>
64
65 /**
66 * @defgroup IAS_C_MACRO Defines
67 * @{
68 */
69 #define IAS_C_CONNECTION_MAX 10 /**< Maximum number of IAS Client connections. */
70 /** @} */
71
72 /**
73 * @defgroup IAS_C_ENUM Enumerations
74 * @{
75 */
76 /**@brief Immediate Alert Service Alert levels. */
77 typedef enum
78 {
79 IAS_C_ALERT_NONE, /**< No alert. */
80 IAS_C_ALERT_MILD, /**< Mild alert. */
81 IAS_C_ALERT_HIGH, /**< High alert. */
82 } ias_c_alert_level_t;
83
84 /**@brief Immediate Alert Service Client event type. */
85 typedef enum
86 {
87 IAS_C_EVT_INVALID, /**< IAS Client invalid event. */
88 IAS_C_EVT_DISCOVERY_COMPLETE, /**< IAS Client has found BAS service and its characteristics. */
89 IAS_C_EVT_DISCOVERY_FAIL, /**< IAS Client found BAS service failed because of invalid operation or no found at the peer. */
90 IAS_C_EVT_ALERT_LEVEL_SET_SUCCESS, /**< IAS Client has set Alert Level characteristic. */
91 IAS_C_EVT_ALERT_LEVEL_SET_ERR, /**< Error occured when IAS Client set Alert Level characteristic. */
92 } ias_c_evt_type_t;
93 /** @} */
94
95 /**
96 * @defgroup IAS_C_STRUCT Structures
97 * @{
98 */
99 /**@brief Handles on the connected peer device needed to interact with it. */
100 typedef struct
101 {
102 uint16_t ias_srvc_start_handle; /**< IAS Service start handle. */
103 uint16_t ias_srvc_end_handle; /**< IAS Service end handle. */
104 uint16_t ias_alert_level_handle; /**< IAS Alert Level characteristic Value handle which has been got from peer. */
105 } ias_c_handles_t;
106
107 /**@brief Immediate Alert Service Client event. */
108 typedef struct
109 {
110 uint8_t conn_idx; /**< The connection index. */
111 ias_c_evt_type_t evt_type; /**< IAS Client event type. */
112 } ias_c_evt_t;
113 /** @} */
114
115 /**
116 * @defgroup IAS_C_TYPEDEF Typedefs
117 * @{
118 */
119 /**@brief Immediate Alert Service Client event handler type. */
120 typedef void (*ias_c_evt_handler_t)(ias_c_evt_t *p_evt);
121 /** @} */
122
123 /**
124 * @defgroup IAS_C_FUNCTION Functions
125 * @{
126 */
127 /**
128 *****************************************************************************************
129 * @brief Register IAS Client event handler.
130 *
131 * @param[in] evt_handler: Immediate Alert Service Client event handler.
132 *
133 * @return Result of initialization.
134 *****************************************************************************************
135 */
136 sdk_err_t ias_client_init(ias_c_evt_handler_t evt_handler);
137
138 /**
139 *****************************************************************************************
140 * @brief Discovery Immediate Alert Service on peer.
141 *
142 * @param[in] conn_idx: Index of connection.
143 *
144 * @return Operation result.
145 *****************************************************************************************
146 */
147 sdk_err_t ias_c_disc_srvc_start(uint8_t conn_idx);
148
149 /**
150 *****************************************************************************************
151 * @brief Enable or disable peer Alert Level characteristic notify.
152 *
153 * @param[in] conn_idx: Index of connection.
154 * @param[in] alert_level: Alert level.
155 *
156 * @return Operation result.
157 *****************************************************************************************
158 */
159 sdk_err_t ias_c_alert_level_set(uint8_t conn_idx, ias_c_alert_level_t alert_level);
160
161 /** @} */
162
163 #endif
164 /** @} */
165 /** @} */
ias_c_alert_level_set
sdk_err_t ias_c_alert_level_set(uint8_t conn_idx, ias_c_alert_level_t alert_level)
Enable or disable peer Alert Level characteristic notify.
ias_c_evt_handler_t
void(* ias_c_evt_handler_t)(ias_c_evt_t *p_evt)
Immediate Alert Service Client event handler type.
Definition: ias_c.h:120
IAS_C_EVT_ALERT_LEVEL_SET_SUCCESS
@ IAS_C_EVT_ALERT_LEVEL_SET_SUCCESS
IAS Client has set Alert Level characteristic.
Definition: ias_c.h:90
gr_includes.h
Include Files API.
ias_c_handles_t::ias_alert_level_handle
uint16_t ias_alert_level_handle
IAS Alert Level characteristic Value handle which has been got from peer.
Definition: ias_c.h:104
ias_c_evt_t
Immediate Alert Service Client event.
Definition: ias_c.h:109
ias_c_handles_t::ias_srvc_end_handle
uint16_t ias_srvc_end_handle
IAS Service end handle.
Definition: ias_c.h:103
ias_c_evt_t::evt_type
ias_c_evt_type_t evt_type
IAS Client event type.
Definition: ias_c.h:111
IAS_C_EVT_DISCOVERY_COMPLETE
@ IAS_C_EVT_DISCOVERY_COMPLETE
IAS Client has found BAS service and its characteristics.
Definition: ias_c.h:88
IAS_C_ALERT_HIGH
@ IAS_C_ALERT_HIGH
High alert.
Definition: ias_c.h:81
IAS_C_EVT_INVALID
@ IAS_C_EVT_INVALID
IAS Client invalid event.
Definition: ias_c.h:87
IAS_C_ALERT_MILD
@ IAS_C_ALERT_MILD
Mild alert.
Definition: ias_c.h:80
IAS_C_EVT_ALERT_LEVEL_SET_ERR
@ IAS_C_EVT_ALERT_LEVEL_SET_ERR
Error occured when IAS Client set Alert Level characteristic.
Definition: ias_c.h:91
ble_prf_types.h
Profile/Service Common Types.
ias_c_alert_level_t
ias_c_alert_level_t
Immediate Alert Service Alert levels.
Definition: ias_c.h:78
IAS_C_ALERT_NONE
@ IAS_C_ALERT_NONE
No alert.
Definition: ias_c.h:79
ias_c_handles_t
Handles on the connected peer device needed to interact with it.
Definition: ias_c.h:101
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:273
ias_c_disc_srvc_start
sdk_err_t ias_c_disc_srvc_start(uint8_t conn_idx)
Discovery Immediate Alert Service on peer.
ias_c_evt_type_t
ias_c_evt_type_t
Immediate Alert Service Client event type.
Definition: ias_c.h:86
ias_client_init
sdk_err_t ias_client_init(ias_c_evt_handler_t evt_handler)
Register IAS Client event handler.
IAS_C_EVT_DISCOVERY_FAIL
@ IAS_C_EVT_DISCOVERY_FAIL
IAS Client found BAS service failed because of invalid operation or no found at the peer.
Definition: ias_c.h:89
ias_c_evt_t::conn_idx
uint8_t conn_idx
The connection index.
Definition: ias_c.h:110
ias_c_handles_t::ias_srvc_start_handle
uint16_t ias_srvc_start_handle
IAS Service start handle.
Definition: ias_c.h:102