• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <stdint.h>
61 #include <stdbool.h>
62 #include "ble_prf_types.h"
63 #include "gr55xx_sys.h"
64 #include "custom_config.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 \
72                                                                     HRS RSCS Relay Control Point Service connections. */
73 #define HRRCPS_CTRL_PT_VAL_LEN      2   /**< Length of the value of Control Point characteristic. */
74 #define HRRCPS_CTRL_PT_RSP_VAL_LEN  4   /**< Length of the value of Control Point Response characteristic. */
75 #define HRRCPS_SERVICE_UUID         0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80, 0x0A, 0x46, 0x44, 0xD3, \
76                                     0x01, 0x06, 0xED, 0xA6      /**< The UUID of HRS RSCS Relay Control Point Service \
77                                                                      for setting advertising data. */
78 /** @} */
79 
80 /**
81  * @defgroup HRRCPS_ENUM Enumerations
82  * @{
83  */
84 /**@brief HRS RSCS Relay Control Point Service Control Point IDs. */
85 typedef enum {
86     HRRCPS_CTRL_PT_SCAN_HRS = 0x01,        /**< Scan HRS device. */
87     HRRCPS_CTRL_PT_SCAN_RSCS,              /**< Scan RSCS device. */
88     HRRCPS_CTRL_PT_HRS_SEN_LOC_READ,       /**< Read HRS sensor location. */
89     HRRCPS_CTRL_PT_RSCS_SEN_LOC_READ,      /**< Read RSCS sensor location. */
90     HRRCPS_CTRL_PT_HRS_NTF_ENABLE,         /**< Enable HRS notification. */
91     HRRCPS_CTRL_PT_HRS_NTF_DISABLE,        /**< Disable HRS notification. */
92     HRRCPS_CTRL_PT_RSCS_NTF_ENABLE,        /**< Enable RSCS notification. */
93     HRRCPS_CTRL_PT_RSCS_NTF_DISABLE,       /**< Disable RSCS notification. */
94     HRRCPS_CTRL_PT_HRS_CONN_STA_REPORT,    /**< Report HRS connection state. */
95     HRRCPS_CTRL_PT_RSCS_CONN_STA_REPORT,   /**< Report RSCS connecntion state. */
96     HRRCPS_CTRL_PT_HRS_DISCONN,            /**< Disconnect HRS link. */
97     HRRCPS_CTRL_PT_RSCS_DISCONN,           /**< Disconnect RSCS link. */
98     HRRCPS_CTRL_PT_RSP_CODE = 0xff,        /**< Response code. */
99 } hrrcps_ctrl_pt_id_t;
100 
101 /**@brief HRS RSCS Relay Control Point Service Response IDs of Control Point. */
102 typedef enum {
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     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. */
122 } hrrcps_evt_type_t;
123 /** @} */
124 
125 /**
126  * @defgroup HRRCPS_STRUCT Structures
127  * @{
128  */
129 /**@brief HRS RSCS Relay Control Point Response value. */
130 typedef struct {
131     hrrcps_ctrl_pt_id_t  cmd_id;        /**< Control Point ID. */
132     hrrcps_rsp_id_t      rsp_id;        /**< Response ID. */
133     bool                 is_inc_prama;  /**< Parameter is included or not. */
134     uint8_t              rsp_param;     /**< Response parameters. */
135 } hrrcps_rsp_val_t;
136 
137 /**@brief HRS RSCS Relay Control Point Service event. */
138 typedef struct {
139     uint8_t           conn_idx;        /**< The index of the connection. */
140     hrrcps_evt_type_t evt_type;        /**< The HRRCPS event type. */
141 } hrrcps_evt_t;
142 /** @} */
143 
144 /**
145  * @defgroup HRRCPS_TYPEDEF Typedefs
146  * @{
147  */
148 /**@brief HRS RSCS Relay Control Point Service event handler type.*/
149 typedef void (*hrrcps_evt_handler_t)(hrrcps_evt_t *p_evt);
150 /** @} */
151 
152 /**
153  * @defgroup ANS_FUNCTION Functions
154  * @{
155  */
156 /**
157  *****************************************************************************************
158  * @brief Initialize an Alert Notification Service instance and add in the DB.
159  *
160  * @param[in] evt_handler: HRS RSCS Relay Control Point Service event handler.
161  *
162  * @return Result of service initialization.
163  *****************************************************************************************
164  */
165 sdk_err_t hrrcps_service_init(hrrcps_evt_handler_t evt_handler);
166 
167 /**
168  *****************************************************************************************
169  * @brief Send Control Point Response if its indicaiton has been enabled.
170  *
171  * @param[in] conn_idx:  Connnection index.
172  * @param[in] p_rsp_val: Pointer to Response value.
173  *
174  * @return Result of indicate value
175  *****************************************************************************************
176  */
177 sdk_err_t hrrcps_ctrl_pt_rsp_send(uint8_t conn_idx, hrrcps_rsp_val_t *p_rsp_val);
178 /** @} */
179 
180 #endif
181 
182 /** @} */
183 /** @} */
184