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