HM_IOT_Demo / nrf51-sdk

Fork of nrf51-sdk by Nordic Semiconductor

Committer:
vcoubard
Date:
Thu Apr 07 17:37:47 2016 +0100
Revision:
22:67a8d2c0bbbf
Parent:
20:a90c48eb1d30
Child:
24:2aea0c1c57ee
Synchronized with git rev 21d0f023
Author: Liyou Zhou
Change version number in README

Who changed what in which revision?

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