BLE FOTA APP

Dependencies:   BLE_API mbed

It doesn't work with the default FOTA bootloader. It use NVIC_SystemReset() to enter a bootloader.

Committer:
yihui
Date:
Fri Oct 10 03:36:28 2014 +0000
Revision:
1:a607cd9655d7
use NVIC_SystemReset() to run bootloader

Who changed what in which revision?

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