svc_core.h 6.23 KB
Newer Older
1
2
/* Copyright (c) 2009-2019 Arm Limited
 * SPDX-License-Identifier: Apache-2.0
schneider's avatar
schneider committed
3
 *
4
5
6
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
schneider's avatar
schneider committed
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
schneider's avatar
schneider committed
9
 *
10
11
12
13
14
15
16
17
18
19
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*************************************************************************************************/
/*!
 *  \brief Example GATT and GAP service implementations.
schneider's avatar
schneider committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 */
/*************************************************************************************************/

#ifndef SVC_CORE_H
#define SVC_CORE_H


#ifdef __cplusplus
extern "C" {
#endif

/*! \addtogroup GATT_AND_GAP_SERVICE
 *  \{ */


/**************************************************************************************************
 Handle Ranges
**************************************************************************************************/
/** \name GAP Service Handles
 * \note GAP -- RPAO characterstic added only when DM Privacy enabled
 */
/**@{*/
#define GAP_START_HDL               0x01               /*!< \brief GAP start handle */
#define GAP_END_HDL                 (GAP_MAX_HDL - 3)  /*!< \brief GAP end handle */
/**@}*/

/** \name GATT Service Handles
 *
 */
/**@{*/
#define GATT_START_HDL              0x10                /*!< \brief GATT start handle */
#define GATT_END_HDL                (GATT_MAX_HDL - 1)  /*!< \brief GATT end handle */
/**@}*/

/**************************************************************************************************
 Handles
**************************************************************************************************/

/** \name GAP Service Handles
 *
 */
/**@{*/
/*! \brief GAP service handle */
enum
{
  GAP_SVC_HDL = GAP_START_HDL,      /*!< \brief GAP service declaration */
  GAP_DN_CH_HDL,                    /*!< \brief Device name characteristic */
  GAP_DN_HDL,                       /*!< \brief Device name */
  GAP_AP_CH_HDL,                    /*!< \brief Appearance characteristic */
  GAP_AP_HDL,                       /*!< \brief Appearance */
  GAP_CAR_CH_HDL,                   /*!< \brief Central address resolution characteristic */
  GAP_CAR_HDL,                      /*!< \brief Central address resolution */
  GAP_RPAO_CH_HDL,                  /*!< \brief Resolvable private address only characteristic */
  GAP_RPAO_HDL,                     /*!< \brief Resolvable private address only */
  GAP_MAX_HDL                       /*!< \brief GAP maximum handle */
};
/**@}*/

/** \name GATT Service Handles
 *
 */
/**@{*/
/*! \brief GATT service handles */
enum
{
  GATT_SVC_HDL = GATT_START_HDL,    /*!< \brief GATT service declaration */
  GATT_SC_CH_HDL,                   /*!< \brief Service changed characteristic */
  GATT_SC_HDL,                      /*!< \brief Service changed */
  GATT_SC_CH_CCC_HDL,               /*!< \brief Service changed client characteristic configuration descriptor */
89
90
91
92
  GATT_CSF_CH_HDL,                  /*!< \brief Client supported features characteristic */
  GATT_CSF_HDL,                     /*!< \brief Client supported features */
  GATT_DBH_CH_HDL,                  /*!< \brief Database hash characteristic */
  GATT_DBH_HDL,                     /*!< \brief Database hash */
schneider's avatar
schneider committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
  GATT_MAX_HDL                      /*!< \brief GATT maximum handle */
};
/**@}*/

/**************************************************************************************************
  Function Declarations
**************************************************************************************************/

/*************************************************************************************************/
/*!
 *  \brief  Add the services to the attribute server.
 *
 *  \return None.
 */
/*************************************************************************************************/
void SvcCoreAddGroup(void);

/*************************************************************************************************/
/*!
 *  \brief  Remove the services from the attribute server.
 *
 *  \return None.
 */
/*************************************************************************************************/
void SvcCoreRemoveGroup(void);

/*************************************************************************************************/
/*!
 *  \brief  Register callbacks for the service.
 *
 *  \param  readCback   Read callback function.
 *  \param  writeCback  Write callback function.
 *
 *  \return None.
 */
/*************************************************************************************************/
void SvcCoreGattCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);

/*************************************************************************************************/
/*!
 *  \brief  Register callbacks for the service.
 *
 *  \param  readCback   Read callback function.
 *  \param  writeCback  Write callback function.
 *
 *  \return None.
 */
/*************************************************************************************************/
void SvcCoreGapCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);

/*************************************************************************************************/
/*!
 *  \brief  Update the central address resolution attribute value.
 *
 *  \param  value   New value.
 *
 *  \return None.
 */
/*************************************************************************************************/
void SvcCoreGapCentAddrResUpdate(bool_t value);

/*************************************************************************************************/
/*!
 *  \brief  Add the Resolvable Private Address Only (RPAO) characteristic to the GAP service.
 *          The RPAO characteristic should be added only when DM Privacy is enabled.
 *
 *  \return None.
 */
/*************************************************************************************************/
void SvcCoreGapAddRpaoCh(void);

/*! \} */    /* GATT_AND_GAP_SERVICE */

#ifdef __cplusplus
};
#endif

#endif /* SVC_CORE_H */