hrrcps.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file hrrcps.h
5 *
6 * @brief HRS RSCS Relay Control Point Service API.
7 *
8 ****************************************************************************************
9 * @attention
10 #####Copyright (c) 2019 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 * @addtogroup BLE_SRV BLE Services
40 * @{
41 * @brief Definitions and prototypes for the BLE Service interface.
42 */
43
44 /**
45 * @defgroup BLE_SDK_HRRCPS HRS RSCS Relay Control Point Service (HRRCPS)
46 * @{
47 * @brief HRS RSCS Relay Control Point Service module.
48 *
49 * @details The HRS RSCS Relay Control Point Service provides Scan Device, Read Characteristic Value,
50 * Enable Notification and Query Connection State for application.
51 *
52 * The application must provide an event handler to register, then call \ref hrrcps_service_init()
53 * to add HRS RSCS Relay Control Point Service and HRR Control Point, HRR Control Point Response
54 * characteristics to the BLE Stack database.
55 */
56
57 #ifndef __HRRCPS_H__
58 #define __HRRCPS_H__
59
60 #include "ble_prf_types.h"
61 #include "gr55xx_sys.h"
62 #include "custom_config.h"
63 #include <stdint.h>
64 #include <stdbool.h>
65
66 /**
67 * @defgroup HRRCPS_MACRO Defines
68 * @{
69 */
70 #define HRRCPS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
71 10 : CFG_MAX_CONNECTIONS) /**< Maximum number of HRS RSCS Relay Control Point Service connections. */
72 #define HRRCPS_CTRL_PT_VAL_LEN 2 /**< Length of the value of Control Point characteristic. */
73 #define HRRCPS_CTRL_PT_RSP_VAL_LEN 4 /**< Length of the value of Control Point Response characteristic. */
74 #define HRRCPS_SERVICE_UUID 0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80,\
75 0x0A, 0x46, 0x44, 0xD3, 0x01, 0x06, 0xED, 0xA6 /**< The UUID of HRS RSCS Relay Control Point Service for setting advertising data. */
76 /** @} */
77
78 /**
79 * @defgroup HRRCPS_ENUM Enumerations
80 * @{
81 */
82 /**@brief HRS RSCS Relay Control Point Service Control Point IDs. */
83 typedef enum
84 {
85 HRRCPS_CTRL_PT_SCAN_HRS = 0x01, /**< Scan HRS device. */
86 HRRCPS_CTRL_PT_SCAN_RSCS, /**< Scan RSCS device. */
87 HRRCPS_CTRL_PT_HRS_SEN_LOC_READ, /**< Read HRS sensor location. */
88 HRRCPS_CTRL_PT_RSCS_SEN_LOC_READ, /**< Read RSCS sensor location. */
89 HRRCPS_CTRL_PT_HRS_NTF_ENABLE, /**< Enable HRS notification. */
90 HRRCPS_CTRL_PT_HRS_NTF_DISABLE, /**< Disable HRS notification. */
91 HRRCPS_CTRL_PT_RSCS_NTF_ENABLE, /**< Enable RSCS notification. */
92 HRRCPS_CTRL_PT_RSCS_NTF_DISABLE, /**< Disable RSCS notification. */
93 HRRCPS_CTRL_PT_HRS_CONN_STA_REPORT, /**< Report HRS connection state. */
94 HRRCPS_CTRL_PT_RSCS_CONN_STA_REPORT, /**< Report RSCS connecntion state. */
95 HRRCPS_CTRL_PT_HRS_DISCONN, /**< Disconnect HRS link. */
96 HRRCPS_CTRL_PT_RSCS_DISCONN, /**< Disconnect RSCS link. */
97 HRRCPS_CTRL_PT_RSP_CODE = 0xff, /**< Response code. */
98 } hrrcps_ctrl_pt_id_t;
99
100 /**@brief HRS RSCS Relay Control Point Service Response IDs of Control Point. */
101 typedef enum
102 {
103 HRRCPS_RSP_ID_OK = 0x01, /**< Success. */
104 HRRCPS_RSP_ID_ERROR, /**< Fail. */
105 } hrrcps_rsp_id_t;
106
107 /**@brief HRS RSCS Relay Control Point Service event type. */
108 typedef enum
109 {
110 HRRCPS_EVT_INVALID, /**< Invalid HRRCPS event type. */
111 HRRCPS_EVT_CTRL_PT_IND_ENABLE, /**< HRR Control Point indicaiton is enabled. */
112 HRRCPS_EVT_CTRL_PT_IND_DISABLE, /**< HRR Control Point indicaiton is disabled. */
113 HRRCPS_EVT_SCAN_HRS, /**< Scan HRS device. */
114 HRRCPS_EVT_SCAN_RSCS, /**< Scan RSCS device. */
115 HRRCPS_EVT_ENABLE_HRS_NTF, /**< Enable HRS notification. */
116 HRRCPS_EVT_DISABLE_HRS_NTF, /**< Disable HRS notification. */
117 HRRCPS_EVT_ENABLE_RSCS_NTF, /**< Enable RSCS notificaiton. */
118 HRRCPS_EVT_DISABLE_RSCS_NTF, /**< Disable RSCS notificaiton. */
119 HRRCPS_EVT_HRS_SENSOR_LOC_READ, /**< Read HRS sensor location. */
120 HRRCPS_EVT_RSCS_SENSOR_LOC_READ, /**< Read RSCS sensor location. */
121 HRRCPS_EVT_DISCONN_HRS_LINK, /**< Disconnect HRS link. */
122 HRRCPS_EVT_DISCONN_RSCS_LINK, /**< Disconnect RSCS link. */
123 } hrrcps_evt_type_t;
124 /** @} */
125
126 /**
127 * @defgroup HRRCPS_STRUCT Structures
128 * @{
129 */
130 /**@brief HRS RSCS Relay Control Point Response value. */
131 typedef struct
132 {
133 hrrcps_ctrl_pt_id_t cmd_id; /**< Control Point ID. */
134 hrrcps_rsp_id_t rsp_id; /**< Response ID. */
135 bool is_inc_prama; /**< Parameter is included or not. */
136 uint8_t rsp_param; /**< Response parameters. */
137 } hrrcps_rsp_val_t;
138
139 /**@brief HRS RSCS Relay Control Point Service event. */
140 typedef struct
141 {
142 uint8_t conn_idx; /**< The index of the connection. */
143 hrrcps_evt_type_t evt_type; /**< The HRRCPS event type. */
144 } hrrcps_evt_t;
145 /** @} */
146
147 /**
148 * @defgroup HRRCPS_TYPEDEF Typedefs
149 * @{
150 */
151 /**@brief HRS RSCS Relay Control Point Service event handler type.*/
152 typedef void (*hrrcps_evt_handler_t)(hrrcps_evt_t *p_evt);
153 /** @} */
154
155 /**
156 * @defgroup ANS_FUNCTION Functions
157 * @{
158 */
159 /**
160 *****************************************************************************************
161 * @brief Initialize an Alert Notification Service instance and add in the DB.
162 *
163 * @param[in] evt_handler: HRS RSCS Relay Control Point Service event handler.
164 *
165 * @return Result of service initialization.
166 *****************************************************************************************
167 */
168 sdk_err_t hrrcps_service_init(hrrcps_evt_handler_t evt_handler);
169
170 /**
171 *****************************************************************************************
172 * @brief Send Control Point Response if its indicaiton has been enabled.
173 *
174 * @param[in] conn_idx: Connnection index.
175 * @param[in] p_rsp_val: Pointer to Response value.
176 *
177 * @return Result of indicate value
178 *****************************************************************************************
179 */
180 sdk_err_t hrrcps_ctrl_pt_rsp_send(uint8_t conn_idx, hrrcps_rsp_val_t *p_rsp_val);
181 /** @} */
182
183 #endif
184
185 /** @} */
186 /** @} */
HRRCPS_CTRL_PT_HRS_NTF_ENABLE
@ HRRCPS_CTRL_PT_HRS_NTF_ENABLE
Enable HRS notification.
Definition: hrrcps.h:89
hrrcps_rsp_val_t::is_inc_prama
bool is_inc_prama
Parameter is included or not.
Definition: hrrcps.h:135
hrrcps_rsp_id_t
hrrcps_rsp_id_t
HRS RSCS Relay Control Point Service Response IDs of Control Point.
Definition: hrrcps.h:102
HRRCPS_CTRL_PT_SCAN_RSCS
@ HRRCPS_CTRL_PT_SCAN_RSCS
Scan RSCS device.
Definition: hrrcps.h:86
HRRCPS_EVT_DISABLE_RSCS_NTF
@ HRRCPS_EVT_DISABLE_RSCS_NTF
Disable RSCS notificaiton.
Definition: hrrcps.h:118
hrrcps_rsp_val_t
HRS RSCS Relay Control Point Response value.
Definition: hrrcps.h:132
HRRCPS_CTRL_PT_RSCS_NTF_DISABLE
@ HRRCPS_CTRL_PT_RSCS_NTF_DISABLE
Disable RSCS notification.
Definition: hrrcps.h:92
HRRCPS_EVT_DISCONN_RSCS_LINK
@ HRRCPS_EVT_DISCONN_RSCS_LINK
Disconnect RSCS link.
Definition: hrrcps.h:122
HRRCPS_CTRL_PT_HRS_SEN_LOC_READ
@ HRRCPS_CTRL_PT_HRS_SEN_LOC_READ
Read HRS sensor location.
Definition: hrrcps.h:87
HRRCPS_EVT_ENABLE_HRS_NTF
@ HRRCPS_EVT_ENABLE_HRS_NTF
Enable HRS notification.
Definition: hrrcps.h:115
HRRCPS_CTRL_PT_HRS_CONN_STA_REPORT
@ HRRCPS_CTRL_PT_HRS_CONN_STA_REPORT
Report HRS connection state.
Definition: hrrcps.h:93
hrrcps_ctrl_pt_rsp_send
sdk_err_t hrrcps_ctrl_pt_rsp_send(uint8_t conn_idx, hrrcps_rsp_val_t *p_rsp_val)
Send Control Point Response if its indicaiton has been enabled.
gr55xx_sys.h
GR55XX System API.
hrrcps_evt_t::conn_idx
uint8_t conn_idx
The index of the connection.
Definition: hrrcps.h:142
hrrcps_rsp_val_t::cmd_id
hrrcps_ctrl_pt_id_t cmd_id
Control Point ID.
Definition: hrrcps.h:133
HRRCPS_EVT_INVALID
@ HRRCPS_EVT_INVALID
Invalid HRRCPS event type.
Definition: hrrcps.h:110
HRRCPS_RSP_ID_OK
@ HRRCPS_RSP_ID_OK
Success.
Definition: hrrcps.h:103
HRRCPS_CTRL_PT_RSCS_SEN_LOC_READ
@ HRRCPS_CTRL_PT_RSCS_SEN_LOC_READ
Read RSCS sensor location.
Definition: hrrcps.h:88
HRRCPS_EVT_CTRL_PT_IND_ENABLE
@ HRRCPS_EVT_CTRL_PT_IND_ENABLE
HRR Control Point indicaiton is enabled.
Definition: hrrcps.h:111
hrrcps_evt_type_t
hrrcps_evt_type_t
HRS RSCS Relay Control Point Service event type.
Definition: hrrcps.h:109
HRRCPS_EVT_HRS_SENSOR_LOC_READ
@ HRRCPS_EVT_HRS_SENSOR_LOC_READ
Read HRS sensor location.
Definition: hrrcps.h:119
HRRCPS_EVT_RSCS_SENSOR_LOC_READ
@ HRRCPS_EVT_RSCS_SENSOR_LOC_READ
Read RSCS sensor location.
Definition: hrrcps.h:120
HRRCPS_CTRL_PT_RSCS_DISCONN
@ HRRCPS_CTRL_PT_RSCS_DISCONN
Disconnect RSCS link.
Definition: hrrcps.h:96
HRRCPS_RSP_ID_ERROR
@ HRRCPS_RSP_ID_ERROR
Fail.
Definition: hrrcps.h:104
hrrcps_ctrl_pt_id_t
hrrcps_ctrl_pt_id_t
HRS RSCS Relay Control Point Service Control Point IDs.
Definition: hrrcps.h:84
hrrcps_service_init
sdk_err_t hrrcps_service_init(hrrcps_evt_handler_t evt_handler)
Initialize an Alert Notification Service instance and add in the DB.
ble_prf_types.h
Profile/Service Common Types.
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
HRRCPS_CTRL_PT_SCAN_HRS
@ HRRCPS_CTRL_PT_SCAN_HRS
Scan HRS device.
Definition: hrrcps.h:85
HRRCPS_EVT_DISCONN_HRS_LINK
@ HRRCPS_EVT_DISCONN_HRS_LINK
Disconnect HRS link.
Definition: hrrcps.h:121
HRRCPS_CTRL_PT_RSP_CODE
@ HRRCPS_CTRL_PT_RSP_CODE
Response code.
Definition: hrrcps.h:97
hrrcps_evt_t::evt_type
hrrcps_evt_type_t evt_type
The HRRCPS event type.
Definition: hrrcps.h:143
hrrcps_rsp_val_t::rsp_param
uint8_t rsp_param
Response parameters.
Definition: hrrcps.h:136
HRRCPS_CTRL_PT_HRS_DISCONN
@ HRRCPS_CTRL_PT_HRS_DISCONN
Disconnect HRS link.
Definition: hrrcps.h:95
HRRCPS_CTRL_PT_RSCS_CONN_STA_REPORT
@ HRRCPS_CTRL_PT_RSCS_CONN_STA_REPORT
Report RSCS connecntion state.
Definition: hrrcps.h:94
hrrcps_evt_handler_t
void(* hrrcps_evt_handler_t)(hrrcps_evt_t *p_evt)
HRS RSCS Relay Control Point Service event handler type.
Definition: hrrcps.h:152
HRRCPS_EVT_ENABLE_RSCS_NTF
@ HRRCPS_EVT_ENABLE_RSCS_NTF
Enable RSCS notificaiton.
Definition: hrrcps.h:117
HRRCPS_CTRL_PT_RSCS_NTF_ENABLE
@ HRRCPS_CTRL_PT_RSCS_NTF_ENABLE
Enable RSCS notification.
Definition: hrrcps.h:91
hrrcps_rsp_val_t::rsp_id
hrrcps_rsp_id_t rsp_id
Response ID.
Definition: hrrcps.h:134
HRRCPS_EVT_CTRL_PT_IND_DISABLE
@ HRRCPS_EVT_CTRL_PT_IND_DISABLE
HRR Control Point indicaiton is disabled.
Definition: hrrcps.h:112
HRRCPS_EVT_DISABLE_HRS_NTF
@ HRRCPS_EVT_DISABLE_HRS_NTF
Disable HRS notification.
Definition: hrrcps.h:116
HRRCPS_CTRL_PT_HRS_NTF_DISABLE
@ HRRCPS_CTRL_PT_HRS_NTF_DISABLE
Disable HRS notification.
Definition: hrrcps.h:90
HRRCPS_EVT_SCAN_RSCS
@ HRRCPS_EVT_SCAN_RSCS
Scan RSCS device.
Definition: hrrcps.h:114
HRRCPS_EVT_SCAN_HRS
@ HRRCPS_EVT_SCAN_HRS
Scan HRS device.
Definition: hrrcps.h:113
hrrcps_evt_t
HRS RSCS Relay Control Point Service event.
Definition: hrrcps.h:141