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 "gr_includes.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 /**< Maximum number of HRS RSCS Relay Control Point Service connections. */
71 #define HRRCPS_CTRL_PT_VAL_LEN 2 /**< Length of the value of Control Point characteristic. */
72 #define HRRCPS_CTRL_PT_RSP_VAL_LEN 4 /**< Length of the value of Control Point Response characteristic. */
73 #define HRRCPS_SERVICE_UUID 0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80,\
74  0x0A, 0x46, 0x44, 0xD3, 0x01, 0x06, 0xED, 0xA6 /**< The UUID of HRS RSCS Relay Control Point Service for setting advertising data. */
75 /** @} */
76 
77 /**
78  * @defgroup HRRCPS_ENUM Enumerations
79  * @{
80  */
81 /**@brief HRS RSCS Relay Control Point Service Control Point IDs. */
82 typedef enum
83 {
84  HRRCPS_CTRL_PT_SCAN_HRS = 0x01, /**< Scan HRS device. */
85  HRRCPS_CTRL_PT_SCAN_RSCS, /**< Scan RSCS device. */
86  HRRCPS_CTRL_PT_HRS_SEN_LOC_READ, /**< Read HRS sensor location. */
87  HRRCPS_CTRL_PT_RSCS_SEN_LOC_READ, /**< Read RSCS sensor location. */
88  HRRCPS_CTRL_PT_HRS_NTF_ENABLE, /**< Enable HRS notification. */
89  HRRCPS_CTRL_PT_HRS_NTF_DISABLE, /**< Disable HRS notification. */
90  HRRCPS_CTRL_PT_RSCS_NTF_ENABLE, /**< Enable RSCS notification. */
91  HRRCPS_CTRL_PT_RSCS_NTF_DISABLE, /**< Disable RSCS notification. */
92  HRRCPS_CTRL_PT_HRS_CONN_STA_REPORT, /**< Report HRS connection state. */
93  HRRCPS_CTRL_PT_RSCS_CONN_STA_REPORT, /**< Report RSCS connecntion state. */
94  HRRCPS_CTRL_PT_HRS_DISCONN, /**< Disconnect HRS link. */
95  HRRCPS_CTRL_PT_RSCS_DISCONN, /**< Disconnect RSCS link. */
96  HRRCPS_CTRL_PT_RSP_CODE = 0xff, /**< Response code. */
98 
99 /**@brief HRS RSCS Relay Control Point Service Response IDs of Control Point. */
100 typedef enum
101 {
102  HRRCPS_RSP_ID_OK = 0x01, /**< Success. */
103  HRRCPS_RSP_ID_ERROR, /**< Fail. */
105 
106 /**@brief HRS RSCS Relay Control Point Service event type. */
107 typedef enum
108 {
109  HRRCPS_EVT_INVALID, /**< Invalid HRRCPS event type. */
110  HRRCPS_EVT_CTRL_PT_IND_ENABLE, /**< HRR Control Point indicaiton is enabled. */
111  HRRCPS_EVT_CTRL_PT_IND_DISABLE, /**< HRR Control Point indicaiton is disabled. */
112  HRRCPS_EVT_SCAN_HRS, /**< Scan HRS device. */
113  HRRCPS_EVT_SCAN_RSCS, /**< Scan RSCS device. */
114  HRRCPS_EVT_ENABLE_HRS_NTF, /**< Enable HRS notification. */
115  HRRCPS_EVT_DISABLE_HRS_NTF, /**< Disable HRS notification. */
116  HRRCPS_EVT_ENABLE_RSCS_NTF, /**< Enable RSCS notificaiton. */
117  HRRCPS_EVT_DISABLE_RSCS_NTF, /**< Disable RSCS notificaiton. */
118  HRRCPS_EVT_HRS_SENSOR_LOC_READ, /**< Read HRS sensor location. */
119  HRRCPS_EVT_RSCS_SENSOR_LOC_READ, /**< Read RSCS sensor location. */
120  HRRCPS_EVT_DISCONN_HRS_LINK, /**< Disconnect HRS link. */
121  HRRCPS_EVT_DISCONN_RSCS_LINK, /**< Disconnect RSCS link. */
123 /** @} */
124 
125 /**
126  * @defgroup HRRCPS_STRUCT Structures
127  * @{
128  */
129 /**@brief HRS RSCS Relay Control Point Response value. */
130 typedef struct
131 {
132  hrrcps_ctrl_pt_id_t cmd_id; /**< Control Point ID. */
133  hrrcps_rsp_id_t rsp_id; /**< Response ID. */
134  bool is_inc_prama; /**< Parameter is included or not. */
135  uint8_t rsp_param; /**< Response parameters. */
137 
138 /**@brief HRS RSCS Relay Control Point Service event. */
139 typedef struct
140 {
141  uint8_t conn_idx; /**< The index of the connection. */
142  hrrcps_evt_type_t evt_type; /**< The HRRCPS event type. */
143 } hrrcps_evt_t;
144 /** @} */
145 
146 /**
147  * @defgroup HRRCPS_TYPEDEF Typedefs
148  * @{
149  */
150 /**@brief HRS RSCS Relay Control Point Service event handler type.*/
151 typedef void (*hrrcps_evt_handler_t)(hrrcps_evt_t *p_evt);
152 /** @} */
153 
154 /**
155  * @defgroup ANS_FUNCTION Functions
156  * @{
157  */
158 /**
159  *****************************************************************************************
160  * @brief Initialize an Alert Notification Service instance and add in the DB.
161  *
162  * @param[in] evt_handler: HRS RSCS Relay Control Point Service event handler.
163  *
164  * @return Result of service initialization.
165  *****************************************************************************************
166  */
168 
169 /**
170  *****************************************************************************************
171  * @brief Send Control Point Response if its indicaiton has been enabled.
172  *
173  * @param[in] conn_idx: Connnection index.
174  * @param[in] p_rsp_val: Pointer to Response value.
175  *
176  * @return Result of indicate value
177  *****************************************************************************************
178  */
179 sdk_err_t hrrcps_ctrl_pt_rsp_send(uint8_t conn_idx, hrrcps_rsp_val_t *p_rsp_val);
180 /** @} */
181 
182 #endif
183 
184 /** @} */
185 /** @} */
HRRCPS_CTRL_PT_HRS_NTF_ENABLE
@ HRRCPS_CTRL_PT_HRS_NTF_ENABLE
Definition: hrrcps.h:88
hrrcps_rsp_val_t::is_inc_prama
bool is_inc_prama
Definition: hrrcps.h:134
hrrcps_rsp_id_t
hrrcps_rsp_id_t
HRS RSCS Relay Control Point Service Response IDs of Control Point.
Definition: hrrcps.h:101
HRRCPS_CTRL_PT_SCAN_RSCS
@ HRRCPS_CTRL_PT_SCAN_RSCS
Definition: hrrcps.h:85
HRRCPS_EVT_DISABLE_RSCS_NTF
@ HRRCPS_EVT_DISABLE_RSCS_NTF
Definition: hrrcps.h:117
hrrcps_rsp_val_t
HRS RSCS Relay Control Point Response value.
Definition: hrrcps.h:131
HRRCPS_CTRL_PT_RSCS_NTF_DISABLE
@ HRRCPS_CTRL_PT_RSCS_NTF_DISABLE
Definition: hrrcps.h:91
HRRCPS_EVT_DISCONN_RSCS_LINK
@ HRRCPS_EVT_DISCONN_RSCS_LINK
Definition: hrrcps.h:121
HRRCPS_CTRL_PT_HRS_SEN_LOC_READ
@ HRRCPS_CTRL_PT_HRS_SEN_LOC_READ
Definition: hrrcps.h:86
gr_includes.h
Include Files API.
HRRCPS_EVT_ENABLE_HRS_NTF
@ HRRCPS_EVT_ENABLE_HRS_NTF
Definition: hrrcps.h:114
HRRCPS_CTRL_PT_HRS_CONN_STA_REPORT
@ HRRCPS_CTRL_PT_HRS_CONN_STA_REPORT
Definition: hrrcps.h:92
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.
hrrcps_evt_t::conn_idx
uint8_t conn_idx
Definition: hrrcps.h:141
hrrcps_rsp_val_t::cmd_id
hrrcps_ctrl_pt_id_t cmd_id
Definition: hrrcps.h:132
HRRCPS_EVT_INVALID
@ HRRCPS_EVT_INVALID
Definition: hrrcps.h:109
HRRCPS_RSP_ID_OK
@ HRRCPS_RSP_ID_OK
Definition: hrrcps.h:102
HRRCPS_CTRL_PT_RSCS_SEN_LOC_READ
@ HRRCPS_CTRL_PT_RSCS_SEN_LOC_READ
Definition: hrrcps.h:87
HRRCPS_EVT_CTRL_PT_IND_ENABLE
@ HRRCPS_EVT_CTRL_PT_IND_ENABLE
Definition: hrrcps.h:110
hrrcps_evt_type_t
hrrcps_evt_type_t
HRS RSCS Relay Control Point Service event type.
Definition: hrrcps.h:108
HRRCPS_EVT_HRS_SENSOR_LOC_READ
@ HRRCPS_EVT_HRS_SENSOR_LOC_READ
Definition: hrrcps.h:118
HRRCPS_EVT_RSCS_SENSOR_LOC_READ
@ HRRCPS_EVT_RSCS_SENSOR_LOC_READ
Definition: hrrcps.h:119
HRRCPS_CTRL_PT_RSCS_DISCONN
@ HRRCPS_CTRL_PT_RSCS_DISCONN
Definition: hrrcps.h:95
HRRCPS_RSP_ID_ERROR
@ HRRCPS_RSP_ID_ERROR
Definition: hrrcps.h:103
hrrcps_ctrl_pt_id_t
hrrcps_ctrl_pt_id_t
HRS RSCS Relay Control Point Service Control Point IDs.
Definition: hrrcps.h:83
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:273
HRRCPS_CTRL_PT_SCAN_HRS
@ HRRCPS_CTRL_PT_SCAN_HRS
Definition: hrrcps.h:84
HRRCPS_EVT_DISCONN_HRS_LINK
@ HRRCPS_EVT_DISCONN_HRS_LINK
Definition: hrrcps.h:120
HRRCPS_CTRL_PT_RSP_CODE
@ HRRCPS_CTRL_PT_RSP_CODE
Definition: hrrcps.h:96
hrrcps_evt_t::evt_type
hrrcps_evt_type_t evt_type
Definition: hrrcps.h:142
hrrcps_rsp_val_t::rsp_param
uint8_t rsp_param
Definition: hrrcps.h:135
HRRCPS_CTRL_PT_HRS_DISCONN
@ HRRCPS_CTRL_PT_HRS_DISCONN
Definition: hrrcps.h:94
HRRCPS_CTRL_PT_RSCS_CONN_STA_REPORT
@ HRRCPS_CTRL_PT_RSCS_CONN_STA_REPORT
Definition: hrrcps.h:93
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:151
HRRCPS_EVT_ENABLE_RSCS_NTF
@ HRRCPS_EVT_ENABLE_RSCS_NTF
Definition: hrrcps.h:116
HRRCPS_CTRL_PT_RSCS_NTF_ENABLE
@ HRRCPS_CTRL_PT_RSCS_NTF_ENABLE
Definition: hrrcps.h:90
hrrcps_rsp_val_t::rsp_id
hrrcps_rsp_id_t rsp_id
Definition: hrrcps.h:133
HRRCPS_EVT_CTRL_PT_IND_DISABLE
@ HRRCPS_EVT_CTRL_PT_IND_DISABLE
Definition: hrrcps.h:111
HRRCPS_EVT_DISABLE_HRS_NTF
@ HRRCPS_EVT_DISABLE_HRS_NTF
Definition: hrrcps.h:115
HRRCPS_CTRL_PT_HRS_NTF_DISABLE
@ HRRCPS_CTRL_PT_HRS_NTF_DISABLE
Definition: hrrcps.h:89
HRRCPS_EVT_SCAN_RSCS
@ HRRCPS_EVT_SCAN_RSCS
Definition: hrrcps.h:113
HRRCPS_EVT_SCAN_HRS
@ HRRCPS_EVT_SCAN_HRS
Definition: hrrcps.h:112
hrrcps_evt_t
HRS RSCS Relay Control Point Service event.
Definition: hrrcps.h:140