ras_common.h
Go to the documentation of this file.
1 #ifndef __RAS_COMMON_H__
2 #define __RAS_COMMON_H__
3
4 #include <stdint.h>
5 #include "ble_hci_ext.h"
6
7 #define OPEN_RAS_LOG 0
8
9 #if (OPEN_RAS_LOG)
10 #define RAS_LOG_INFO APP_LOG_INFO
11 #else
12 #define RAS_LOG_INFO(...)
13 #endif
14
15 #define RAS_CONNECTION_MAX (4)
16 #define RAS_MAX_PROC_NUM_PER_LINK (2)
17 #define RAS_CCCD_LEN (0x02)
18 #define RAS_FEATURE_CHAR_LEN (4)
19
20 #define RAS_RANGING_COUNTER_BIT_MASK (0x0FFF)
21 #define RAS_CFG_ID_BIT_MASK (0xF000)
22 #define RAS_ANT_PATH_BIT_MASK (0x0F)
23
24 // RAS control point
25 #define RAS_CTRL_PT_OPCODE_LEN (1)
26 #define RAS_CTRL_PT_OPERAND_MAX_LEN (4)
27 #define RAS_CTRL_PT_CHAR_MAX_LEN (RAS_CTRL_PT_OPCODE_LEN + RAS_CTRL_PT_OPERAND_MAX_LEN)
28
29 #define RAS_CTRL_PT_OPCODE_OFFSET (0)
30 #define RAS_CTRL_PT_OPERAND_OFFSET (1)
31
32 #define RAS_MODE_TYPE_BIT_MASK (0xC000)
33 #define RAS_MODE_TYPE_BIT_OFFSET (14)
34
35 #define RAS_MODE0_DATA_BIT_MASK (0x000F)
36 #define RAS_MODE1_DATA_BIT_MASK (0x007F)
37 #define RAS_MODE2_DATA_BIT_MASK (0x007F)
38 #define RAS_MODE3_DATA_BIT_MASK (0x3FFF)
39
40 #define RAS_PCT_FORMAT_BIT_MASK (0x01)
41
42 #define RAS_ERROR_PROC_ALREADY_IN_PROGRESS (0xFE)
43
44 // Ranging data
45 #define RAS_SEGMENT_HEADER_LEN (1)
46 #define RAS_SEGMENT_HEADER_FIRST_SEG_BITMASK (0x01)
47 #define RAS_SEGMENT_HEADER_LAST_SEG_BITMASK (0x02)
48 #define RAS_SEGMENT_HEADER_ROLL_SEG_COUNT_BITMASK (0xFC)
49 #define RAS_ROLLING_SEGMENT_COUNTER_MIN (0x00)
50 #define RAS_ROLLING_SEGMENT_COUNTER_MAX (0x3F)
51
52 #define RAS_RANGING_HEADER_LEN (4)
53 #define RAS_ANTENNA_PATH_1_MASK (0x01)
54 #define RAS_ANTENNA_PATH_2_MASK (0x02)
55 #define RAS_ANTENNA_PATH_3_MASK (0x04)
56 #define RAS_ANTENNA_PATH_4_MASK (0x08)
57 #define RAS_PCT_FORMAT_MASK (0x40)
58
59 #define RAS_SUBEVENT_HEADER_LEN (8)
60 #define RAS_SUBEVENT_HEADER_START_ACL_CON_EVENT_OFFSET (0)
61 #define RAS_SUBEVENT_HEADER_FREQ_COMPENSATION_OFFSET (2)
62 #define RAS_SUBEVENT_HEADER_RANGING_DONE_STATUS_OFFSET (4)
63 #define RAS_SUBEVENT_HEADER_SUBEVENT_DONE_STATUS_OFFSET (5)
64 #define RAS_SUBEVENT_HEADER_REF_POWER_LEVEL_OFFSET (6)
65 #define RAS_SUBEVENT_HEADER_NUM_STEPS_REPORTED_OFFSET (7)
66
67 typedef enum
68 {
69 RAS_FEA_RT_RA_DATA_BIT_MASK = 0x0001,
70 RAS_FEA_RETR_LOST_RA_DATA_SEG_BIT_MASK = 0x0002,
71 RAS_FEA_ABORT_OPERATION_BIT_MASK = 0x0004,
72 RAS_FEA_FILTER_RA_DATA_BIT_MASK = 0x0008,
73 RAS_FEA_ALL_BIT_MASK = 0x001F,
74 } ras_fea_bit_mask_t;
75
76 typedef enum
77 {
78 RAS_MODE_0 = 0x00,
79 RAS_MODE_1 = 0x01,
80 RAS_MODE_2 = 0x02,
81 RAS_MODE_3 = 0x03,
82 RAS_MODE_NUM = 0x04,
83 } ras_mode_type_t;
84
85 typedef enum
86 {
87 MODE0_PACKET_QUALITY = 0x01 << 0,
88 MODE0_PACKET_RSSI = 0x01 << 1,
89 MODE0_PACKET_ANT = 0x01 << 2,
90 MODE0_MEA_FREQ_OFFSET = 0x01 << 3,
91 } ras_mode0_data_bit_t;
92
93 typedef enum
94 {
95 MODE1_PACKET_QUALITY = 0x01 << 0,
96 MODE1_PACKET_NADM = 0x01 << 1,
97 MODE1_PACKET_RSSI = 0x01 << 2,
98 MODE1_TOD_TOA = 0x01 << 3,
99 MODE1_PACKET_ANT = 0x01 << 4,
100 MODE1_PACKET_PCT1 = 0x01 << 5,
101 MODE1_PACKET_PCT2 = 0x01 << 6,
102 } ras_mode1_data_bit_t;
103
104 typedef enum
105 {
106 MODE2_ANT_PERM_IDX = 0x01 << 0,
107 MODE2_TON_PCT = 0x01 << 1,
108 MODE2_TON_QUALITY_IND = 0x01 << 2,
109 MODE2_ANT_PATH_1 = 0x01 << 3,
110 MODE2_ANT_PATH_2 = 0x01 << 4,
111 MODE2_ANT_PATH_3 = 0x01 << 5,
112 MODE2_ANT_PATH_4 = 0x01 << 6,
113 } ras_mode2_data_bit_t;
114
115 typedef enum
116 {
117 MODE3_PACKET_QUALITY = 0x01 << 0,
118 MODE3_PACKET_NADM = 0x01 << 1,
119 MODE3_PACKET_RSSI = 0x01 << 2,
120 MODE3_PACKET_ANT = 0x01 << 3,
121 MODE3_PACKET_PCT1 = 0x01 << 4,
122 MODE3_PACKET_PCT2 = 0x01 << 5,
123 MODE3_TOD_TOA = 0x01 << 6,
124 MODE3_ANT_PERM_IDX = 0x01 << 7,
125 MODE3_TONE_PCT = 0x01 << 8,
126 MODE3_TON_QUALITY_IND = 0x01 << 9,
127 MODE3_ANT_PATH_1 = 0x01 << 10,
128 MODE3_ANT_PATH_2 = 0x01 << 11,
129 MODE3_ANT_PATH_3 = 0x01 << 12,
130 MODE3_ANT_PATH_4 = 0x01 << 13,
131 } ras_mode3_data_bit_t;
132
133 typedef enum
134 {
135 RAS_OP_GET_RA_DATA = 0x00,
136 RAS_OP_ACK_RA_DATA = 0x01,
137 RAS_OP_RETR_LOST_RA_DATA_SEGMENTS = 0x02,
138 RAS_OP_ABORT_OPERATION = 0x03,
139 RAS_OP_FILTER = 0x04,
140 } ras_ctrl_pt_cmd_opd_t;
141
142 typedef enum
143 {
144 RAS_OP_CMP_RA_DATA_RSP = 0x00,
145 RAS_OP_CMP_LOST_RA_DATA_SEG_RSP = 0x01,
146 RAS_OP_RSP_CODE = 0x02,
147 } ras_ctrl_pt_rsp_opd_t;
148
149 typedef struct
150 {
151 uint16_t ras_counter;
152 } ras_ctr_data_operand_t;
153
154 typedef struct
155 {
156 uint16_t ras_num;
157 } ras_cmp_data_rsp_operand_t;
158
159 typedef struct
160 {
161 uint16_t ras_counter;
162 uint8_t start_seg;
163 uint8_t end_seg;
164 } ras_ctr_lost_data_seg_operand_t;
165
166 typedef struct
167 {
168 // Bit14~15: CS mode, bit0~13: data bit mask.
169 uint8_t mode;
170 uint16_t bit_mask;
171 } ras_filter_data_operand_t;
172
173 typedef enum
174 {
175 RAS_RSP_SUCCESS = 0x01,
176 RAS_RSP_OPCODE_NOT_SUPPORTED = 0x02,
177 RAS_RSP_INVALID_PARAM = 0x03,
178 RAS_RSP_PARAM_NOT_SUPPORTED = 0x04,
179 RAS_RSP_ABORT_UNSUCCESSFUL = 0x05,
180 RAS_RSP_PROCEDURE_NOT_COMPLETED = 0x06,
181 RAS_RSP_SERVER_BUSY = 0x07,
182 RAS_RSP_NO_RECORDS_FOUND = 0x08,
183 } ras_rsp_code_val_t;
184
185 typedef cs_subevent_result_all_t ras_subevt_data_t;
186
187 typedef struct
188 {
189 ras_ctrl_pt_cmd_opd_t opcode;
190 union
191 {
192 ras_ctr_data_operand_t get_ra_data_param;
193 ras_ctr_data_operand_t ack_ra_data_param;
194 ras_ctr_lost_data_seg_operand_t retr_ra_data_param;
195 ras_filter_data_operand_t filter_param;
196 } operands;
197 } ras_ctr_pt_operation_t;
198
199 typedef struct
200 {
201 ras_ctrl_pt_rsp_opd_t opcode;
202 union
203 {
204 ras_cmp_data_rsp_operand_t cmp_data_rsp;
205 ras_ctr_lost_data_seg_operand_t cmp_lost_data_seg_rsp;
206 ras_rsp_code_val_t rsp_code_val;
207 } operands;
208 } ras_ctr_pt_rsp_t;
209
210 #endif /* __RAS_COMMON_H__ */
211
RAS_MODE_0
@ RAS_MODE_0
Definition: ras_common.h:78
RAS_OP_ABORT_OPERATION
@ RAS_OP_ABORT_OPERATION
Definition: ras_common.h:138
ras_ctr_pt_rsp_t::cmp_lost_data_seg_rsp
ras_ctr_lost_data_seg_operand_t cmp_lost_data_seg_rsp
Definition: ras_common.h:205
RAS_RSP_ABORT_UNSUCCESSFUL
@ RAS_RSP_ABORT_UNSUCCESSFUL
Definition: ras_common.h:179
ras_filter_data_operand_t::bit_mask
uint16_t bit_mask
Definition: ras_common.h:170
MODE3_ANT_PATH_2
@ MODE3_ANT_PATH_2
Definition: ras_common.h:128
ras_ctr_pt_rsp_t::rsp_code_val
ras_rsp_code_val_t rsp_code_val
Definition: ras_common.h:206
MODE1_PACKET_ANT
@ MODE1_PACKET_ANT
Definition: ras_common.h:99
MODE2_ANT_PATH_3
@ MODE2_ANT_PATH_3
Definition: ras_common.h:111
RAS_RSP_PROCEDURE_NOT_COMPLETED
@ RAS_RSP_PROCEDURE_NOT_COMPLETED
Definition: ras_common.h:180
MODE3_PACKET_PCT1
@ MODE3_PACKET_PCT1
Definition: ras_common.h:121
RAS_MODE_1
@ RAS_MODE_1
Definition: ras_common.h:79
MODE2_TON_QUALITY_IND
@ MODE2_TON_QUALITY_IND
Definition: ras_common.h:108
ras_ctr_pt_operation_t
Definition: ras_common.h:188
MODE2_ANT_PERM_IDX
@ MODE2_ANT_PERM_IDX
Definition: ras_common.h:106
ras_ctr_lost_data_seg_operand_t::start_seg
uint8_t start_seg
Definition: ras_common.h:162
RAS_FEA_RT_RA_DATA_BIT_MASK
@ RAS_FEA_RT_RA_DATA_BIT_MASK
Definition: ras_common.h:69
RAS_RSP_SERVER_BUSY
@ RAS_RSP_SERVER_BUSY
Definition: ras_common.h:181
ras_ctr_lost_data_seg_operand_t
Definition: ras_common.h:160
MODE3_ANT_PERM_IDX
@ MODE3_ANT_PERM_IDX
Definition: ras_common.h:124
ras_subevt_data_t
cs_subevent_result_all_t ras_subevt_data_t
Definition: ras_common.h:185
ras_ctr_lost_data_seg_operand_t::ras_counter
uint16_t ras_counter
Definition: ras_common.h:161
RAS_MODE_NUM
@ RAS_MODE_NUM
Definition: ras_common.h:82
ras_ctr_pt_rsp_t::cmp_data_rsp
ras_cmp_data_rsp_operand_t cmp_data_rsp
Definition: ras_common.h:204
MODE3_PACKET_QUALITY
@ MODE3_PACKET_QUALITY
Definition: ras_common.h:117
MODE1_PACKET_RSSI
@ MODE1_PACKET_RSSI
Definition: ras_common.h:97
ras_ctr_pt_operation_t::ack_ra_data_param
ras_ctr_data_operand_t ack_ra_data_param
Definition: ras_common.h:193
ras_cmp_data_rsp_operand_t
Definition: ras_common.h:155
MODE0_PACKET_RSSI
@ MODE0_PACKET_RSSI
Definition: ras_common.h:88
ras_ctr_pt_operation_t::get_ra_data_param
ras_ctr_data_operand_t get_ra_data_param
Definition: ras_common.h:192
RAS_OP_CMP_LOST_RA_DATA_SEG_RSP
@ RAS_OP_CMP_LOST_RA_DATA_SEG_RSP
Definition: ras_common.h:145
MODE1_PACKET_PCT2
@ MODE1_PACKET_PCT2
Definition: ras_common.h:101
ras_filter_data_operand_t::mode
uint8_t mode
Definition: ras_common.h:169
ras_mode0_data_bit_t
ras_mode0_data_bit_t
Definition: ras_common.h:86
MODE3_TON_QUALITY_IND
@ MODE3_TON_QUALITY_IND
Definition: ras_common.h:126
ras_ctr_data_operand_t::ras_counter
uint16_t ras_counter
Definition: ras_common.h:151
MODE2_ANT_PATH_1
@ MODE2_ANT_PATH_1
Definition: ras_common.h:109
MODE1_PACKET_PCT1
@ MODE1_PACKET_PCT1
Definition: ras_common.h:100
MODE3_TONE_PCT
@ MODE3_TONE_PCT
Definition: ras_common.h:125
RAS_FEA_RETR_LOST_RA_DATA_SEG_BIT_MASK
@ RAS_FEA_RETR_LOST_RA_DATA_SEG_BIT_MASK
Definition: ras_common.h:70
ras_ctr_pt_operation_t::retr_ra_data_param
ras_ctr_lost_data_seg_operand_t retr_ra_data_param
Definition: ras_common.h:194
ras_filter_data_operand_t
Definition: ras_common.h:167
RAS_FEA_FILTER_RA_DATA_BIT_MASK
@ RAS_FEA_FILTER_RA_DATA_BIT_MASK
Definition: ras_common.h:72
RAS_MODE_3
@ RAS_MODE_3
Definition: ras_common.h:81
ras_ctrl_pt_rsp_opd_t
ras_ctrl_pt_rsp_opd_t
Definition: ras_common.h:143
MODE3_ANT_PATH_1
@ MODE3_ANT_PATH_1
Definition: ras_common.h:127
ras_mode3_data_bit_t
ras_mode3_data_bit_t
Definition: ras_common.h:116
ras_fea_bit_mask_t
ras_fea_bit_mask_t
Definition: ras_common.h:68
RAS_OP_ACK_RA_DATA
@ RAS_OP_ACK_RA_DATA
Definition: ras_common.h:136
ras_mode_type_t
ras_mode_type_t
Definition: ras_common.h:77
MODE2_ANT_PATH_4
@ MODE2_ANT_PATH_4
Definition: ras_common.h:112
ras_ctr_pt_rsp_t
Definition: ras_common.h:200
RAS_RSP_OPCODE_NOT_SUPPORTED
@ RAS_RSP_OPCODE_NOT_SUPPORTED
Definition: ras_common.h:176
RAS_OP_FILTER
@ RAS_OP_FILTER
Definition: ras_common.h:139
RAS_OP_RETR_LOST_RA_DATA_SEGMENTS
@ RAS_OP_RETR_LOST_RA_DATA_SEGMENTS
Definition: ras_common.h:137
MODE1_PACKET_NADM
@ MODE1_PACKET_NADM
Definition: ras_common.h:96
ras_ctr_data_operand_t
Definition: ras_common.h:150
RAS_FEA_ALL_BIT_MASK
@ RAS_FEA_ALL_BIT_MASK
Definition: ras_common.h:73
RAS_MODE_2
@ RAS_MODE_2
Definition: ras_common.h:80
MODE3_ANT_PATH_4
@ MODE3_ANT_PATH_4
Definition: ras_common.h:130
RAS_RSP_NO_RECORDS_FOUND
@ RAS_RSP_NO_RECORDS_FOUND
Definition: ras_common.h:182
MODE3_TOD_TOA
@ MODE3_TOD_TOA
Definition: ras_common.h:123
MODE3_ANT_PATH_3
@ MODE3_ANT_PATH_3
Definition: ras_common.h:129
RAS_OP_RSP_CODE
@ RAS_OP_RSP_CODE
Definition: ras_common.h:146
MODE0_PACKET_ANT
@ MODE0_PACKET_ANT
Definition: ras_common.h:89
MODE2_TON_PCT
@ MODE2_TON_PCT
Definition: ras_common.h:107
MODE1_PACKET_QUALITY
@ MODE1_PACKET_QUALITY
Definition: ras_common.h:95
ras_cmp_data_rsp_operand_t::ras_num
uint16_t ras_num
Definition: ras_common.h:156
MODE3_PACKET_RSSI
@ MODE3_PACKET_RSSI
Definition: ras_common.h:119
MODE2_ANT_PATH_2
@ MODE2_ANT_PATH_2
Definition: ras_common.h:110
RAS_RSP_INVALID_PARAM
@ RAS_RSP_INVALID_PARAM
Definition: ras_common.h:177
ras_ctr_pt_operation_t::filter_param
ras_filter_data_operand_t filter_param
Definition: ras_common.h:195
ras_ctrl_pt_cmd_opd_t
ras_ctrl_pt_cmd_opd_t
Definition: ras_common.h:134
RAS_OP_CMP_RA_DATA_RSP
@ RAS_OP_CMP_RA_DATA_RSP
Definition: ras_common.h:144
RAS_RSP_SUCCESS
@ RAS_RSP_SUCCESS
Definition: ras_common.h:175
MODE3_PACKET_PCT2
@ MODE3_PACKET_PCT2
Definition: ras_common.h:122
RAS_RSP_PARAM_NOT_SUPPORTED
@ RAS_RSP_PARAM_NOT_SUPPORTED
Definition: ras_common.h:178
ras_ctr_pt_rsp_t::opcode
ras_ctrl_pt_rsp_opd_t opcode
Definition: ras_common.h:201
ras_mode2_data_bit_t
ras_mode2_data_bit_t
Definition: ras_common.h:105
RAS_OP_GET_RA_DATA
@ RAS_OP_GET_RA_DATA
Definition: ras_common.h:135
ras_ctr_pt_operation_t::opcode
ras_ctrl_pt_cmd_opd_t opcode
Definition: ras_common.h:189
MODE1_TOD_TOA
@ MODE1_TOD_TOA
Definition: ras_common.h:98
ras_rsp_code_val_t
ras_rsp_code_val_t
Definition: ras_common.h:174
MODE0_PACKET_QUALITY
@ MODE0_PACKET_QUALITY
Definition: ras_common.h:87
ras_ctr_lost_data_seg_operand_t::end_seg
uint8_t end_seg
Definition: ras_common.h:163
MODE3_PACKET_ANT
@ MODE3_PACKET_ANT
Definition: ras_common.h:120
MODE0_MEA_FREQ_OFFSET
@ MODE0_MEA_FREQ_OFFSET
Definition: ras_common.h:90
MODE3_PACKET_NADM
@ MODE3_PACKET_NADM
Definition: ras_common.h:118
RAS_FEA_ABORT_OPERATION_BIT_MASK
@ RAS_FEA_ABORT_OPERATION_BIT_MASK
Definition: ras_common.h:71
ras_mode1_data_bit_t
ras_mode1_data_bit_t
Definition: ras_common.h:94