ras_ad.h
Go to the documentation of this file.
1 /**
2 *****************************************************************************************
3 *
4 * @file ras_ad.h
5 *
6 * @brief Ranging Service Adaptor.
7 *
8 *****************************************************************************************
9 * @attention
10 #####Copyright (c) 2024 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 #ifndef __RAS_AD_H__
39 #define __RAS_AD_H__
40
41 #include "gr_includes.h"
42 #include <stdbool.h>
43 #include <stdint.h>
44
45 #define RAS_AD_FEA_MAX_LEN 4 /**< Maximun length of feature value. */
46 #define RAS_AD_DATA_MAX_LEN 244 /**< Maximun length of ranging data value(251 - 4 - 3). */
47 #define RAS_AD_CP_MAX_LEN 5 /**< Maximun length of control point value. */
48 #define RAS_AD_DATA_READY_MAX_LEN 2 /**< Maximun length of ranging data ready value. */
49 #define RAS_AD_DATA_OW_MAX_LEN 2 /**< Maximun length of ranging data overwritten value. */
50
51 /**@brief Ranging Service Adaptor Attributes Indexes. */
52 typedef enum
53 {
54 RAS_AD_IDX_SVC,
55
56 RAS_AD_IDX_FEA_CHAR,
57 RAS_AD_IDX_FEA_VAL,
58
59 RAS_AD_IDX_RT_DATA_CHAR,
60 RAS_AD_IDX_RT_DATA_VAL,
61 RAS_AD_IDX_RT_DATA_CCCD_CFG,
62
63 RAS_AD_IDX_OD_DATA_CHAR,
64 RAS_AD_IDX_OD_DATA_VAL,
65 RAS_AD_IDX_OD_DATA_CCCD_CFG,
66
67 RAS_AD_IDX_CP_CHAR,
68 RAS_AD_IDX_CP_VAL,
69 RAS_AD_IDX_CP_CCCD_CFG,
70
71 RAS_AD_IDX_DATA_READY_CHAR,
72 RAS_AD_IDX_DATA_READY_VAL,
73 RAS_AD_IDX_DATA_READY_CCCD_CFG,
74
75 RAS_AD_IDX_DATA_OW_CHAR,
76 RAS_AD_IDX_DATA_OW_VAL,
77 RAS_AD_IDX_DATA_OW_CCCD_CFG,
78
79 RAS_AD_IDX_NB,
80 } ras_ad_attr_idx_t;
81
82 /**@brief Ranging Service Adaptor event types. */
83 typedef enum
84 {
85 RAS_AD_EVT_INVALID, /**< That it's an invalid event. */
86 RAS_AD_EVT_SET_RT_DATA_CCCD, /**< Set CCCD for real time data. */
87 RAS_AD_EVT_SET_OD_DATA_CCCD, /**< Set CCCD for on demand data. */
88 RAS_AD_EVT_SET_CP_CCCD, /**< Set CCCD for control point. */
89 RAS_AD_EVT_SET_DATA_READY_CCCD, /**< Set CCCD for data ready. */
90 RAS_AD_EVT_SET_DATA_OW_CCCD, /**< Set CCCD for data overwritten. */
91 RAS_AD_EVT_WRITE_CP, /**< Write control point. */
92 RAS_AD_EVT_SEND_NTI_IND_CMP, /**< Send notification or indication complete. */
93 } ras_ad_evt_type_t;
94
95 /**@brief The type for sending data. */
96 typedef enum
97 {
98 RAS_AD_SEND_DATA_TYPE_INVALID, /**< Invalid type. */
99 RAS_AD_SEND_DATA_TYPE_NOTIFY, /**< Send data using notification. */
100 RAS_AD_SEND_DATA_TYPE_INDICATE, /**< Send data using indication. */
101 } ras_ad_send_data_type_t;
102
103 /**@brief Event parameter for RAS_AD_EVT_SEND_NTI_IND_CMP. */
104 typedef struct
105 {
106 uint8_t type;
107 uint8_t status;
108 uint8_t att_idx;
109 } ras_ad_send_nti_ind_cmp_info_t;
110
111 /**@brief Event parameter for set cccd. */
112 typedef struct
113 {
114 uint16_t cccd_value;
115 } ras_ad_set_cccd_info_t;
116
117 /**@brief Raning Service Adaptor event. */
118 typedef struct
119 {
120 uint8_t conn_idx; /**< The index of the connection. */
121 ras_ad_evt_type_t evt_type; /**< The RAS Adaptor event type. */
122 uint16_t evt_param_len; /**< The length for event parameter. */
123 uint8_t *evt_param; /**< Event parameter. */
124 } ras_ad_evt_t;
125
126 /**@brief Ranging Service event handler type. */
127 typedef void (*ras_ad_evt_handler_t)(ras_ad_evt_t *p_evt);
128
129 #ifdef __cplusplus
130 extern "C"
131 {
132 #endif /* __cplusplus */
133
134 /**
135 *****************************************************************************************
136 * @brief Initialize Ranging Service Adaptor instances and add to the DB.
137 *
138 * @param[in] evt_handler: Event handler for the gatt operation.
139 * @param[in] features: Features to support.
140 *
141 * @return Result of Ranging Service Adaptor initialization.
142 *****************************************************************************************
143 */
144 sdk_err_t ras_ad_init(ras_ad_evt_handler_t evt_handler, uint32_t features);
145
146 /**
147 *****************************************************************************************
148 * @brief Send notification or indication.
149 *
150 * @param[in] conn_idx: Connection index.
151 * @param[in] type: Type for sending data, @ref ras_ad_send_data_type_t.
152 * @param[in] att_idx: Attribute index, @ref ras_ad_attr_idx_t.
153 * @param[in] data_len: Data length.
154 * @param[in] p_data: Pointer to the data.
155 *
156 * @return Result of Ranging Service Adaptor initialization.
157 *****************************************************************************************
158 */
159 sdk_err_t ras_ad_send_noti_ind(uint8_t conn_idx, uint8_t type, uint8_t att_idx, uint16_t data_len, uint8_t *p_data);
160
161 #ifdef __cplusplus
162 }
163 #endif /* __cplusplus */
164
165 #endif
166
RAS_AD_IDX_NB
@ RAS_AD_IDX_NB
Definition: ras_ad.h:79
RAS_AD_EVT_INVALID
@ RAS_AD_EVT_INVALID
Definition: ras_ad.h:85
RAS_AD_IDX_DATA_OW_VAL
@ RAS_AD_IDX_DATA_OW_VAL
Definition: ras_ad.h:76
RAS_AD_IDX_RT_DATA_VAL
@ RAS_AD_IDX_RT_DATA_VAL
Definition: ras_ad.h:60
RAS_AD_EVT_SEND_NTI_IND_CMP
@ RAS_AD_EVT_SEND_NTI_IND_CMP
Definition: ras_ad.h:92
ras_ad_attr_idx_t
ras_ad_attr_idx_t
Ranging Service Adaptor Attributes Indexes.
Definition: ras_ad.h:53
RAS_AD_IDX_OD_DATA_CCCD_CFG
@ RAS_AD_IDX_OD_DATA_CCCD_CFG
Definition: ras_ad.h:65
RAS_AD_EVT_SET_OD_DATA_CCCD
@ RAS_AD_EVT_SET_OD_DATA_CCCD
Definition: ras_ad.h:87
ras_ad_set_cccd_info_t
Event parameter for set cccd.
Definition: ras_ad.h:113
ras_ad_evt_handler_t
void(* ras_ad_evt_handler_t)(ras_ad_evt_t *p_evt)
Ranging Service event handler type.
Definition: ras_ad.h:127
ras_ad_evt_t::evt_param_len
uint16_t evt_param_len
Definition: ras_ad.h:122
ras_ad_evt_t::conn_idx
uint8_t conn_idx
Definition: ras_ad.h:120
gr_includes.h
Include Files API.
RAS_AD_IDX_OD_DATA_VAL
@ RAS_AD_IDX_OD_DATA_VAL
Definition: ras_ad.h:64
RAS_AD_EVT_SET_DATA_OW_CCCD
@ RAS_AD_EVT_SET_DATA_OW_CCCD
Definition: ras_ad.h:90
RAS_AD_IDX_CP_VAL
@ RAS_AD_IDX_CP_VAL
Definition: ras_ad.h:68
RAS_AD_IDX_CP_CCCD_CFG
@ RAS_AD_IDX_CP_CCCD_CFG
Definition: ras_ad.h:69
RAS_AD_SEND_DATA_TYPE_INDICATE
@ RAS_AD_SEND_DATA_TYPE_INDICATE
Definition: ras_ad.h:100
RAS_AD_IDX_SVC
@ RAS_AD_IDX_SVC
Definition: ras_ad.h:54
RAS_AD_IDX_FEA_CHAR
@ RAS_AD_IDX_FEA_CHAR
Definition: ras_ad.h:56
ras_ad_evt_t::evt_param
uint8_t * evt_param
Definition: ras_ad.h:123
ras_ad_send_nti_ind_cmp_info_t::type
uint8_t type
Definition: ras_ad.h:106
RAS_AD_IDX_DATA_READY_CCCD_CFG
@ RAS_AD_IDX_DATA_READY_CCCD_CFG
Definition: ras_ad.h:73
RAS_AD_SEND_DATA_TYPE_NOTIFY
@ RAS_AD_SEND_DATA_TYPE_NOTIFY
Definition: ras_ad.h:99
ras_ad_send_data_type_t
ras_ad_send_data_type_t
The type for sending data.
Definition: ras_ad.h:97
RAS_AD_IDX_DATA_READY_CHAR
@ RAS_AD_IDX_DATA_READY_CHAR
Definition: ras_ad.h:71
RAS_AD_IDX_CP_CHAR
@ RAS_AD_IDX_CP_CHAR
Definition: ras_ad.h:67
RAS_AD_IDX_RT_DATA_CHAR
@ RAS_AD_IDX_RT_DATA_CHAR
Definition: ras_ad.h:59
ras_ad_evt_t::evt_type
ras_ad_evt_type_t evt_type
Definition: ras_ad.h:121
RAS_AD_EVT_SET_CP_CCCD
@ RAS_AD_EVT_SET_CP_CCCD
Definition: ras_ad.h:88
RAS_AD_EVT_WRITE_CP
@ RAS_AD_EVT_WRITE_CP
Definition: ras_ad.h:91
RAS_AD_IDX_DATA_OW_CHAR
@ RAS_AD_IDX_DATA_OW_CHAR
Definition: ras_ad.h:75
ras_ad_send_nti_ind_cmp_info_t::status
uint8_t status
Definition: ras_ad.h:107
ras_ad_evt_type_t
ras_ad_evt_type_t
Ranging Service Adaptor event types.
Definition: ras_ad.h:84
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:290
RAS_AD_IDX_RT_DATA_CCCD_CFG
@ RAS_AD_IDX_RT_DATA_CCCD_CFG
Definition: ras_ad.h:61
RAS_AD_IDX_DATA_READY_VAL
@ RAS_AD_IDX_DATA_READY_VAL
Definition: ras_ad.h:72
RAS_AD_EVT_SET_DATA_READY_CCCD
@ RAS_AD_EVT_SET_DATA_READY_CCCD
Definition: ras_ad.h:89
ras_ad_set_cccd_info_t::cccd_value
uint16_t cccd_value
Definition: ras_ad.h:114
RAS_AD_IDX_DATA_OW_CCCD_CFG
@ RAS_AD_IDX_DATA_OW_CCCD_CFG
Definition: ras_ad.h:77
RAS_AD_SEND_DATA_TYPE_INVALID
@ RAS_AD_SEND_DATA_TYPE_INVALID
Definition: ras_ad.h:98
RAS_AD_IDX_FEA_VAL
@ RAS_AD_IDX_FEA_VAL
Definition: ras_ad.h:57
ras_ad_init
sdk_err_t ras_ad_init(ras_ad_evt_handler_t evt_handler, uint32_t features)
Initialize Ranging Service Adaptor instances and add to the DB.
RAS_AD_IDX_OD_DATA_CHAR
@ RAS_AD_IDX_OD_DATA_CHAR
Definition: ras_ad.h:63
ras_ad_send_nti_ind_cmp_info_t::att_idx
uint8_t att_idx
Definition: ras_ad.h:108
ras_ad_evt_t
Raning Service Adaptor event.
Definition: ras_ad.h:119
ras_ad_send_nti_ind_cmp_info_t
Event parameter for RAS_AD_EVT_SEND_NTI_IND_CMP.
Definition: ras_ad.h:105
ras_ad_send_noti_ind
sdk_err_t ras_ad_send_noti_ind(uint8_t conn_idx, uint8_t type, uint8_t att_idx, uint16_t data_len, uint8_t *p_data)
Send notification or indication.
RAS_AD_EVT_SET_RT_DATA_CCCD
@ RAS_AD_EVT_SET_RT_DATA_CCCD
Definition: ras_ad.h:86