User | Revision | Line number | New contents of line |
jinu |
0:6ba9b94b8997
|
1
|
/* Copyright (c) Nordic Semiconductor ASA
|
jinu |
0:6ba9b94b8997
|
2
|
* All rights reserved.
|
jinu |
0:6ba9b94b8997
|
3
|
*
|
jinu |
0:6ba9b94b8997
|
4
|
* Redistribution and use in source and binary forms, with or without modification,
|
jinu |
0:6ba9b94b8997
|
5
|
* are permitted provided that the following conditions are met:
|
jinu |
0:6ba9b94b8997
|
6
|
*
|
jinu |
0:6ba9b94b8997
|
7
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
jinu |
0:6ba9b94b8997
|
8
|
* list of conditions and the following disclaimer.
|
jinu |
0:6ba9b94b8997
|
9
|
*
|
jinu |
0:6ba9b94b8997
|
10
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this
|
jinu |
0:6ba9b94b8997
|
11
|
* list of conditions and the following disclaimer in the documentation and/or
|
jinu |
0:6ba9b94b8997
|
12
|
* other materials provided with the distribution.
|
jinu |
0:6ba9b94b8997
|
13
|
*
|
jinu |
0:6ba9b94b8997
|
14
|
* 3. Neither the name of Nordic Semiconductor ASA nor the names of other
|
jinu |
0:6ba9b94b8997
|
15
|
* contributors to this software may be used to endorse or promote products
|
jinu |
0:6ba9b94b8997
|
16
|
* derived from this software without specific prior written permission.
|
jinu |
0:6ba9b94b8997
|
17
|
*
|
jinu |
0:6ba9b94b8997
|
18
|
* 4. This software must only be used in a processor manufactured by Nordic
|
jinu |
0:6ba9b94b8997
|
19
|
* Semiconductor ASA, or in a processor manufactured by a third party that
|
jinu |
0:6ba9b94b8997
|
20
|
* is used in combination with a processor manufactured by Nordic Semiconductor.
|
jinu |
0:6ba9b94b8997
|
21
|
*
|
jinu |
0:6ba9b94b8997
|
22
|
*
|
jinu |
0:6ba9b94b8997
|
23
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
jinu |
0:6ba9b94b8997
|
24
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
jinu |
0:6ba9b94b8997
|
25
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
jinu |
0:6ba9b94b8997
|
26
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
jinu |
0:6ba9b94b8997
|
27
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
jinu |
0:6ba9b94b8997
|
28
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
jinu |
0:6ba9b94b8997
|
29
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
jinu |
0:6ba9b94b8997
|
30
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
jinu |
0:6ba9b94b8997
|
31
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
jinu |
0:6ba9b94b8997
|
32
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
jinu |
0:6ba9b94b8997
|
33
|
*/
|
jinu |
0:6ba9b94b8997
|
34
|
|
jinu |
0:6ba9b94b8997
|
35
|
/** @file
|
jinu |
0:6ba9b94b8997
|
36
|
*
|
jinu |
0:6ba9b94b8997
|
37
|
* @defgroup ble_sdk_srv_common 'Common service definitions'
|
jinu |
0:6ba9b94b8997
|
38
|
* @{
|
jinu |
0:6ba9b94b8997
|
39
|
* @ingroup ble_sdk_srv
|
jinu |
0:6ba9b94b8997
|
40
|
* @brief Constants, type definitions and functions that are common to all services.
|
jinu |
0:6ba9b94b8997
|
41
|
*/
|
jinu |
0:6ba9b94b8997
|
42
|
|
jinu |
0:6ba9b94b8997
|
43
|
#ifndef BLE_SRV_COMMON_H__
|
jinu |
0:6ba9b94b8997
|
44
|
#define BLE_SRV_COMMON_H__
|
jinu |
0:6ba9b94b8997
|
45
|
|
jinu |
0:6ba9b94b8997
|
46
|
#include <stdint.h>
|
jinu |
0:6ba9b94b8997
|
47
|
#include <stdbool.h>
|
jinu |
0:6ba9b94b8997
|
48
|
#include "ble_types.h"
|
jinu |
0:6ba9b94b8997
|
49
|
#include "app_util.h"
|
jinu |
0:6ba9b94b8997
|
50
|
#include "ble_gap.h"
|
jinu |
0:6ba9b94b8997
|
51
|
#include "ble_gatt.h"
|
jinu |
0:6ba9b94b8997
|
52
|
|
jinu |
0:6ba9b94b8997
|
53
|
/** @defgroup UUID_SERVICES Service UUID definitions
|
jinu |
0:6ba9b94b8997
|
54
|
* @{ */
|
jinu |
0:6ba9b94b8997
|
55
|
#define BLE_UUID_ALERT_NOTIFICATION_SERVICE 0x1811 /**< Alert Notification service UUID. */
|
jinu |
0:6ba9b94b8997
|
56
|
#define BLE_UUID_BATTERY_SERVICE 0x180F /**< Battery service UUID. */
|
jinu |
0:6ba9b94b8997
|
57
|
#define BLE_UUID_BLOOD_PRESSURE_SERVICE 0x1810 /**< Blood Pressure service UUID. */
|
jinu |
0:6ba9b94b8997
|
58
|
#define BLE_UUID_CURRENT_TIME_SERVICE 0x1805 /**< Current Time service UUID. */
|
jinu |
0:6ba9b94b8997
|
59
|
#define BLE_UUID_CYCLING_SPEED_AND_CADENCE 0x1816 /**< Cycling Speed and Cadence service UUID. */
|
jinu |
0:6ba9b94b8997
|
60
|
#define BLE_UUID_DEVICE_INFORMATION_SERVICE 0x180A /**< Device Information service UUID. */
|
jinu |
0:6ba9b94b8997
|
61
|
#define BLE_UUID_GLUCOSE_SERVICE 0x1808 /**< Glucose service UUID. */
|
jinu |
0:6ba9b94b8997
|
62
|
#define BLE_UUID_HEALTH_THERMOMETER_SERVICE 0x1809 /**< Health Thermometer service UUID. */
|
jinu |
0:6ba9b94b8997
|
63
|
#define BLE_UUID_HEART_RATE_SERVICE 0x180D /**< Heart Rate service UUID. */
|
jinu |
0:6ba9b94b8997
|
64
|
#define BLE_UUID_HUMAN_INTERFACE_DEVICE_SERVICE 0x1812 /**< Human Interface Device service UUID. */
|
jinu |
0:6ba9b94b8997
|
65
|
#define BLE_UUID_IMMEDIATE_ALERT_SERVICE 0x1802 /**< Immediate Alert service UUID. */
|
jinu |
0:6ba9b94b8997
|
66
|
#define BLE_UUID_LINK_LOSS_SERVICE 0x1803 /**< Link Loss service UUID. */
|
jinu |
0:6ba9b94b8997
|
67
|
#define BLE_UUID_NEXT_DST_CHANGE_SERVICE 0x1807 /**< Next Dst Change service UUID. */
|
jinu |
0:6ba9b94b8997
|
68
|
#define BLE_UUID_PHONE_ALERT_STATUS_SERVICE 0x180E /**< Phone Alert Status service UUID. */
|
jinu |
0:6ba9b94b8997
|
69
|
#define BLE_UUID_REFERENCE_TIME_UPDATE_SERVICE 0x1806 /**< Reference Time Update service UUID. */
|
jinu |
0:6ba9b94b8997
|
70
|
#define BLE_UUID_RUNNING_SPEED_AND_CADENCE 0x1814 /**< Running Speed and Cadence service UUID. */
|
jinu |
0:6ba9b94b8997
|
71
|
#define BLE_UUID_SCAN_PARAMETERS_SERVICE 0x1813 /**< Scan Parameters service UUID. */
|
jinu |
0:6ba9b94b8997
|
72
|
#define BLE_UUID_TX_POWER_SERVICE 0x1804 /**< TX Power service UUID. */
|
jinu |
0:6ba9b94b8997
|
73
|
/** @} */
|
jinu |
0:6ba9b94b8997
|
74
|
|
jinu |
0:6ba9b94b8997
|
75
|
/** @defgroup UUID_CHARACTERISTICS Characteristic UUID definitions
|
jinu |
0:6ba9b94b8997
|
76
|
* @{ */
|
jinu |
0:6ba9b94b8997
|
77
|
#define BLE_UUID_BATTERY_LEVEL_STATE_CHAR 0x2A1B /**< Battery Level State characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
78
|
#define BLE_UUID_BATTERY_POWER_STATE_CHAR 0x2A1A /**< Battery Power State characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
79
|
#define BLE_UUID_REMOVABLE_CHAR 0x2A3A /**< Removable characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
80
|
#define BLE_UUID_SERVICE_REQUIRED_CHAR 0x2A3B /**< Service Required characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
81
|
#define BLE_UUID_ALERT_CATEGORY_ID_CHAR 0x2A43 /**< Alert Category Id characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
82
|
#define BLE_UUID_ALERT_CATEGORY_ID_BIT_MASK_CHAR 0x2A42 /**< Alert Category Id Bit Mask characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
83
|
#define BLE_UUID_ALERT_LEVEL_CHAR 0x2A06 /**< Alert Level characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
84
|
#define BLE_UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR 0x2A44 /**< Alert Notification Control Point characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
85
|
#define BLE_UUID_ALERT_STATUS_CHAR 0x2A3F /**< Alert Status characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
86
|
#define BLE_UUID_BATTERY_LEVEL_CHAR 0x2A19 /**< Battery Level characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
87
|
#define BLE_UUID_BLOOD_PRESSURE_FEATURE_CHAR 0x2A49 /**< Blood Pressure Feature characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
88
|
#define BLE_UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR 0x2A35 /**< Blood Pressure Measurement characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
89
|
#define BLE_UUID_BODY_SENSOR_LOCATION_CHAR 0x2A38 /**< Body Sensor Location characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
90
|
#define BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR 0x2A22 /**< Boot Keyboard Input Report characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
91
|
#define BLE_UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR 0x2A32 /**< Boot Keyboard Output Report characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
92
|
#define BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR 0x2A33 /**< Boot Mouse Input Report characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
93
|
#define BLE_UUID_CURRENT_TIME_CHAR 0x2A2B /**< Current Time characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
94
|
#define BLE_UUID_DATE_TIME_CHAR 0x2A08 /**< Date Time characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
95
|
#define BLE_UUID_DAY_DATE_TIME_CHAR 0x2A0A /**< Day Date Time characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
96
|
#define BLE_UUID_DAY_OF_WEEK_CHAR 0x2A09 /**< Day Of Week characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
97
|
#define BLE_UUID_DST_OFFSET_CHAR 0x2A0D /**< Dst Offset characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
98
|
#define BLE_UUID_EXACT_TIME_256_CHAR 0x2A0C /**< Exact Time 256 characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
99
|
#define BLE_UUID_FIRMWARE_REVISION_STRING_CHAR 0x2A26 /**< Firmware Revision String characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
100
|
#define BLE_UUID_GLUCOSE_FEATURE_CHAR 0x2A51 /**< Glucose Feature characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
101
|
#define BLE_UUID_GLUCOSE_MEASUREMENT_CHAR 0x2A18 /**< Glucose Measurement characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
102
|
#define BLE_UUID_GLUCOSE_MEASUREMENT_CONTEXT_CHAR 0x2A34 /**< Glucose Measurement Context characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
103
|
#define BLE_UUID_HARDWARE_REVISION_STRING_CHAR 0x2A27 /**< Hardware Revision String characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
104
|
#define BLE_UUID_HEART_RATE_CONTROL_POINT_CHAR 0x2A39 /**< Heart Rate Control Point characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
105
|
#define BLE_UUID_HEART_RATE_MEASUREMENT_CHAR 0x2A37 /**< Heart Rate Measurement characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
106
|
#define BLE_UUID_HID_CONTROL_POINT_CHAR 0x2A4C /**< Hid Control Point characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
107
|
#define BLE_UUID_HID_INFORMATION_CHAR 0x2A4A /**< Hid Information characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
108
|
#define BLE_UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR 0x2A2A /**< IEEE Regulatory Certification Data List characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
109
|
#define BLE_UUID_INTERMEDIATE_CUFF_PRESSURE_CHAR 0x2A36 /**< Intermediate Cuff Pressure characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
110
|
#define BLE_UUID_INTERMEDIATE_TEMPERATURE_CHAR 0x2A1E /**< Intermediate Temperature characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
111
|
#define BLE_UUID_LOCAL_TIME_INFORMATION_CHAR 0x2A0F /**< Local Time Information characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
112
|
#define BLE_UUID_MANUFACTURER_NAME_STRING_CHAR 0x2A29 /**< Manufacturer Name String characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
113
|
#define BLE_UUID_MEASUREMENT_INTERVAL_CHAR 0x2A21 /**< Measurement Interval characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
114
|
#define BLE_UUID_MODEL_NUMBER_STRING_CHAR 0x2A24 /**< Model Number String characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
115
|
#define BLE_UUID_UNREAD_ALERT_CHAR 0x2A45 /**< Unread Alert characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
116
|
#define BLE_UUID_NEW_ALERT_CHAR 0x2A46 /**< New Alert characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
117
|
#define BLE_UUID_PNP_ID_CHAR 0x2A50 /**< PNP Id characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
118
|
#define BLE_UUID_PROTOCOL_MODE_CHAR 0x2A4E /**< Protocol Mode characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
119
|
#define BLE_UUID_RECORD_ACCESS_CONTROL_POINT_CHAR 0x2A52 /**< Record Access Control Point characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
120
|
#define BLE_UUID_REFERENCE_TIME_INFORMATION_CHAR 0x2A14 /**< Reference Time Information characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
121
|
#define BLE_UUID_REPORT_CHAR 0x2A4D /**< Report characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
122
|
#define BLE_UUID_REPORT_MAP_CHAR 0x2A4B /**< Report Map characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
123
|
#define BLE_UUID_RINGER_CONTROL_POINT_CHAR 0x2A40 /**< Ringer Control Point characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
124
|
#define BLE_UUID_RINGER_SETTING_CHAR 0x2A41 /**< Ringer Setting characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
125
|
#define BLE_UUID_SCAN_INTERVAL_WINDOW_CHAR 0x2A4F /**< Scan Interval Window characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
126
|
#define BLE_UUID_SCAN_REFRESH_CHAR 0x2A31 /**< Scan Refresh characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
127
|
#define BLE_UUID_SERIAL_NUMBER_STRING_CHAR 0x2A25 /**< Serial Number String characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
128
|
#define BLE_UUID_SOFTWARE_REVISION_STRING_CHAR 0x2A28 /**< Software Revision String characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
129
|
#define BLE_UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR 0x2A47 /**< Supported New Alert Category characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
130
|
#define BLE_UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR 0x2A48 /**< Supported Unread Alert Category characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
131
|
#define BLE_UUID_SYSTEM_ID_CHAR 0x2A23 /**< System Id characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
132
|
#define BLE_UUID_TEMPERATURE_MEASUREMENT_CHAR 0x2A1C /**< Temperature Measurement characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
133
|
#define BLE_UUID_TEMPERATURE_TYPE_CHAR 0x2A1D /**< Temperature Type characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
134
|
#define BLE_UUID_TIME_ACCURACY_CHAR 0x2A12 /**< Time Accuracy characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
135
|
#define BLE_UUID_TIME_SOURCE_CHAR 0x2A13 /**< Time Source characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
136
|
#define BLE_UUID_TIME_UPDATE_CONTROL_POINT_CHAR 0x2A16 /**< Time Update Control Point characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
137
|
#define BLE_UUID_TIME_UPDATE_STATE_CHAR 0x2A17 /**< Time Update State characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
138
|
#define BLE_UUID_TIME_WITH_DST_CHAR 0x2A11 /**< Time With Dst characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
139
|
#define BLE_UUID_TIME_ZONE_CHAR 0x2A0E /**< Time Zone characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
140
|
#define BLE_UUID_TX_POWER_LEVEL_CHAR 0x2A07 /**< TX Power Level characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
141
|
#define BLE_UUID_CSC_FEATURE_CHAR 0x2A5C /**< Cycling Speed and Cadence Feature characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
142
|
#define BLE_UUID_CSC_MEASUREMENT_CHAR 0x2A5B /**< Cycling Speed and Cadence Measurement characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
143
|
#define BLE_UUID_RSC_FEATURE_CHAR 0x2A54 /**< Running Speed and Cadence Feature characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
144
|
#define BLE_UUID_SC_CTRLPT_CHAR 0x2A55 /**< Speed and Cadence Control Point UUID. */
|
jinu |
0:6ba9b94b8997
|
145
|
#define BLE_UUID_RSC_MEASUREMENT_CHAR 0x2A53 /**< Running Speed and Cadence Measurement characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
146
|
#define BLE_UUID_SENSOR_LOCATION_CHAR 0x2A5D /**< Sensor Location characteristic UUID. */
|
jinu |
0:6ba9b94b8997
|
147
|
/** @} */
|
jinu |
0:6ba9b94b8997
|
148
|
|
jinu |
0:6ba9b94b8997
|
149
|
/** @defgroup UUID_CHARACTERISTICS descriptors UUID definitions
|
jinu |
0:6ba9b94b8997
|
150
|
* @{ */
|
jinu |
0:6ba9b94b8997
|
151
|
#define BLE_UUID_EXTERNAL_REPORT_REF_DESCR 0x2907 /**< External Report Reference descriptor UUID. */
|
jinu |
0:6ba9b94b8997
|
152
|
#define BLE_UUID_REPORT_REF_DESCR 0x2908 /**< Report Reference descriptor UUID. */
|
jinu |
0:6ba9b94b8997
|
153
|
/** @} */
|
jinu |
0:6ba9b94b8997
|
154
|
|
jinu |
0:6ba9b94b8997
|
155
|
/** @defgroup ALERT_LEVEL_VALUES Definitions for the Alert Level characteristic values
|
jinu |
0:6ba9b94b8997
|
156
|
* @{ */
|
jinu |
0:6ba9b94b8997
|
157
|
#define BLE_CHAR_ALERT_LEVEL_NO_ALERT 0x00 /**< No Alert. */
|
jinu |
0:6ba9b94b8997
|
158
|
#define BLE_CHAR_ALERT_LEVEL_MILD_ALERT 0x01 /**< Mild Alert. */
|
jinu |
0:6ba9b94b8997
|
159
|
#define BLE_CHAR_ALERT_LEVEL_HIGH_ALERT 0x02 /**< High Alert. */
|
jinu |
0:6ba9b94b8997
|
160
|
/** @} */
|
jinu |
0:6ba9b94b8997
|
161
|
|
jinu |
0:6ba9b94b8997
|
162
|
#define BLE_SRV_ENCODED_REPORT_REF_LEN 2 /**< The length of an encoded Report Reference Descriptor. */
|
jinu |
0:6ba9b94b8997
|
163
|
#define BLE_CCCD_VALUE_LEN 2 /**< The length of a CCCD value. */
|
jinu |
0:6ba9b94b8997
|
164
|
|
jinu |
0:6ba9b94b8997
|
165
|
/**@brief Type definition for error handler function which will be called in case of an error in
|
jinu |
0:6ba9b94b8997
|
166
|
* a service or a service library module. */
|
jinu |
0:6ba9b94b8997
|
167
|
typedef void (*ble_srv_error_handler_t) (uint32_t nrf_error);
|
jinu |
0:6ba9b94b8997
|
168
|
|
jinu |
0:6ba9b94b8997
|
169
|
/**@brief Value of a Report Reference descriptor.
|
jinu |
0:6ba9b94b8997
|
170
|
*
|
jinu |
0:6ba9b94b8997
|
171
|
* @details This is mapping information which maps the parent characteristic to the Report ID(s) and
|
jinu |
0:6ba9b94b8997
|
172
|
* Report Type(s) defined within a Report Map characteristic.
|
jinu |
0:6ba9b94b8997
|
173
|
*/
|
jinu |
0:6ba9b94b8997
|
174
|
typedef struct
|
jinu |
0:6ba9b94b8997
|
175
|
{
|
jinu |
0:6ba9b94b8997
|
176
|
uint8_t report_id; /**< Non-zero value if these is more than one instance of the same Report Type */
|
jinu |
0:6ba9b94b8997
|
177
|
uint8_t report_type; /**< Type of Report characteristic (see @ref BLE_SRV_HIDS_REPORT_TYPE) */
|
jinu |
0:6ba9b94b8997
|
178
|
} ble_srv_report_ref_t;
|
jinu |
0:6ba9b94b8997
|
179
|
|
jinu |
0:6ba9b94b8997
|
180
|
/**@brief UTF-8 string data type.
|
jinu |
0:6ba9b94b8997
|
181
|
*
|
jinu |
0:6ba9b94b8997
|
182
|
* @note The type can only hold a pointer to the string data (i.e. not the actual data).
|
jinu |
0:6ba9b94b8997
|
183
|
*/
|
jinu |
0:6ba9b94b8997
|
184
|
typedef struct
|
jinu |
0:6ba9b94b8997
|
185
|
{
|
jinu |
0:6ba9b94b8997
|
186
|
uint16_t length; /**< String length. */
|
jinu |
0:6ba9b94b8997
|
187
|
uint8_t * p_str; /**< String data. */
|
jinu |
0:6ba9b94b8997
|
188
|
} ble_srv_utf8_str_t;
|
jinu |
0:6ba9b94b8997
|
189
|
|
jinu |
0:6ba9b94b8997
|
190
|
/**@brief Security settings structure.
|
jinu |
0:6ba9b94b8997
|
191
|
* @details This structure contains the security options needed during initialization of the
|
jinu |
0:6ba9b94b8997
|
192
|
* service.
|
jinu |
0:6ba9b94b8997
|
193
|
*/
|
jinu |
0:6ba9b94b8997
|
194
|
typedef struct
|
jinu |
0:6ba9b94b8997
|
195
|
{
|
jinu |
0:6ba9b94b8997
|
196
|
ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */
|
jinu |
0:6ba9b94b8997
|
197
|
ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */
|
jinu |
0:6ba9b94b8997
|
198
|
} ble_srv_security_mode_t;
|
jinu |
0:6ba9b94b8997
|
199
|
|
jinu |
0:6ba9b94b8997
|
200
|
/**@brief Security settings structure.
|
jinu |
0:6ba9b94b8997
|
201
|
* @details This structure contains the security options needed during initialization of the
|
jinu |
0:6ba9b94b8997
|
202
|
* service. It can be used when the charecteristics contains cccd.
|
jinu |
0:6ba9b94b8997
|
203
|
*/
|
jinu |
0:6ba9b94b8997
|
204
|
typedef struct
|
jinu |
0:6ba9b94b8997
|
205
|
{
|
jinu |
0:6ba9b94b8997
|
206
|
ble_gap_conn_sec_mode_t cccd_write_perm;
|
jinu |
0:6ba9b94b8997
|
207
|
ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */
|
jinu |
0:6ba9b94b8997
|
208
|
ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */
|
jinu |
0:6ba9b94b8997
|
209
|
} ble_srv_cccd_security_mode_t;
|
jinu |
0:6ba9b94b8997
|
210
|
|
jinu |
0:6ba9b94b8997
|
211
|
/**@brief Function for decoding a CCCD value, and then testing if notification is
|
jinu |
0:6ba9b94b8997
|
212
|
* enabled.
|
jinu |
0:6ba9b94b8997
|
213
|
*
|
jinu |
0:6ba9b94b8997
|
214
|
* @param[in] p_encoded_data Buffer where the encoded CCCD is stored.
|
jinu |
0:6ba9b94b8997
|
215
|
*
|
jinu |
0:6ba9b94b8997
|
216
|
* @return TRUE if notification is enabled, FALSE otherwise.
|
jinu |
0:6ba9b94b8997
|
217
|
*/
|
jinu |
0:6ba9b94b8997
|
218
|
static __INLINE bool ble_srv_is_notification_enabled(uint8_t * p_encoded_data)
|
jinu |
0:6ba9b94b8997
|
219
|
{
|
jinu |
0:6ba9b94b8997
|
220
|
uint16_t cccd_value = uint16_decode(p_encoded_data);
|
jinu |
0:6ba9b94b8997
|
221
|
return ((cccd_value & BLE_GATT_HVX_NOTIFICATION) != 0);
|
jinu |
0:6ba9b94b8997
|
222
|
}
|
jinu |
0:6ba9b94b8997
|
223
|
|
jinu |
0:6ba9b94b8997
|
224
|
/**@brief Function for decoding a CCCD value, and then testing if indication is
|
jinu |
0:6ba9b94b8997
|
225
|
* enabled.
|
jinu |
0:6ba9b94b8997
|
226
|
*
|
jinu |
0:6ba9b94b8997
|
227
|
* @param[in] p_encoded_data Buffer where the encoded CCCD is stored.
|
jinu |
0:6ba9b94b8997
|
228
|
*
|
jinu |
0:6ba9b94b8997
|
229
|
* @return TRUE if indication is enabled, FALSE otherwise.
|
jinu |
0:6ba9b94b8997
|
230
|
*/
|
jinu |
0:6ba9b94b8997
|
231
|
static __INLINE bool ble_srv_is_indication_enabled(uint8_t * p_encoded_data)
|
jinu |
0:6ba9b94b8997
|
232
|
{
|
jinu |
0:6ba9b94b8997
|
233
|
uint16_t cccd_value = uint16_decode(p_encoded_data);
|
jinu |
0:6ba9b94b8997
|
234
|
return ((cccd_value & BLE_GATT_HVX_INDICATION) != 0);
|
jinu |
0:6ba9b94b8997
|
235
|
}
|
jinu |
0:6ba9b94b8997
|
236
|
|
jinu |
0:6ba9b94b8997
|
237
|
/**@brief Function for encoding a Report Reference Descriptor.
|
jinu |
0:6ba9b94b8997
|
238
|
*
|
jinu |
0:6ba9b94b8997
|
239
|
* @param[in] p_encoded_buffer The buffer of the encoded data.
|
jinu |
0:6ba9b94b8997
|
240
|
* @param[in] p_report_ref Report Reference value to be encoded.
|
jinu |
0:6ba9b94b8997
|
241
|
*
|
jinu |
0:6ba9b94b8997
|
242
|
* @return Length of the encoded data.
|
jinu |
0:6ba9b94b8997
|
243
|
*/
|
jinu |
0:6ba9b94b8997
|
244
|
uint8_t ble_srv_report_ref_encode(uint8_t * p_encoded_buffer,
|
jinu |
0:6ba9b94b8997
|
245
|
const ble_srv_report_ref_t * p_report_ref);
|
jinu |
0:6ba9b94b8997
|
246
|
|
jinu |
0:6ba9b94b8997
|
247
|
/**@brief Function for making UTF-8 structure refer to an ASCII string.
|
jinu |
0:6ba9b94b8997
|
248
|
*
|
jinu |
0:6ba9b94b8997
|
249
|
* @param[out] p_utf8 UTF-8 structure to be set.
|
jinu |
0:6ba9b94b8997
|
250
|
* @param[in] p_ascii ASCII string to be referred to.
|
jinu |
0:6ba9b94b8997
|
251
|
*/
|
jinu |
0:6ba9b94b8997
|
252
|
void ble_srv_ascii_to_utf8(ble_srv_utf8_str_t * p_utf8, char * p_ascii);
|
jinu |
0:6ba9b94b8997
|
253
|
|
jinu |
0:6ba9b94b8997
|
254
|
#endif // BLE_SRV_COMMON_H__
|
jinu |
0:6ba9b94b8997
|
255
|
|
jinu |
0:6ba9b94b8997
|
256
|
/** @} */
|
jinu |
0:6ba9b94b8997
|
257
|
|