ccc_dk_c.h
Go to the documentation of this file.
1 /**
2 *****************************************************************************************
3 *
4 * @file ccc_dk_c.h
5 *
6 * @brief CCC DK Service Client.
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 __CCC_DK_C_H__
39 #define __CCC_DK_C_H__
40
41 #include "gr_includes.h"
42 #include <stdbool.h>
43 #include <stdint.h>
44
45 #ifdef __cplusplus
46 extern "C"
47 {
48 #endif /* __cplusplus */
49
50 typedef enum
51 {
52 CCC_DK_C_EVT_INVALID = 0x00,
53 CCC_DK_C_EVT_DISC_SVC_COMPLETED = 0x01,
54 CCC_DK_C_EVT_DISC_SVC_FAILED = 0x02,
55 CCC_DK_C_EVT_READ_SPSM_RSP = 0x03,
56 } ccc_dk_c_evt_type_t;
57
58 typedef struct
59 {
60 uint8_t err_code;
61 uint16_t spsm_value;
62 } ccc_dk_c_read_spsm_rsp_t;
63
64 typedef struct
65 {
66 uint8_t err_code;
67 } ccc_dk_c_disc_svc_fail_t;
68
69 typedef struct
70 {
71 uint8_t conn_idx;
72 ccc_dk_c_evt_type_t evt_type;
73 union
74 {
75 ccc_dk_c_disc_svc_fail_t disc_svc_fail;
76 ccc_dk_c_read_spsm_rsp_t read_spsm_rsp;
77 } evt_data;
78 } ccc_dk_c_evt_t;
79
80 typedef void (*ccc_dk_c_evt_handler_t)(ccc_dk_c_evt_t *p_evt);
81
82 /**
83 *****************************************************************************************
84 * @brief Initialize ccc dk service client.
85 *
86 *****************************************************************************************
87 */
88 sdk_err_t ccc_dk_c_init(ccc_dk_c_evt_handler_t evt_handler);
89
90 /**
91 *****************************************************************************************
92 * @brief Start discovery ccc dk service.
93 *
94 *****************************************************************************************
95 */
96 sdk_err_t ccc_dk_c_start_disc_srvc(uint8_t conn_idx);
97
98 /**
99 *****************************************************************************************
100 * @brief Read ccc dk spsm.
101 *
102 *****************************************************************************************
103 */
104 sdk_err_t ccc_dk_c_read_spsm(uint8_t conn_idx);
105
106 /**
107 *****************************************************************************************
108 * @brief Disconnect handler function.
109 *
110 *****************************************************************************************
111 */
112 void ccc_dk_c_disconnect_handler(uint8_t conn_idx);
113
114 #ifdef __cplusplus
115 }
116 #endif /* __cplusplus */
117
118 #endif /* __CCC_DK_C_H__ */
ccc_dk_c_read_spsm_rsp_t::err_code
uint8_t err_code
Definition: ccc_dk_c.h:60
ccc_dk_c_evt_t
Definition: ccc_dk_c.h:70
ccc_dk_c_read_spsm_rsp_t
Definition: ccc_dk_c.h:59
gr_includes.h
Include Files API.
CCC_DK_C_EVT_DISC_SVC_COMPLETED
@ CCC_DK_C_EVT_DISC_SVC_COMPLETED
Definition: ccc_dk_c.h:53
ccc_dk_c_read_spsm
sdk_err_t ccc_dk_c_read_spsm(uint8_t conn_idx)
Read ccc dk spsm.
ccc_dk_c_evt_t::conn_idx
uint8_t conn_idx
Definition: ccc_dk_c.h:71
ccc_dk_c_evt_t::read_spsm_rsp
ccc_dk_c_read_spsm_rsp_t read_spsm_rsp
Definition: ccc_dk_c.h:76
ccc_dk_c_evt_handler_t
void(* ccc_dk_c_evt_handler_t)(ccc_dk_c_evt_t *p_evt)
Definition: ccc_dk_c.h:80
ccc_dk_c_read_spsm_rsp_t::spsm_value
uint16_t spsm_value
Definition: ccc_dk_c.h:61
ccc_dk_c_disconnect_handler
void ccc_dk_c_disconnect_handler(uint8_t conn_idx)
Disconnect handler function.
ccc_dk_c_disc_svc_fail_t::err_code
uint8_t err_code
Definition: ccc_dk_c.h:66
CCC_DK_C_EVT_DISC_SVC_FAILED
@ CCC_DK_C_EVT_DISC_SVC_FAILED
Definition: ccc_dk_c.h:54
ccc_dk_c_evt_t::disc_svc_fail
ccc_dk_c_disc_svc_fail_t disc_svc_fail
Definition: ccc_dk_c.h:75
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:274
ccc_dk_c_init
sdk_err_t ccc_dk_c_init(ccc_dk_c_evt_handler_t evt_handler)
Initialize ccc dk service client.
ccc_dk_c_evt_t::evt_type
ccc_dk_c_evt_type_t evt_type
Definition: ccc_dk_c.h:72
CCC_DK_C_EVT_INVALID
@ CCC_DK_C_EVT_INVALID
Definition: ccc_dk_c.h:52
ccc_dk_c_evt_type_t
ccc_dk_c_evt_type_t
Definition: ccc_dk_c.h:51
ccc_dk_c_disc_svc_fail_t
Definition: ccc_dk_c.h:65
ccc_dk_c_start_disc_srvc
sdk_err_t ccc_dk_c_start_disc_srvc(uint8_t conn_idx)
Start discovery ccc dk service.
CCC_DK_C_EVT_READ_SPSM_RSP
@ CCC_DK_C_EVT_READ_SPSM_RSP
Definition: ccc_dk_c.h:55