ras_c.h
Go to the documentation of this file.
1 #ifndef __RAS_C_H__
2 #define __RAS_C_H__
3
4 #include <stdint.h>
5 #include "ble_error.h"
6 #include "ras_common.h"
7
8 #ifdef __cplusplus
9 extern "C"
10 {
11 #endif /* __cplusplus */
12
13 typedef enum
14 {
15 RAS_C_EVT_INVALID = 0x00,
16 RAS_C_EVT_DISCOVER_COMPLETED = 0x01,
17 RAS_C_EVT_DISCOVER_FAILED = 0x02,
18 RAS_C_EVT_WRITE_RSP = 0x03,
19 RAS_C_EVT_WRITE_ERR = 0x04,
20 RAS_C_EVT_READ_RSP = 0x05,
21 RAS_C_EVT_SUBEVT_REPORT = 0x06,
22 } ras_c_evt_type_t;
23
24 typedef enum
25 {
26 RAS_C_WRITE_RT_RA_DATA_IND_NTF_CFG = 0x00,
27 RAS_C_WRITE_ON_DEMAND_RA_DATA_IND_NTF_CFG = 0x01,
28 RAS_C_WRITE_RAS_CP = 0x02,
29 RAS_C_WRITE_RAS_CP_IND_NTF_CFG = 0x03,
30 RAS_C_WRITE_RA_DATA_READY_IND_NTF_CFG = 0x04,
31 RAS_C_WRITE_RA_DATA_OVERWRITE_IND_NTF_CFG = 0x05,
32 RAS_C_WRITE_TYPE_INVALID = 0x06,
33 } ras_c_write_type_t;
34
35 typedef enum
36 {
37 RAS_C_READ_RAS_FEATURE = 0x00,
38 RAS_C_READ_RT_RA_DATA_IND_NTF_CFG,
39 RAS_C_READ_ON_DEMAND_RA_DATA_IND_NTF_CFG,
40 RAS_C_READ_RAS_CP_IND_NTF_CFG,
41 RAS_C_READ_RA_DATA_READY_IND_NTF_CFG,
42 RAS_C_READ_RA_DATA_OVERWRITE_IND_NTF_CFG,
43 RAS_C_READ_TYPE_INVALID = 0x06,
44 } ras_c_read_type_t;
45
46 typedef enum
47 {
48 RAS_C_DIS_NTF_IND = 0x0000, /**< Stop notification/indication. */
49 RAS_C_EN_NTF = 0x0001, /**< Start notification. */
50 RAS_C_EN_IND = 0x0002, /**< Start indication. */
51 RAS_C_EN_NTF_IND = 0x0003, /**< Start notification/indication. */
52 } ras_c_cccd_value_type_t;
53
54 typedef struct
55 {
56 ras_c_write_type_t write_type; /**< Characteristic or Descriptor type. */
57 uint16_t length; /**< Write length. */
58 uint8_t *p_data; /**< Value to be written. */
59 } ras_c_write_req_t;
60
61 typedef struct
62 {
63 ras_c_write_type_t write_type;
64 uint8_t err_code;
65 } ras_c_write_rsp_t;
66
67 typedef struct
68 {
69 ras_c_read_type_t read_type;
70 uint8_t err_code;
71 union
72 {
73 uint32_t ras_features;
74 uint16_t cccd;
75 } rsp_data;
76 } ras_c_read_rsp_t;
77
78 typedef struct
79 {
80 uint8_t *p_subevt_data;
81 } ras_c_subevt_report_t;
82
83 typedef struct
84 {
85 uint8_t err_code; /**< Error code. */
86 } ras_c_discover_rsp_t;
87
88 typedef struct
89 {
90 uint8_t conn_idx; /**< Connection index. */
91 ras_c_evt_type_t evt_type; /**< Event type, @ref ras_c_evt_type_t. */
92 union
93 {
94 ras_c_discover_rsp_t discover_rsp;
95 ras_c_write_rsp_t write_rsp;
96 ras_c_read_rsp_t read_rsp;
97 ras_c_subevt_report_t subevt_report;
98 } evt_data;
99 } ras_c_evt_t;
100
101 typedef void (*ras_c_evt_handler_t)(ras_c_evt_t *p_evt);
102
103 /**
104 *****************************************************************************************
105 * @brief Register RAS Client event handler.
106 *
107 * @param[in] evt_handler: Ranging Service Client event handler.
108 *
109 * @return Result of initialization.
110 *****************************************************************************************
111 */
112 sdk_err_t ras_c_init(ras_c_evt_handler_t evt_handler);
113
114 /**
115 *****************************************************************************************
116 * @brief Discovery Ranging Service on peer.
117 *
118 * @param[in] conn_idx: Index of connection.
119 *
120 * @return Operation result.
121 *****************************************************************************************
122 */
123 sdk_err_t ras_c_discov_srvc_start(uint8_t conn_idx);
124
125 /**
126 *****************************************************************************************
127 * @brief Set characteristic cccd on peer service.
128 *
129 * @param[in] conn_idx: Index of connection.
130 * @param[in] cccd_type: Type of cccd, @ref ras_c_write_type_t.
131 * @param[in] cccd_value: Value of cccd, @ref ras_c_cccd_value_type_t.
132 *
133 * @return Operation result.
134 *****************************************************************************************
135 */
136 sdk_err_t ras_c_char_cccd_set(uint8_t conn_idx, ras_c_write_type_t cccd_type, ras_c_cccd_value_type_t cccd_value);
137
138 /**
139 *****************************************************************************************
140 * @brief Abort current operation.
141 *
142 * @param[in] conn_idx: Index of connection.
143 *
144 * @return Operation result.
145 *****************************************************************************************
146 */
147 sdk_err_t ras_c_operation_abort(uint8_t conn_idx);
148
149 /**
150 *****************************************************************************************
151 * @brief Set the filter policy for receiving ranging data.
152 *
153 * @param[in] conn_idx: Index of connection.
154 * @param[in] cs_mode: Channel sounding mode, @ref ras_mode_type_t.
155 * @param[in] data_bit_mask: filter data bit mask(bit = 1: not filter, bit = 0: filter),
156 * @ref ras_mode0_data_bit_t, ras_mode1_data_bit_t, ras_mode2_data_bit_t, ras_mode3_data_bit_t.
157 *
158 * @return Operation result.
159 *****************************************************************************************
160 */
161 sdk_err_t ras_c_filter_policy_set(uint8_t conn_idx, uint8_t cs_mode, uint16_t data_bit_mask);
162
163 /**
164 *****************************************************************************************
165 * @brief Handle for the connection event.
166 *
167 * @param[in] conn_idx: Connection index.
168 *
169 *****************************************************************************************
170 */
171 void ras_c_connect_handler(uint8_t conn_idx);
172
173 /**
174 *****************************************************************************************
175 * @brief Handle for the disconnection event.
176 *
177 * @param[in] conn_idx: Connection index.
178 *
179 *****************************************************************************************
180 */
181 void ras_c_disconnect_handler(uint8_t conn_idx);
182
183 /**
184 *****************************************************************************************
185 * @brief Handle for the mtu exchange event.
186 *
187 * @param[in] conn_idx: Connection index.
188 * @param[in] mtu: exchange mtu value.
189 *
190 *****************************************************************************************
191 */
192 void ras_c_mtu_exch_handler(uint8_t conn_idx, uint16_t mtu);
193
194 /**
195 *****************************************************************************************
196 * @brief Set remote step data len.
197 *
198 * @param[in] conn_idx: Connection index.
199 * @param[in] cfg_id: Procedure configure id.
200 * @param[in] mode0_len: Mode0 step data length.
201 * @param[in] mode1_len: Mode1 step data length.
202 * @param[in] mode2_len: Mode2 step data length.
203 * @param[in] mode3_len: Mode3 step data length.
204 *
205 *****************************************************************************************
206 */
207 void ras_c_set_remote_step_data_len(uint8_t conn_idx, uint8_t cfg_id, uint8_t mode0_len, uint8_t mode1_len, uint8_t mode2_len, uint8_t mode3_len);
208
209 #ifdef __cplusplus
210 }
211 #endif /* __cplusplus */
212
213 #endif /* __RAS_C_H__ */
ras_c_init
sdk_err_t ras_c_init(ras_c_evt_handler_t evt_handler)
Register RAS Client event handler.
RAS_C_DIS_NTF_IND
@ RAS_C_DIS_NTF_IND
Definition: ras_c.h:48
ras_c_evt_type_t
ras_c_evt_type_t
Definition: ras_c.h:14
ras_c_evt_t::write_rsp
ras_c_write_rsp_t write_rsp
Definition: ras_c.h:95
RAS_C_EVT_DISCOVER_FAILED
@ RAS_C_EVT_DISCOVER_FAILED
Definition: ras_c.h:17
RAS_C_WRITE_RA_DATA_READY_IND_NTF_CFG
@ RAS_C_WRITE_RA_DATA_READY_IND_NTF_CFG
Definition: ras_c.h:30
ras_c_discover_rsp_t::err_code
uint8_t err_code
Definition: ras_c.h:85
ras_c_write_req_t
Definition: ras_c.h:55
ras_c_discover_rsp_t
Definition: ras_c.h:84
ras_c_set_remote_step_data_len
void ras_c_set_remote_step_data_len(uint8_t conn_idx, uint8_t cfg_id, uint8_t mode0_len, uint8_t mode1_len, uint8_t mode2_len, uint8_t mode3_len)
Set remote step data len.
ras_c_cccd_value_type_t
ras_c_cccd_value_type_t
Definition: ras_c.h:47
ras_c_read_type_t
ras_c_read_type_t
Definition: ras_c.h:36
ras_c_write_req_t::p_data
uint8_t * p_data
Definition: ras_c.h:58
RAS_C_EN_IND
@ RAS_C_EN_IND
Definition: ras_c.h:50
ras_c_evt_t::read_rsp
ras_c_read_rsp_t read_rsp
Definition: ras_c.h:96
ras_c_write_type_t
ras_c_write_type_t
Definition: ras_c.h:25
ras_c_evt_handler_t
void(* ras_c_evt_handler_t)(ras_c_evt_t *p_evt)
Definition: ras_c.h:101
ras_c_connect_handler
void ras_c_connect_handler(uint8_t conn_idx)
Handle for the connection event.
ras_c_evt_t::discover_rsp
ras_c_discover_rsp_t discover_rsp
Definition: ras_c.h:94
RAS_C_EN_NTF_IND
@ RAS_C_EN_NTF_IND
Definition: ras_c.h:51
RAS_C_WRITE_RA_DATA_OVERWRITE_IND_NTF_CFG
@ RAS_C_WRITE_RA_DATA_OVERWRITE_IND_NTF_CFG
Definition: ras_c.h:31
ras_common.h
RAS_C_EVT_READ_RSP
@ RAS_C_EVT_READ_RSP
Definition: ras_c.h:20
ras_c_read_rsp_t::err_code
uint8_t err_code
Definition: ras_c.h:70
RAS_C_READ_TYPE_INVALID
@ RAS_C_READ_TYPE_INVALID
Definition: ras_c.h:43
ras_c_operation_abort
sdk_err_t ras_c_operation_abort(uint8_t conn_idx)
Abort current operation.
ras_c_evt_t::evt_type
ras_c_evt_type_t evt_type
Definition: ras_c.h:91
RAS_C_EVT_INVALID
@ RAS_C_EVT_INVALID
Definition: ras_c.h:15
ras_c_subevt_report_t::p_subevt_data
uint8_t * p_subevt_data
Definition: ras_c.h:80
ras_c_write_req_t::write_type
ras_c_write_type_t write_type
Definition: ras_c.h:56
RAS_C_EVT_WRITE_RSP
@ RAS_C_EVT_WRITE_RSP
Definition: ras_c.h:18
RAS_C_EVT_DISCOVER_COMPLETED
@ RAS_C_EVT_DISCOVER_COMPLETED
Definition: ras_c.h:16
ras_c_evt_t::subevt_report
ras_c_subevt_report_t subevt_report
Definition: ras_c.h:97
RAS_C_WRITE_RAS_CP_IND_NTF_CFG
@ RAS_C_WRITE_RAS_CP_IND_NTF_CFG
Definition: ras_c.h:29
RAS_C_WRITE_ON_DEMAND_RA_DATA_IND_NTF_CFG
@ RAS_C_WRITE_ON_DEMAND_RA_DATA_IND_NTF_CFG
Definition: ras_c.h:27
ras_c_read_rsp_t
Definition: ras_c.h:68
ble_error.h
File that contains error codes.
ras_c_evt_t::conn_idx
uint8_t conn_idx
Definition: ras_c.h:90
ras_c_read_rsp_t::ras_features
uint32_t ras_features
Definition: ras_c.h:73
RAS_C_READ_RA_DATA_OVERWRITE_IND_NTF_CFG
@ RAS_C_READ_RA_DATA_OVERWRITE_IND_NTF_CFG
Definition: ras_c.h:42
ras_c_mtu_exch_handler
void ras_c_mtu_exch_handler(uint8_t conn_idx, uint16_t mtu)
Handle for the mtu exchange event.
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:290
ras_c_write_rsp_t
Definition: ras_c.h:62
ras_c_filter_policy_set
sdk_err_t ras_c_filter_policy_set(uint8_t conn_idx, uint8_t cs_mode, uint16_t data_bit_mask)
Set the filter policy for receiving ranging data.
RAS_C_WRITE_RAS_CP
@ RAS_C_WRITE_RAS_CP
Definition: ras_c.h:28
RAS_C_READ_RA_DATA_READY_IND_NTF_CFG
@ RAS_C_READ_RA_DATA_READY_IND_NTF_CFG
Definition: ras_c.h:41
RAS_C_READ_RAS_CP_IND_NTF_CFG
@ RAS_C_READ_RAS_CP_IND_NTF_CFG
Definition: ras_c.h:40
RAS_C_EVT_WRITE_ERR
@ RAS_C_EVT_WRITE_ERR
Definition: ras_c.h:19
ras_c_read_rsp_t::cccd
uint16_t cccd
Definition: ras_c.h:74
RAS_C_EN_NTF
@ RAS_C_EN_NTF
Definition: ras_c.h:49
ras_c_char_cccd_set
sdk_err_t ras_c_char_cccd_set(uint8_t conn_idx, ras_c_write_type_t cccd_type, ras_c_cccd_value_type_t cccd_value)
Set characteristic cccd on peer service.
RAS_C_READ_RAS_FEATURE
@ RAS_C_READ_RAS_FEATURE
Definition: ras_c.h:37
ras_c_write_req_t::length
uint16_t length
Definition: ras_c.h:57
ras_c_evt_t
Definition: ras_c.h:89
RAS_C_READ_ON_DEMAND_RA_DATA_IND_NTF_CFG
@ RAS_C_READ_ON_DEMAND_RA_DATA_IND_NTF_CFG
Definition: ras_c.h:39
RAS_C_READ_RT_RA_DATA_IND_NTF_CFG
@ RAS_C_READ_RT_RA_DATA_IND_NTF_CFG
Definition: ras_c.h:38
ras_c_read_rsp_t::read_type
ras_c_read_type_t read_type
Definition: ras_c.h:69
ras_c_subevt_report_t
Definition: ras_c.h:79
ras_c_write_rsp_t::err_code
uint8_t err_code
Definition: ras_c.h:64
RAS_C_EVT_SUBEVT_REPORT
@ RAS_C_EVT_SUBEVT_REPORT
Definition: ras_c.h:21
ras_c_disconnect_handler
void ras_c_disconnect_handler(uint8_t conn_idx)
Handle for the disconnection event.
ras_c_write_rsp_t::write_type
ras_c_write_type_t write_type
Definition: ras_c.h:63
ras_c_discov_srvc_start
sdk_err_t ras_c_discov_srvc_start(uint8_t conn_idx)
Discovery Ranging Service on peer.
RAS_C_WRITE_TYPE_INVALID
@ RAS_C_WRITE_TYPE_INVALID
Definition: ras_c.h:32
RAS_C_WRITE_RT_RA_DATA_IND_NTF_CFG
@ RAS_C_WRITE_RT_RA_DATA_IND_NTF_CFG
Definition: ras_c.h:26