ras_c_ad.h
Go to the documentation of this file.
1 /**
2 *****************************************************************************************
3 *
4 * @file ras_c_ad.h
5 *
6 * @brief Ranging Service Client 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
39 #ifndef __RAS_C_AD_H__
40 #define __RAS_C_AD_H__
41
42 #include <stdint.h>
43
44 #ifdef __cplusplus
45 extern "C"
46 {
47 #endif /* __cplusplus */
48
49 typedef enum
50 {
51 RAS_C_AD_EVT_INVALID = 0x00,
52 RAS_C_AD_EVT_DISCOVER_COMPLETED = 0x01,
53 RAS_C_AD_EVT_DISCOVER_FAILED = 0x02,
54 RAS_C_AD_EVT_WRITE_RSP = 0x03,
55 RAS_C_AD_EVT_WRITE_ERR = 0x04,
56 RAS_C_AD_EVT_READ_RSP = 0x05,
57 RAS_C_AD_EVT_SERVER_NOTIFY = 0x06,
58 RAS_C_AD_EVT_SERVER_IND = 0x07,
59 } ras_c_ad_evt_type_t;
60
61 typedef enum
62 {
63 RAS_C_AD_HANDLE_RAS_FEATURES = 0x00,
64 RAS_C_AD_HANDLE_RT_RA_DATA = 0x01,
65 RAS_C_AD_HANDLE_RT_RA_DATA_IND_NTF_CFG = 0x02,
66 RAS_C_AD_HANDLE_ON_DEMAND_RA_DATA = 0x03,
67 RAS_C_AD_HANDLE_ON_DEMAND_RA_DATA_IND_NTF_CFG = 0x04,
68 RAS_C_AD_HANDLE_RAS_CP = 0x05,
69 RAS_C_AD_HANDLE_RAS_CP_IND_NTF_CFG = 0x06,
70 RAS_C_AD_HANDLE_RA_DATA_READY = 0x07,
71 RAS_C_AD_HANDLE_RA_DATA_READY_IND_NTF_CFG = 0x08,
72 RAS_C_AD_HANDLE_RA_DATA_OVERWRITE = 0x09,
73 RAS_C_AD_HANDLE_RA_DATA_OVERWRITE_IND_NTF_CFG = 0x0A,
74
75 RAS_C_AD_CHAR_HANDLE_CCCD_NB = 0x0B,
76 } ras_c_ad_char_type_t;
77
78 typedef struct
79 {
80 ras_c_ad_char_type_t char_type; /**< Characteristic or Descriptor type. */
81 uint16_t length; /**< Write length. */
82 uint8_t *p_data; /**< Value to be written. */
83 } ras_c_ad_write_req_t;
84
85 typedef struct
86 {
87 ras_c_ad_char_type_t char_type;
88 uint8_t err_code;
89 } ras_c_ad_write_rsp_t;
90
91 typedef struct
92 {
93 ras_c_ad_char_type_t char_type;
94 uint16_t length; /**< Read length. */
95 uint8_t *p_data; /**< Value to be read. */
96 uint8_t err_code;
97 } ras_c_ad_read_ntf_ind_data_t;
98
99 typedef struct
100 {
101 uint8_t err_code; /**< Error code. */
102 } ras_c_ad_discover_rsp_t;
103
104 typedef struct
105 {
106 uint8_t conn_idx; /**< Connection index. */
107 ras_c_ad_evt_type_t evt_type; /**< Volume Control Profile event type. */
108 union
109 {
110 ras_c_ad_discover_rsp_t discover_rsp;
111 ras_c_ad_write_rsp_t write_rsp;
112 ras_c_ad_read_ntf_ind_data_t read_ntf_ind_rsp;
113 } evt_data;
114 } ras_c_ad_evt_t;
115
116 typedef void (*ras_c_ad_evt_handler_t)(ras_c_ad_evt_t *p_evt);
117
118 sdk_err_t ras_c_ad_init(ras_c_ad_evt_handler_t evt_handler);
119
120 sdk_err_t ras_c_ad_read_char(uint8_t conn_idx, ras_c_ad_char_type_t read_char_type);
121 sdk_err_t ras_c_ad_write_char(uint8_t conn_idx, ras_c_ad_write_req_t *p_write_req);
122 sdk_err_t ras_c_ad_start_discov_srvc(uint8_t conn_idx);
123 void ras_c_ad_disconnect_handler(uint8_t conn_idx);
124
125 #ifdef __cplusplus
126 }
127 #endif /* __cplusplus */
128
129 #endif /* __RAS_C_AD_H__ */
ras_c_ad_evt_type_t
ras_c_ad_evt_type_t
Definition: ras_c_ad.h:50
RAS_C_AD_HANDLE_RA_DATA_READY
@ RAS_C_AD_HANDLE_RA_DATA_READY
Definition: ras_c_ad.h:70
ras_c_ad_read_ntf_ind_data_t::length
uint16_t length
Definition: ras_c_ad.h:94
RAS_C_AD_HANDLE_RA_DATA_OVERWRITE
@ RAS_C_AD_HANDLE_RA_DATA_OVERWRITE
Definition: ras_c_ad.h:72
RAS_C_AD_HANDLE_RT_RA_DATA_IND_NTF_CFG
@ RAS_C_AD_HANDLE_RT_RA_DATA_IND_NTF_CFG
Definition: ras_c_ad.h:65
RAS_C_AD_EVT_READ_RSP
@ RAS_C_AD_EVT_READ_RSP
Definition: ras_c_ad.h:56
ras_c_ad_read_ntf_ind_data_t::p_data
uint8_t * p_data
Definition: ras_c_ad.h:95
ras_c_ad_evt_t::read_ntf_ind_rsp
ras_c_ad_read_ntf_ind_data_t read_ntf_ind_rsp
Definition: ras_c_ad.h:112
ras_c_ad_discover_rsp_t
Definition: ras_c_ad.h:100
RAS_C_AD_CHAR_HANDLE_CCCD_NB
@ RAS_C_AD_CHAR_HANDLE_CCCD_NB
Definition: ras_c_ad.h:75
ras_c_ad_init
sdk_err_t ras_c_ad_init(ras_c_ad_evt_handler_t evt_handler)
ras_c_ad_start_discov_srvc
sdk_err_t ras_c_ad_start_discov_srvc(uint8_t conn_idx)
ras_c_ad_write_rsp_t::char_type
ras_c_ad_char_type_t char_type
Definition: ras_c_ad.h:87
ras_c_ad_disconnect_handler
void ras_c_ad_disconnect_handler(uint8_t conn_idx)
RAS_C_AD_EVT_WRITE_RSP
@ RAS_C_AD_EVT_WRITE_RSP
Definition: ras_c_ad.h:54
RAS_C_AD_EVT_INVALID
@ RAS_C_AD_EVT_INVALID
Definition: ras_c_ad.h:51
RAS_C_AD_HANDLE_ON_DEMAND_RA_DATA_IND_NTF_CFG
@ RAS_C_AD_HANDLE_ON_DEMAND_RA_DATA_IND_NTF_CFG
Definition: ras_c_ad.h:67
ras_c_ad_evt_t::write_rsp
ras_c_ad_write_rsp_t write_rsp
Definition: ras_c_ad.h:111
ras_c_ad_write_rsp_t::err_code
uint8_t err_code
Definition: ras_c_ad.h:88
RAS_C_AD_EVT_DISCOVER_COMPLETED
@ RAS_C_AD_EVT_DISCOVER_COMPLETED
Definition: ras_c_ad.h:52
RAS_C_AD_EVT_WRITE_ERR
@ RAS_C_AD_EVT_WRITE_ERR
Definition: ras_c_ad.h:55
ras_c_ad_write_req_t::char_type
ras_c_ad_char_type_t char_type
Definition: ras_c_ad.h:80
ras_c_ad_evt_t::conn_idx
uint8_t conn_idx
Definition: ras_c_ad.h:106
RAS_C_AD_EVT_DISCOVER_FAILED
@ RAS_C_AD_EVT_DISCOVER_FAILED
Definition: ras_c_ad.h:53
RAS_C_AD_HANDLE_RAS_CP_IND_NTF_CFG
@ RAS_C_AD_HANDLE_RAS_CP_IND_NTF_CFG
Definition: ras_c_ad.h:69
ras_c_ad_evt_t::discover_rsp
ras_c_ad_discover_rsp_t discover_rsp
Definition: ras_c_ad.h:110
RAS_C_AD_HANDLE_ON_DEMAND_RA_DATA
@ RAS_C_AD_HANDLE_ON_DEMAND_RA_DATA
Definition: ras_c_ad.h:66
ras_c_ad_evt_handler_t
void(* ras_c_ad_evt_handler_t)(ras_c_ad_evt_t *p_evt)
Definition: ras_c_ad.h:116
RAS_C_AD_EVT_SERVER_NOTIFY
@ RAS_C_AD_EVT_SERVER_NOTIFY
Definition: ras_c_ad.h:57
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:290
ras_c_ad_char_type_t
ras_c_ad_char_type_t
Definition: ras_c_ad.h:62
RAS_C_AD_HANDLE_RAS_CP
@ RAS_C_AD_HANDLE_RAS_CP
Definition: ras_c_ad.h:68
ras_c_ad_read_ntf_ind_data_t
Definition: ras_c_ad.h:92
ras_c_ad_evt_t
Definition: ras_c_ad.h:105
ras_c_ad_read_ntf_ind_data_t::char_type
ras_c_ad_char_type_t char_type
Definition: ras_c_ad.h:93
RAS_C_AD_HANDLE_RT_RA_DATA
@ RAS_C_AD_HANDLE_RT_RA_DATA
Definition: ras_c_ad.h:64
RAS_C_AD_HANDLE_RAS_FEATURES
@ RAS_C_AD_HANDLE_RAS_FEATURES
Definition: ras_c_ad.h:63
ras_c_ad_read_ntf_ind_data_t::err_code
uint8_t err_code
Definition: ras_c_ad.h:96
RAS_C_AD_HANDLE_RA_DATA_READY_IND_NTF_CFG
@ RAS_C_AD_HANDLE_RA_DATA_READY_IND_NTF_CFG
Definition: ras_c_ad.h:71
ras_c_ad_write_req_t::length
uint16_t length
Definition: ras_c_ad.h:81
ras_c_ad_write_req_t::p_data
uint8_t * p_data
Definition: ras_c_ad.h:82
ras_c_ad_write_req_t
Definition: ras_c_ad.h:79
ras_c_ad_evt_t::evt_type
ras_c_ad_evt_type_t evt_type
Definition: ras_c_ad.h:107
ras_c_ad_discover_rsp_t::err_code
uint8_t err_code
Definition: ras_c_ad.h:101
ras_c_ad_write_rsp_t
Definition: ras_c_ad.h:86
ras_c_ad_read_char
sdk_err_t ras_c_ad_read_char(uint8_t conn_idx, ras_c_ad_char_type_t read_char_type)
RAS_C_AD_HANDLE_RA_DATA_OVERWRITE_IND_NTF_CFG
@ RAS_C_AD_HANDLE_RA_DATA_OVERWRITE_IND_NTF_CFG
Definition: ras_c_ad.h:73
RAS_C_AD_EVT_SERVER_IND
@ RAS_C_AD_EVT_SERVER_IND
Definition: ras_c_ad.h:58
ras_c_ad_write_char
sdk_err_t ras_c_ad_write_char(uint8_t conn_idx, ras_c_ad_write_req_t *p_write_req)