Mouse code for the MacroRat
mbed-dev/targets/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF51822_UNIFIED/sdk/softdevice/s130/headers/nrf_ble_gatts.h@46:b156ef445742, 2017-06-03 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sat Jun 03 00:22:44 2017 +0000
- Revision:
- 46:b156ef445742
- Parent:
- 18:6a4db94011d3
Final code for internal battlebot competition.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /* |
sahilmgandhi | 18:6a4db94011d3 | 2 | * Copyright (c) 2000 Nordic Semiconductor ASA |
sahilmgandhi | 18:6a4db94011d3 | 3 | * All rights reserved. |
sahilmgandhi | 18:6a4db94011d3 | 4 | * |
sahilmgandhi | 18:6a4db94011d3 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
sahilmgandhi | 18:6a4db94011d3 | 6 | * are permitted provided that the following conditions are met: |
sahilmgandhi | 18:6a4db94011d3 | 7 | * |
sahilmgandhi | 18:6a4db94011d3 | 8 | * 1. Redistributions of source code must retain the above copyright notice, this list |
sahilmgandhi | 18:6a4db94011d3 | 9 | * of conditions and the following disclaimer. |
sahilmgandhi | 18:6a4db94011d3 | 10 | * |
sahilmgandhi | 18:6a4db94011d3 | 11 | * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA |
sahilmgandhi | 18:6a4db94011d3 | 12 | * integrated circuit in a product or a software update for such product, must reproduce |
sahilmgandhi | 18:6a4db94011d3 | 13 | * the above copyright notice, this list of conditions and the following disclaimer in |
sahilmgandhi | 18:6a4db94011d3 | 14 | * the documentation and/or other materials provided with the distribution. |
sahilmgandhi | 18:6a4db94011d3 | 15 | * |
sahilmgandhi | 18:6a4db94011d3 | 16 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be |
sahilmgandhi | 18:6a4db94011d3 | 17 | * used to endorse or promote products derived from this software without specific prior |
sahilmgandhi | 18:6a4db94011d3 | 18 | * written permission. |
sahilmgandhi | 18:6a4db94011d3 | 19 | * |
sahilmgandhi | 18:6a4db94011d3 | 20 | * 4. This software, with or without modification, must only be used with a |
sahilmgandhi | 18:6a4db94011d3 | 21 | * Nordic Semiconductor ASA integrated circuit. |
sahilmgandhi | 18:6a4db94011d3 | 22 | * |
sahilmgandhi | 18:6a4db94011d3 | 23 | * 5. Any software provided in binary or object form under this license must not be reverse |
sahilmgandhi | 18:6a4db94011d3 | 24 | * engineered, decompiled, modified and/or disassembled. |
sahilmgandhi | 18:6a4db94011d3 | 25 | * |
sahilmgandhi | 18:6a4db94011d3 | 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
sahilmgandhi | 18:6a4db94011d3 | 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
sahilmgandhi | 18:6a4db94011d3 | 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
sahilmgandhi | 18:6a4db94011d3 | 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
sahilmgandhi | 18:6a4db94011d3 | 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
sahilmgandhi | 18:6a4db94011d3 | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
sahilmgandhi | 18:6a4db94011d3 | 32 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
sahilmgandhi | 18:6a4db94011d3 | 33 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
sahilmgandhi | 18:6a4db94011d3 | 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
sahilmgandhi | 18:6a4db94011d3 | 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
sahilmgandhi | 18:6a4db94011d3 | 36 | * |
sahilmgandhi | 18:6a4db94011d3 | 37 | */ |
sahilmgandhi | 18:6a4db94011d3 | 38 | |
sahilmgandhi | 18:6a4db94011d3 | 39 | |
sahilmgandhi | 18:6a4db94011d3 | 40 | /** |
sahilmgandhi | 18:6a4db94011d3 | 41 | @addtogroup BLE_GATTS Generic Attribute Profile (GATT) Server |
sahilmgandhi | 18:6a4db94011d3 | 42 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 43 | @brief Definitions and prototypes for the GATTS interface. |
sahilmgandhi | 18:6a4db94011d3 | 44 | */ |
sahilmgandhi | 18:6a4db94011d3 | 45 | |
sahilmgandhi | 18:6a4db94011d3 | 46 | #ifndef NRF_BLE_GATTS_H__ |
sahilmgandhi | 18:6a4db94011d3 | 47 | #define NRF_BLE_GATTS_H__ |
sahilmgandhi | 18:6a4db94011d3 | 48 | |
sahilmgandhi | 18:6a4db94011d3 | 49 | #include "nrf_ble_types.h" |
sahilmgandhi | 18:6a4db94011d3 | 50 | #include "nrf_ble_ranges.h" |
sahilmgandhi | 18:6a4db94011d3 | 51 | #include "nrf_ble_l2cap.h" |
sahilmgandhi | 18:6a4db94011d3 | 52 | #include "nrf_ble_gap.h" |
sahilmgandhi | 18:6a4db94011d3 | 53 | #include "nrf_ble_gatt.h" |
sahilmgandhi | 18:6a4db94011d3 | 54 | #include "nrf_svc.h" |
sahilmgandhi | 18:6a4db94011d3 | 55 | |
sahilmgandhi | 18:6a4db94011d3 | 56 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 57 | extern "C" { |
sahilmgandhi | 18:6a4db94011d3 | 58 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 59 | |
sahilmgandhi | 18:6a4db94011d3 | 60 | /** @addtogroup BLE_GATTS_ENUMERATIONS Enumerations |
sahilmgandhi | 18:6a4db94011d3 | 61 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 62 | |
sahilmgandhi | 18:6a4db94011d3 | 63 | /** |
sahilmgandhi | 18:6a4db94011d3 | 64 | * @brief GATTS API SVC numbers. |
sahilmgandhi | 18:6a4db94011d3 | 65 | */ |
sahilmgandhi | 18:6a4db94011d3 | 66 | enum BLE_GATTS_SVCS |
sahilmgandhi | 18:6a4db94011d3 | 67 | { |
sahilmgandhi | 18:6a4db94011d3 | 68 | SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE, /**< Add a service. */ |
sahilmgandhi | 18:6a4db94011d3 | 69 | SD_BLE_GATTS_INCLUDE_ADD, /**< Add an included service. */ |
sahilmgandhi | 18:6a4db94011d3 | 70 | SD_BLE_GATTS_CHARACTERISTIC_ADD, /**< Add a characteristic. */ |
sahilmgandhi | 18:6a4db94011d3 | 71 | SD_BLE_GATTS_DESCRIPTOR_ADD, /**< Add a generic attribute. */ |
sahilmgandhi | 18:6a4db94011d3 | 72 | SD_BLE_GATTS_VALUE_SET, /**< Set an attribute value. */ |
sahilmgandhi | 18:6a4db94011d3 | 73 | SD_BLE_GATTS_VALUE_GET, /**< Get an attribute value. */ |
sahilmgandhi | 18:6a4db94011d3 | 74 | SD_BLE_GATTS_HVX, /**< Handle Value Notification or Indication. */ |
sahilmgandhi | 18:6a4db94011d3 | 75 | SD_BLE_GATTS_SERVICE_CHANGED, /**< Perform a Service Changed Indication to one or more peers. */ |
sahilmgandhi | 18:6a4db94011d3 | 76 | SD_BLE_GATTS_RW_AUTHORIZE_REPLY, /**< Reply to an authorization request for a read or write operation on one or more attributes. */ |
sahilmgandhi | 18:6a4db94011d3 | 77 | SD_BLE_GATTS_SYS_ATTR_SET, /**< Set the persistent system attributes for a connection. */ |
sahilmgandhi | 18:6a4db94011d3 | 78 | SD_BLE_GATTS_SYS_ATTR_GET, /**< Retrieve the persistent system attributes. */ |
sahilmgandhi | 18:6a4db94011d3 | 79 | SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, /**< Retrieve the first valid user handle. */ |
sahilmgandhi | 18:6a4db94011d3 | 80 | SD_BLE_GATTS_ATTR_GET /**< Retrieve the UUID and/or metadata of an attribute. */ |
sahilmgandhi | 18:6a4db94011d3 | 81 | }; |
sahilmgandhi | 18:6a4db94011d3 | 82 | |
sahilmgandhi | 18:6a4db94011d3 | 83 | /** |
sahilmgandhi | 18:6a4db94011d3 | 84 | * @brief GATT Server Event IDs. |
sahilmgandhi | 18:6a4db94011d3 | 85 | */ |
sahilmgandhi | 18:6a4db94011d3 | 86 | enum BLE_GATTS_EVTS |
sahilmgandhi | 18:6a4db94011d3 | 87 | { |
sahilmgandhi | 18:6a4db94011d3 | 88 | BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. \n See @ref ble_gatts_evt_write_t. */ |
sahilmgandhi | 18:6a4db94011d3 | 89 | BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request. \n Reply with @ref sd_ble_gatts_rw_authorize_reply. \n See @ref ble_gatts_evt_rw_authorize_request_t. */ |
sahilmgandhi | 18:6a4db94011d3 | 90 | BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending. \n Respond with @ref sd_ble_gatts_sys_attr_set. \n See @ref ble_gatts_evt_sys_attr_missing_t. */ |
sahilmgandhi | 18:6a4db94011d3 | 91 | BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. \n See @ref ble_gatts_evt_hvc_t. */ |
sahilmgandhi | 18:6a4db94011d3 | 92 | BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. No additional event structure applies. */ |
sahilmgandhi | 18:6a4db94011d3 | 93 | BLE_GATTS_EVT_TIMEOUT /**< Peer failed to resonpond to an ATT request in time. \n See @ref ble_gatts_evt_timeout_t. */ |
sahilmgandhi | 18:6a4db94011d3 | 94 | }; |
sahilmgandhi | 18:6a4db94011d3 | 95 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 96 | |
sahilmgandhi | 18:6a4db94011d3 | 97 | /** @addtogroup BLE_GATTS_DEFINES Defines |
sahilmgandhi | 18:6a4db94011d3 | 98 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 99 | |
sahilmgandhi | 18:6a4db94011d3 | 100 | /** @defgroup BLE_ERRORS_GATTS SVC return values specific to GATTS |
sahilmgandhi | 18:6a4db94011d3 | 101 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 102 | #define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000) /**< Invalid attribute type. */ |
sahilmgandhi | 18:6a4db94011d3 | 103 | #define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001) /**< System Attributes missing. */ |
sahilmgandhi | 18:6a4db94011d3 | 104 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 105 | |
sahilmgandhi | 18:6a4db94011d3 | 106 | /** @defgroup BLE_GATTS_ATTR_LENS_MAX Maximum attribute lengths |
sahilmgandhi | 18:6a4db94011d3 | 107 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 108 | #define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */ |
sahilmgandhi | 18:6a4db94011d3 | 109 | #define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */ |
sahilmgandhi | 18:6a4db94011d3 | 110 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 111 | |
sahilmgandhi | 18:6a4db94011d3 | 112 | /** @defgroup BLE_GATTS_SRVC_TYPES GATT Server Service Types |
sahilmgandhi | 18:6a4db94011d3 | 113 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 114 | #define BLE_GATTS_SRVC_TYPE_INVALID 0x00 /**< Invalid Service Type. */ |
sahilmgandhi | 18:6a4db94011d3 | 115 | #define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01 /**< Primary Service. */ |
sahilmgandhi | 18:6a4db94011d3 | 116 | #define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02 /**< Secondary Type. */ |
sahilmgandhi | 18:6a4db94011d3 | 117 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 118 | |
sahilmgandhi | 18:6a4db94011d3 | 119 | |
sahilmgandhi | 18:6a4db94011d3 | 120 | /** @defgroup BLE_GATTS_ATTR_TYPES GATT Server Attribute Types |
sahilmgandhi | 18:6a4db94011d3 | 121 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 122 | #define BLE_GATTS_ATTR_TYPE_INVALID 0x00 /**< Invalid Attribute Type. */ |
sahilmgandhi | 18:6a4db94011d3 | 123 | #define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01 /**< Primary Service Declaration. */ |
sahilmgandhi | 18:6a4db94011d3 | 124 | #define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02 /**< Secondary Service Declaration. */ |
sahilmgandhi | 18:6a4db94011d3 | 125 | #define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03 /**< Include Declaration. */ |
sahilmgandhi | 18:6a4db94011d3 | 126 | #define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04 /**< Characteristic Declaration. */ |
sahilmgandhi | 18:6a4db94011d3 | 127 | #define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05 /**< Characteristic Value. */ |
sahilmgandhi | 18:6a4db94011d3 | 128 | #define BLE_GATTS_ATTR_TYPE_DESC 0x06 /**< Descriptor. */ |
sahilmgandhi | 18:6a4db94011d3 | 129 | #define BLE_GATTS_ATTR_TYPE_OTHER 0x07 /**< Other, non-GATT specific type. */ |
sahilmgandhi | 18:6a4db94011d3 | 130 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 131 | |
sahilmgandhi | 18:6a4db94011d3 | 132 | |
sahilmgandhi | 18:6a4db94011d3 | 133 | /** @defgroup BLE_GATTS_OPS GATT Server Operations |
sahilmgandhi | 18:6a4db94011d3 | 134 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 135 | #define BLE_GATTS_OP_INVALID 0x00 /**< Invalid Operation. */ |
sahilmgandhi | 18:6a4db94011d3 | 136 | #define BLE_GATTS_OP_WRITE_REQ 0x01 /**< Write Request. */ |
sahilmgandhi | 18:6a4db94011d3 | 137 | #define BLE_GATTS_OP_WRITE_CMD 0x02 /**< Write Command. */ |
sahilmgandhi | 18:6a4db94011d3 | 138 | #define BLE_GATTS_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */ |
sahilmgandhi | 18:6a4db94011d3 | 139 | #define BLE_GATTS_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */ |
sahilmgandhi | 18:6a4db94011d3 | 140 | #define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05 /**< Execute Write Request: Cancel all prepared writes. */ |
sahilmgandhi | 18:6a4db94011d3 | 141 | #define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06 /**< Execute Write Request: Immediately execute all prepared writes. */ |
sahilmgandhi | 18:6a4db94011d3 | 142 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 143 | |
sahilmgandhi | 18:6a4db94011d3 | 144 | /** @defgroup BLE_GATTS_VLOCS GATT Value Locations |
sahilmgandhi | 18:6a4db94011d3 | 145 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 146 | #define BLE_GATTS_VLOC_INVALID 0x00 /**< Invalid Location. */ |
sahilmgandhi | 18:6a4db94011d3 | 147 | #define BLE_GATTS_VLOC_STACK 0x01 /**< Attribute Value is located in stack memory, no user memory is required. */ |
sahilmgandhi | 18:6a4db94011d3 | 148 | #define BLE_GATTS_VLOC_USER 0x02 /**< Attribute Value is located in user memory. This requires the user to maintain a valid buffer through the lifetime of the attribute, since the stack |
sahilmgandhi | 18:6a4db94011d3 | 149 | will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */ |
sahilmgandhi | 18:6a4db94011d3 | 150 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 151 | |
sahilmgandhi | 18:6a4db94011d3 | 152 | /** @defgroup BLE_GATTS_AUTHORIZE_TYPES GATT Server Authorization Types |
sahilmgandhi | 18:6a4db94011d3 | 153 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 154 | #define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00 /**< Invalid Type. */ |
sahilmgandhi | 18:6a4db94011d3 | 155 | #define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01 /**< Authorize a Read Operation. */ |
sahilmgandhi | 18:6a4db94011d3 | 156 | #define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02 /**< Authorize a Write Request Operation. */ |
sahilmgandhi | 18:6a4db94011d3 | 157 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 158 | |
sahilmgandhi | 18:6a4db94011d3 | 159 | /** @defgroup BLE_GATTS_SYS_ATTR_FLAGS System Attribute Flags |
sahilmgandhi | 18:6a4db94011d3 | 160 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 161 | #define BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS (1 << 0) /**< Restrict system attributes to system services only. */ |
sahilmgandhi | 18:6a4db94011d3 | 162 | #define BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS (1 << 1) /**< Restrict system attributes to user services only. */ |
sahilmgandhi | 18:6a4db94011d3 | 163 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 164 | |
sahilmgandhi | 18:6a4db94011d3 | 165 | /** @defgroup BLE_GATTS_ATTR_TAB_SIZE Attribute Table size |
sahilmgandhi | 18:6a4db94011d3 | 166 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 167 | */ |
sahilmgandhi | 18:6a4db94011d3 | 168 | #define BLE_GATTS_ATTR_TAB_SIZE_MIN 216 /**< Minimum Attribute Table size */ |
sahilmgandhi | 18:6a4db94011d3 | 169 | #define BLE_GATTS_ATTR_TAB_SIZE_DEFAULT 0x0000 /**< Default Attribute Table size (0x580 bytes for this version of the SoftDevice). */ |
sahilmgandhi | 18:6a4db94011d3 | 170 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 171 | |
sahilmgandhi | 18:6a4db94011d3 | 172 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 173 | |
sahilmgandhi | 18:6a4db94011d3 | 174 | /** @addtogroup BLE_GATTS_STRUCTURES Structures |
sahilmgandhi | 18:6a4db94011d3 | 175 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 176 | |
sahilmgandhi | 18:6a4db94011d3 | 177 | /** |
sahilmgandhi | 18:6a4db94011d3 | 178 | * @brief BLE GATTS initialization parameters. |
sahilmgandhi | 18:6a4db94011d3 | 179 | */ |
sahilmgandhi | 18:6a4db94011d3 | 180 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 181 | { |
sahilmgandhi | 18:6a4db94011d3 | 182 | uint8_t service_changed:1; /**< Include the Service Changed characteristic in the Attribute Table. */ |
sahilmgandhi | 18:6a4db94011d3 | 183 | uint32_t attr_tab_size; /**< Attribute Table size in bytes. The size must be a multiple of 4. @ref BLE_GATTS_ATTR_TAB_SIZE_DEFAULT is used to set the default size. */ |
sahilmgandhi | 18:6a4db94011d3 | 184 | } ble_gatts_enable_params_t; |
sahilmgandhi | 18:6a4db94011d3 | 185 | |
sahilmgandhi | 18:6a4db94011d3 | 186 | /**@brief Attribute metadata. */ |
sahilmgandhi | 18:6a4db94011d3 | 187 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 188 | { |
sahilmgandhi | 18:6a4db94011d3 | 189 | ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */ |
sahilmgandhi | 18:6a4db94011d3 | 190 | ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */ |
sahilmgandhi | 18:6a4db94011d3 | 191 | uint8_t vlen :1; /**< Variable length attribute. */ |
sahilmgandhi | 18:6a4db94011d3 | 192 | uint8_t vloc :2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/ |
sahilmgandhi | 18:6a4db94011d3 | 193 | uint8_t rd_auth :1; /**< Read authorization and value will be requested from the application on every read operation. */ |
sahilmgandhi | 18:6a4db94011d3 | 194 | uint8_t wr_auth :1; /**< Write authorization will be requested from the application on every Write Request operation (but not Write Command). */ |
sahilmgandhi | 18:6a4db94011d3 | 195 | } ble_gatts_attr_md_t; |
sahilmgandhi | 18:6a4db94011d3 | 196 | |
sahilmgandhi | 18:6a4db94011d3 | 197 | |
sahilmgandhi | 18:6a4db94011d3 | 198 | /**@brief GATT Attribute. */ |
sahilmgandhi | 18:6a4db94011d3 | 199 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 200 | { |
sahilmgandhi | 18:6a4db94011d3 | 201 | ble_uuid_t *p_uuid; /**< Pointer to the attribute UUID. */ |
sahilmgandhi | 18:6a4db94011d3 | 202 | ble_gatts_attr_md_t *p_attr_md; /**< Pointer to the attribute metadata structure. */ |
sahilmgandhi | 18:6a4db94011d3 | 203 | uint16_t init_len; /**< Initial attribute value length in bytes. */ |
sahilmgandhi | 18:6a4db94011d3 | 204 | uint16_t init_offs; /**< Initial attribute value offset in bytes. If different from zero, the first init_offs bytes of the attribute value will be left uninitialized. */ |
sahilmgandhi | 18:6a4db94011d3 | 205 | uint16_t max_len; /**< Maximum attribute value length in bytes, see @ref BLE_GATTS_ATTR_LENS_MAX for maximum values. */ |
sahilmgandhi | 18:6a4db94011d3 | 206 | uint8_t* p_value; /**< Pointer to the attribute data. Please note that if the @ref BLE_GATTS_VLOC_USER value location is selected in the attribute metadata, this will have to point to a buffer |
sahilmgandhi | 18:6a4db94011d3 | 207 | that remains valid through the lifetime of the attribute. This excludes usage of automatic variables that may go out of scope or any other temporary location. |
sahilmgandhi | 18:6a4db94011d3 | 208 | The stack may access that memory directly without the application's knowledge. For writable characteristics, this value must not be a location in flash memory.*/ |
sahilmgandhi | 18:6a4db94011d3 | 209 | } ble_gatts_attr_t; |
sahilmgandhi | 18:6a4db94011d3 | 210 | |
sahilmgandhi | 18:6a4db94011d3 | 211 | /**@brief GATT Attribute Value. */ |
sahilmgandhi | 18:6a4db94011d3 | 212 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 213 | { |
sahilmgandhi | 18:6a4db94011d3 | 214 | uint16_t len; /**< Length in bytes to be written or read. Length in bytes written or read after successful return.*/ |
sahilmgandhi | 18:6a4db94011d3 | 215 | uint16_t offset; /**< Attribute value offset. */ |
sahilmgandhi | 18:6a4db94011d3 | 216 | uint8_t *p_value; /**< Pointer to where value is stored or will be stored. |
sahilmgandhi | 18:6a4db94011d3 | 217 | If value is stored in user memory, only the attribute length is updated when p_value == NULL. |
sahilmgandhi | 18:6a4db94011d3 | 218 | Set to NULL when reading to obtain the complete length of the attribute value */ |
sahilmgandhi | 18:6a4db94011d3 | 219 | } ble_gatts_value_t; |
sahilmgandhi | 18:6a4db94011d3 | 220 | |
sahilmgandhi | 18:6a4db94011d3 | 221 | |
sahilmgandhi | 18:6a4db94011d3 | 222 | /**@brief GATT Characteristic Presentation Format. */ |
sahilmgandhi | 18:6a4db94011d3 | 223 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 224 | { |
sahilmgandhi | 18:6a4db94011d3 | 225 | uint8_t format; /**< Format of the value, see @ref BLE_GATT_CPF_FORMATS. */ |
sahilmgandhi | 18:6a4db94011d3 | 226 | int8_t exponent; /**< Exponent for integer data types. */ |
sahilmgandhi | 18:6a4db94011d3 | 227 | uint16_t unit; /**< Unit from Bluetooth Assigned Numbers. */ |
sahilmgandhi | 18:6a4db94011d3 | 228 | uint8_t name_space; /**< Namespace from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */ |
sahilmgandhi | 18:6a4db94011d3 | 229 | uint16_t desc; /**< Namespace description from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */ |
sahilmgandhi | 18:6a4db94011d3 | 230 | } ble_gatts_char_pf_t; |
sahilmgandhi | 18:6a4db94011d3 | 231 | |
sahilmgandhi | 18:6a4db94011d3 | 232 | |
sahilmgandhi | 18:6a4db94011d3 | 233 | /**@brief GATT Characteristic metadata. */ |
sahilmgandhi | 18:6a4db94011d3 | 234 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 235 | { |
sahilmgandhi | 18:6a4db94011d3 | 236 | ble_gatt_char_props_t char_props; /**< Characteristic Properties. */ |
sahilmgandhi | 18:6a4db94011d3 | 237 | ble_gatt_char_ext_props_t char_ext_props; /**< Characteristic Extended Properties. */ |
sahilmgandhi | 18:6a4db94011d3 | 238 | uint8_t *p_char_user_desc; /**< Pointer to a UTF-8 encoded string (non-NULL terminated), NULL if the descriptor is not required. */ |
sahilmgandhi | 18:6a4db94011d3 | 239 | uint16_t char_user_desc_max_size; /**< The maximum size in bytes of the user description descriptor. */ |
sahilmgandhi | 18:6a4db94011d3 | 240 | uint16_t char_user_desc_size; /**< The size of the user description, must be smaller or equal to char_user_desc_max_size. */ |
sahilmgandhi | 18:6a4db94011d3 | 241 | ble_gatts_char_pf_t* p_char_pf; /**< Pointer to a presentation format structure or NULL if the CPF descriptor is not required. */ |
sahilmgandhi | 18:6a4db94011d3 | 242 | ble_gatts_attr_md_t* p_user_desc_md; /**< Attribute metadata for the User Description descriptor, or NULL for default values. */ |
sahilmgandhi | 18:6a4db94011d3 | 243 | ble_gatts_attr_md_t* p_cccd_md; /**< Attribute metadata for the Client Characteristic Configuration Descriptor, or NULL for default values. */ |
sahilmgandhi | 18:6a4db94011d3 | 244 | ble_gatts_attr_md_t* p_sccd_md; /**< Attribute metadata for the Server Characteristic Configuration Descriptor, or NULL for default values. */ |
sahilmgandhi | 18:6a4db94011d3 | 245 | } ble_gatts_char_md_t; |
sahilmgandhi | 18:6a4db94011d3 | 246 | |
sahilmgandhi | 18:6a4db94011d3 | 247 | |
sahilmgandhi | 18:6a4db94011d3 | 248 | /**@brief GATT Characteristic Definition Handles. */ |
sahilmgandhi | 18:6a4db94011d3 | 249 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 250 | { |
sahilmgandhi | 18:6a4db94011d3 | 251 | uint16_t value_handle; /**< Handle to the characteristic value. */ |
sahilmgandhi | 18:6a4db94011d3 | 252 | uint16_t user_desc_handle; /**< Handle to the User Description descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ |
sahilmgandhi | 18:6a4db94011d3 | 253 | uint16_t cccd_handle; /**< Handle to the Client Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ |
sahilmgandhi | 18:6a4db94011d3 | 254 | uint16_t sccd_handle; /**< Handle to the Server Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ |
sahilmgandhi | 18:6a4db94011d3 | 255 | } ble_gatts_char_handles_t; |
sahilmgandhi | 18:6a4db94011d3 | 256 | |
sahilmgandhi | 18:6a4db94011d3 | 257 | |
sahilmgandhi | 18:6a4db94011d3 | 258 | /**@brief GATT HVx parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 259 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 260 | { |
sahilmgandhi | 18:6a4db94011d3 | 261 | uint16_t handle; /**< Characteristic Value Handle. */ |
sahilmgandhi | 18:6a4db94011d3 | 262 | uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */ |
sahilmgandhi | 18:6a4db94011d3 | 263 | uint16_t offset; /**< Offset within the attribute value. */ |
sahilmgandhi | 18:6a4db94011d3 | 264 | uint16_t *p_len; /**< Length in bytes to be written, length in bytes written after successful return. */ |
sahilmgandhi | 18:6a4db94011d3 | 265 | uint8_t *p_data; /**< Actual data content, use NULL to use the current attribute value. */ |
sahilmgandhi | 18:6a4db94011d3 | 266 | } ble_gatts_hvx_params_t; |
sahilmgandhi | 18:6a4db94011d3 | 267 | |
sahilmgandhi | 18:6a4db94011d3 | 268 | /**@brief GATT Authorization parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 269 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 270 | { |
sahilmgandhi | 18:6a4db94011d3 | 271 | uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */ |
sahilmgandhi | 18:6a4db94011d3 | 272 | uint8_t update : 1; /**< If set, data supplied in p_data will be used to update the attribute value. |
sahilmgandhi | 18:6a4db94011d3 | 273 | Please note that for @ref BLE_GATTS_OP_WRITE_REQ operations this bit must always be set, |
sahilmgandhi | 18:6a4db94011d3 | 274 | as the data to be written needs to be stored and later provided by the application. */ |
sahilmgandhi | 18:6a4db94011d3 | 275 | uint16_t offset; /**< Offset of the attribute value being updated. */ |
sahilmgandhi | 18:6a4db94011d3 | 276 | uint16_t len; /**< Length in bytes of the value in p_data pointer, see @ref BLE_GATTS_ATTR_LENS_MAX. */ |
sahilmgandhi | 18:6a4db94011d3 | 277 | const uint8_t *p_data; /**< Pointer to new value used to update the attribute value. */ |
sahilmgandhi | 18:6a4db94011d3 | 278 | } ble_gatts_authorize_params_t; |
sahilmgandhi | 18:6a4db94011d3 | 279 | |
sahilmgandhi | 18:6a4db94011d3 | 280 | /**@brief GATT Read or Write Authorize Reply parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 281 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 282 | { |
sahilmgandhi | 18:6a4db94011d3 | 283 | uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */ |
sahilmgandhi | 18:6a4db94011d3 | 284 | union { |
sahilmgandhi | 18:6a4db94011d3 | 285 | ble_gatts_authorize_params_t read; /**< Read authorization parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 286 | ble_gatts_authorize_params_t write; /**< Write authorization parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 287 | } params; /**< Reply Parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 288 | } ble_gatts_rw_authorize_reply_params_t; |
sahilmgandhi | 18:6a4db94011d3 | 289 | |
sahilmgandhi | 18:6a4db94011d3 | 290 | |
sahilmgandhi | 18:6a4db94011d3 | 291 | |
sahilmgandhi | 18:6a4db94011d3 | 292 | /**@brief Event structure for @ref BLE_GATTS_EVT_WRITE. */ |
sahilmgandhi | 18:6a4db94011d3 | 293 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 294 | { |
sahilmgandhi | 18:6a4db94011d3 | 295 | uint16_t handle; /**< Attribute Handle. */ |
sahilmgandhi | 18:6a4db94011d3 | 296 | ble_uuid_t uuid; /**< Attribute UUID. */ |
sahilmgandhi | 18:6a4db94011d3 | 297 | uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */ |
sahilmgandhi | 18:6a4db94011d3 | 298 | uint8_t auth_required; /**< Writing operation deferred due to authorization requirement. Application may use @ref sd_ble_gatts_value_set to finalise the writing operation. */ |
sahilmgandhi | 18:6a4db94011d3 | 299 | uint16_t offset; /**< Offset for the write operation. */ |
sahilmgandhi | 18:6a4db94011d3 | 300 | uint16_t len; /**< Length of the received data. */ |
sahilmgandhi | 18:6a4db94011d3 | 301 | uint8_t data[1]; /**< Received data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. |
sahilmgandhi | 18:6a4db94011d3 | 302 | See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ |
sahilmgandhi | 18:6a4db94011d3 | 303 | } ble_gatts_evt_write_t; |
sahilmgandhi | 18:6a4db94011d3 | 304 | |
sahilmgandhi | 18:6a4db94011d3 | 305 | /**@brief Event substructure for authorized read requests, see @ref ble_gatts_evt_rw_authorize_request_t. */ |
sahilmgandhi | 18:6a4db94011d3 | 306 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 307 | { |
sahilmgandhi | 18:6a4db94011d3 | 308 | uint16_t handle; /**< Attribute Handle. */ |
sahilmgandhi | 18:6a4db94011d3 | 309 | ble_uuid_t uuid; /**< Attribute UUID. */ |
sahilmgandhi | 18:6a4db94011d3 | 310 | uint16_t offset; /**< Offset for the read operation. */ |
sahilmgandhi | 18:6a4db94011d3 | 311 | } ble_gatts_evt_read_t; |
sahilmgandhi | 18:6a4db94011d3 | 312 | |
sahilmgandhi | 18:6a4db94011d3 | 313 | /**@brief Event structure for @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. */ |
sahilmgandhi | 18:6a4db94011d3 | 314 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 315 | { |
sahilmgandhi | 18:6a4db94011d3 | 316 | uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */ |
sahilmgandhi | 18:6a4db94011d3 | 317 | union { |
sahilmgandhi | 18:6a4db94011d3 | 318 | ble_gatts_evt_read_t read; /**< Attribute Read Parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 319 | ble_gatts_evt_write_t write; /**< Attribute Write Parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 320 | } request; /**< Request Parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 321 | } ble_gatts_evt_rw_authorize_request_t; |
sahilmgandhi | 18:6a4db94011d3 | 322 | |
sahilmgandhi | 18:6a4db94011d3 | 323 | /**@brief Event structure for @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. */ |
sahilmgandhi | 18:6a4db94011d3 | 324 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 325 | { |
sahilmgandhi | 18:6a4db94011d3 | 326 | uint8_t hint; /**< Hint (currently unused). */ |
sahilmgandhi | 18:6a4db94011d3 | 327 | } ble_gatts_evt_sys_attr_missing_t; |
sahilmgandhi | 18:6a4db94011d3 | 328 | |
sahilmgandhi | 18:6a4db94011d3 | 329 | |
sahilmgandhi | 18:6a4db94011d3 | 330 | /**@brief Event structure for @ref BLE_GATTS_EVT_HVC. */ |
sahilmgandhi | 18:6a4db94011d3 | 331 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 332 | { |
sahilmgandhi | 18:6a4db94011d3 | 333 | uint16_t handle; /**< Attribute Handle. */ |
sahilmgandhi | 18:6a4db94011d3 | 334 | } ble_gatts_evt_hvc_t; |
sahilmgandhi | 18:6a4db94011d3 | 335 | |
sahilmgandhi | 18:6a4db94011d3 | 336 | /**@brief Event structure for @ref BLE_GATTS_EVT_TIMEOUT. */ |
sahilmgandhi | 18:6a4db94011d3 | 337 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 338 | { |
sahilmgandhi | 18:6a4db94011d3 | 339 | uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */ |
sahilmgandhi | 18:6a4db94011d3 | 340 | } ble_gatts_evt_timeout_t; |
sahilmgandhi | 18:6a4db94011d3 | 341 | |
sahilmgandhi | 18:6a4db94011d3 | 342 | |
sahilmgandhi | 18:6a4db94011d3 | 343 | /**@brief GATT Server event callback event structure. */ |
sahilmgandhi | 18:6a4db94011d3 | 344 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 345 | { |
sahilmgandhi | 18:6a4db94011d3 | 346 | uint16_t conn_handle; /**< Connection Handle on which the event occurred. */ |
sahilmgandhi | 18:6a4db94011d3 | 347 | union |
sahilmgandhi | 18:6a4db94011d3 | 348 | { |
sahilmgandhi | 18:6a4db94011d3 | 349 | ble_gatts_evt_write_t write; /**< Write Event Parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 350 | ble_gatts_evt_rw_authorize_request_t authorize_request; /**< Read or Write Authorize Request Parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 351 | ble_gatts_evt_sys_attr_missing_t sys_attr_missing; /**< System attributes missing. */ |
sahilmgandhi | 18:6a4db94011d3 | 352 | ble_gatts_evt_hvc_t hvc; /**< Handle Value Confirmation Event Parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 353 | ble_gatts_evt_timeout_t timeout; /**< Timeout Event. */ |
sahilmgandhi | 18:6a4db94011d3 | 354 | } params; /**< Event Parameters. */ |
sahilmgandhi | 18:6a4db94011d3 | 355 | } ble_gatts_evt_t; |
sahilmgandhi | 18:6a4db94011d3 | 356 | |
sahilmgandhi | 18:6a4db94011d3 | 357 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 358 | |
sahilmgandhi | 18:6a4db94011d3 | 359 | /** @addtogroup BLE_GATTS_FUNCTIONS Functions |
sahilmgandhi | 18:6a4db94011d3 | 360 | * @{ */ |
sahilmgandhi | 18:6a4db94011d3 | 361 | |
sahilmgandhi | 18:6a4db94011d3 | 362 | /**@brief Add a service declaration to the Attribute Table. |
sahilmgandhi | 18:6a4db94011d3 | 363 | * |
sahilmgandhi | 18:6a4db94011d3 | 364 | * @note Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to |
sahilmgandhi | 18:6a4db94011d3 | 365 | * add a secondary service declaration that is not referenced by another service later in the Attribute Table. |
sahilmgandhi | 18:6a4db94011d3 | 366 | * |
sahilmgandhi | 18:6a4db94011d3 | 367 | * @mscs |
sahilmgandhi | 18:6a4db94011d3 | 368 | * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 369 | * @endmscs |
sahilmgandhi | 18:6a4db94011d3 | 370 | * |
sahilmgandhi | 18:6a4db94011d3 | 371 | * @param[in] type Toggles between primary and secondary services, see @ref BLE_GATTS_SRVC_TYPES. |
sahilmgandhi | 18:6a4db94011d3 | 372 | * @param[in] p_uuid Pointer to service UUID. |
sahilmgandhi | 18:6a4db94011d3 | 373 | * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored. |
sahilmgandhi | 18:6a4db94011d3 | 374 | * |
sahilmgandhi | 18:6a4db94011d3 | 375 | * @retval ::NRF_SUCCESS Successfully added a service declaration. |
sahilmgandhi | 18:6a4db94011d3 | 376 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 377 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table. |
sahilmgandhi | 18:6a4db94011d3 | 378 | * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. |
sahilmgandhi | 18:6a4db94011d3 | 379 | * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. |
sahilmgandhi | 18:6a4db94011d3 | 380 | */ |
sahilmgandhi | 18:6a4db94011d3 | 381 | SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle)); |
sahilmgandhi | 18:6a4db94011d3 | 382 | |
sahilmgandhi | 18:6a4db94011d3 | 383 | |
sahilmgandhi | 18:6a4db94011d3 | 384 | /**@brief Add an include declaration to the Attribute Table. |
sahilmgandhi | 18:6a4db94011d3 | 385 | * |
sahilmgandhi | 18:6a4db94011d3 | 386 | * @note It is currently only possible to add an include declaration to the last added service (i.e. only sequential population is supported at this time). |
sahilmgandhi | 18:6a4db94011d3 | 387 | * |
sahilmgandhi | 18:6a4db94011d3 | 388 | * @note The included service must already be present in the Attribute Table prior to this call. |
sahilmgandhi | 18:6a4db94011d3 | 389 | * |
sahilmgandhi | 18:6a4db94011d3 | 390 | * @mscs |
sahilmgandhi | 18:6a4db94011d3 | 391 | * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 392 | * @endmscs |
sahilmgandhi | 18:6a4db94011d3 | 393 | * |
sahilmgandhi | 18:6a4db94011d3 | 394 | * @param[in] service_handle Handle of the service where the included service is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. |
sahilmgandhi | 18:6a4db94011d3 | 395 | * @param[in] inc_srvc_handle Handle of the included service. |
sahilmgandhi | 18:6a4db94011d3 | 396 | * @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored. |
sahilmgandhi | 18:6a4db94011d3 | 397 | * |
sahilmgandhi | 18:6a4db94011d3 | 398 | * @retval ::NRF_SUCCESS Successfully added an include declaration. |
sahilmgandhi | 18:6a4db94011d3 | 399 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 400 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services. |
sahilmgandhi | 18:6a4db94011d3 | 401 | * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. |
sahilmgandhi | 18:6a4db94011d3 | 402 | * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed. |
sahilmgandhi | 18:6a4db94011d3 | 403 | * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. |
sahilmgandhi | 18:6a4db94011d3 | 404 | * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. |
sahilmgandhi | 18:6a4db94011d3 | 405 | */ |
sahilmgandhi | 18:6a4db94011d3 | 406 | SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *p_include_handle)); |
sahilmgandhi | 18:6a4db94011d3 | 407 | |
sahilmgandhi | 18:6a4db94011d3 | 408 | |
sahilmgandhi | 18:6a4db94011d3 | 409 | /**@brief Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the Attribute Table. |
sahilmgandhi | 18:6a4db94011d3 | 410 | * |
sahilmgandhi | 18:6a4db94011d3 | 411 | * @note It is currently only possible to add a characteristic to the last added service (i.e. only sequential population is supported at this time). |
sahilmgandhi | 18:6a4db94011d3 | 412 | * |
sahilmgandhi | 18:6a4db94011d3 | 413 | * @note Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writeable auxiliaries bits, |
sahilmgandhi | 18:6a4db94011d3 | 414 | * readable (no security) and writeable (selectable) CCCDs and SCCDs and valid presentation format values. |
sahilmgandhi | 18:6a4db94011d3 | 415 | * |
sahilmgandhi | 18:6a4db94011d3 | 416 | * @note If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions. |
sahilmgandhi | 18:6a4db94011d3 | 417 | * |
sahilmgandhi | 18:6a4db94011d3 | 418 | * @mscs |
sahilmgandhi | 18:6a4db94011d3 | 419 | * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 420 | * @endmscs |
sahilmgandhi | 18:6a4db94011d3 | 421 | * |
sahilmgandhi | 18:6a4db94011d3 | 422 | * @param[in] service_handle Handle of the service where the characteristic is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. |
sahilmgandhi | 18:6a4db94011d3 | 423 | * @param[in] p_char_md Characteristic metadata. |
sahilmgandhi | 18:6a4db94011d3 | 424 | * @param[in] p_attr_char_value Pointer to the attribute structure corresponding to the characteristic value. |
sahilmgandhi | 18:6a4db94011d3 | 425 | * @param[out] p_handles Pointer to the structure where the assigned handles will be stored. |
sahilmgandhi | 18:6a4db94011d3 | 426 | * |
sahilmgandhi | 18:6a4db94011d3 | 427 | * @retval ::NRF_SUCCESS Successfully added a characteristic. |
sahilmgandhi | 18:6a4db94011d3 | 428 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 429 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints. |
sahilmgandhi | 18:6a4db94011d3 | 430 | * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required. |
sahilmgandhi | 18:6a4db94011d3 | 431 | * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. |
sahilmgandhi | 18:6a4db94011d3 | 432 | * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. |
sahilmgandhi | 18:6a4db94011d3 | 433 | * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. |
sahilmgandhi | 18:6a4db94011d3 | 434 | */ |
sahilmgandhi | 18:6a4db94011d3 | 435 | SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles)); |
sahilmgandhi | 18:6a4db94011d3 | 436 | |
sahilmgandhi | 18:6a4db94011d3 | 437 | |
sahilmgandhi | 18:6a4db94011d3 | 438 | /**@brief Add a descriptor to the Attribute Table. |
sahilmgandhi | 18:6a4db94011d3 | 439 | * |
sahilmgandhi | 18:6a4db94011d3 | 440 | * @note It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential population is supported at this time). |
sahilmgandhi | 18:6a4db94011d3 | 441 | * |
sahilmgandhi | 18:6a4db94011d3 | 442 | * @mscs |
sahilmgandhi | 18:6a4db94011d3 | 443 | * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 444 | * @endmscs |
sahilmgandhi | 18:6a4db94011d3 | 445 | * |
sahilmgandhi | 18:6a4db94011d3 | 446 | * @param[in] char_handle Handle of the characteristic where the descriptor is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. |
sahilmgandhi | 18:6a4db94011d3 | 447 | * @param[in] p_attr Pointer to the attribute structure. |
sahilmgandhi | 18:6a4db94011d3 | 448 | * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored. |
sahilmgandhi | 18:6a4db94011d3 | 449 | * |
sahilmgandhi | 18:6a4db94011d3 | 450 | * @retval ::NRF_SUCCESS Successfully added a descriptor. |
sahilmgandhi | 18:6a4db94011d3 | 451 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 452 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints. |
sahilmgandhi | 18:6a4db94011d3 | 453 | * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required. |
sahilmgandhi | 18:6a4db94011d3 | 454 | * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. |
sahilmgandhi | 18:6a4db94011d3 | 455 | * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. |
sahilmgandhi | 18:6a4db94011d3 | 456 | * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. |
sahilmgandhi | 18:6a4db94011d3 | 457 | */ |
sahilmgandhi | 18:6a4db94011d3 | 458 | SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const *p_attr, uint16_t *p_handle)); |
sahilmgandhi | 18:6a4db94011d3 | 459 | |
sahilmgandhi | 18:6a4db94011d3 | 460 | /**@brief Set the value of a given attribute. |
sahilmgandhi | 18:6a4db94011d3 | 461 | * |
sahilmgandhi | 18:6a4db94011d3 | 462 | * @note Values other than system attributes can be set at any time, regardless of wheter any active connections exist. |
sahilmgandhi | 18:6a4db94011d3 | 463 | * |
sahilmgandhi | 18:6a4db94011d3 | 464 | * @mscs |
sahilmgandhi | 18:6a4db94011d3 | 465 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 466 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 467 | * @endmscs |
sahilmgandhi | 18:6a4db94011d3 | 468 | * |
sahilmgandhi | 18:6a4db94011d3 | 469 | * @param[in] conn_handle Connection handle. If the value does not belong to a system attribute then @ref BLE_CONN_HANDLE_INVALID can be used. |
sahilmgandhi | 18:6a4db94011d3 | 470 | * @param[in] handle Attribute handle. |
sahilmgandhi | 18:6a4db94011d3 | 471 | * @param[in,out] p_value Attribute value information. |
sahilmgandhi | 18:6a4db94011d3 | 472 | * |
sahilmgandhi | 18:6a4db94011d3 | 473 | * @retval ::NRF_SUCCESS Successfully set the value of the attribute. |
sahilmgandhi | 18:6a4db94011d3 | 474 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 475 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. |
sahilmgandhi | 18:6a4db94011d3 | 476 | * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. |
sahilmgandhi | 18:6a4db94011d3 | 477 | * @retval ::NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application. |
sahilmgandhi | 18:6a4db94011d3 | 478 | * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. |
sahilmgandhi | 18:6a4db94011d3 | 479 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. |
sahilmgandhi | 18:6a4db94011d3 | 480 | * @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE @ref BLE_CONN_HANDLE_INVALID supplied on a system attribute. |
sahilmgandhi | 18:6a4db94011d3 | 481 | */ |
sahilmgandhi | 18:6a4db94011d3 | 482 | SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value)); |
sahilmgandhi | 18:6a4db94011d3 | 483 | |
sahilmgandhi | 18:6a4db94011d3 | 484 | /**@brief Get the value of a given attribute. |
sahilmgandhi | 18:6a4db94011d3 | 485 | * |
sahilmgandhi | 18:6a4db94011d3 | 486 | * @note If the attribute value is longer than the size of the supplied buffer, |
sahilmgandhi | 18:6a4db94011d3 | 487 | * p_len will return the total attribute value length (excluding offset), |
sahilmgandhi | 18:6a4db94011d3 | 488 | * and not the number of bytes actually returned in p_data. |
sahilmgandhi | 18:6a4db94011d3 | 489 | * The application may use this information to allocate a suitable buffer size. |
sahilmgandhi | 18:6a4db94011d3 | 490 | * |
sahilmgandhi | 18:6a4db94011d3 | 491 | * @note When retrieving system attribute values with this function, the connection handle |
sahilmgandhi | 18:6a4db94011d3 | 492 | * may refer to an already disconnected connection. Refer to the documentation of |
sahilmgandhi | 18:6a4db94011d3 | 493 | * @ref sd_ble_gatts_sys_attr_get for further information. |
sahilmgandhi | 18:6a4db94011d3 | 494 | * |
sahilmgandhi | 18:6a4db94011d3 | 495 | * @param[in] conn_handle Connection handle. If the value does not belong to a system attribute then @ref BLE_CONN_HANDLE_INVALID can be used. |
sahilmgandhi | 18:6a4db94011d3 | 496 | * @param[in] handle Attribute handle. |
sahilmgandhi | 18:6a4db94011d3 | 497 | * @param[in,out] p_value Attribute value information. |
sahilmgandhi | 18:6a4db94011d3 | 498 | * |
sahilmgandhi | 18:6a4db94011d3 | 499 | * @retval ::NRF_SUCCESS Successfully retrieved the value of the attribute. |
sahilmgandhi | 18:6a4db94011d3 | 500 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 501 | * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. |
sahilmgandhi | 18:6a4db94011d3 | 502 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid attribute offset supplied. |
sahilmgandhi | 18:6a4db94011d3 | 503 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. |
sahilmgandhi | 18:6a4db94011d3 | 504 | * @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE @ref BLE_CONN_HANDLE_INVALID supplied on a system attribute. |
sahilmgandhi | 18:6a4db94011d3 | 505 | */ |
sahilmgandhi | 18:6a4db94011d3 | 506 | SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value)); |
sahilmgandhi | 18:6a4db94011d3 | 507 | |
sahilmgandhi | 18:6a4db94011d3 | 508 | /**@brief Notify or Indicate an attribute value. |
sahilmgandhi | 18:6a4db94011d3 | 509 | * |
sahilmgandhi | 18:6a4db94011d3 | 510 | * @details This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation |
sahilmgandhi | 18:6a4db94011d3 | 511 | * (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that |
sahilmgandhi | 18:6a4db94011d3 | 512 | * the application can atomically perform a value update and a server initiated transaction with a single API call. |
sahilmgandhi | 18:6a4db94011d3 | 513 | * If the application chooses to indicate an attribute value, a @ref BLE_GATTS_EVT_HVC event will be issued as soon as the confirmation arrives from |
sahilmgandhi | 18:6a4db94011d3 | 514 | * the peer. |
sahilmgandhi | 18:6a4db94011d3 | 515 | * |
sahilmgandhi | 18:6a4db94011d3 | 516 | * @note The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution. |
sahilmgandhi | 18:6a4db94011d3 | 517 | * When receiveing the error codes @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and |
sahilmgandhi | 18:6a4db94011d3 | 518 | * @ref BLE_ERROR_NO_TX_PACKETS the Attribute Table has been updated. |
sahilmgandhi | 18:6a4db94011d3 | 519 | * The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len). |
sahilmgandhi | 18:6a4db94011d3 | 520 | * |
sahilmgandhi | 18:6a4db94011d3 | 521 | * @note It is important to note that a notification will <b>consume an application buffer</b>, and will therefore |
sahilmgandhi | 18:6a4db94011d3 | 522 | * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. An indication on the other hand will use the |
sahilmgandhi | 18:6a4db94011d3 | 523 | * standard server internal buffer and thus will only generate a @ref BLE_GATTS_EVT_HVC event as soon as the confirmation |
sahilmgandhi | 18:6a4db94011d3 | 524 | * has been received from the peer. Please see the documentation of @ref sd_ble_tx_packet_count_get for more details. |
sahilmgandhi | 18:6a4db94011d3 | 525 | * |
sahilmgandhi | 18:6a4db94011d3 | 526 | * @events |
sahilmgandhi | 18:6a4db94011d3 | 527 | * @event{@ref BLE_EVT_TX_COMPLETE, Transmission complete.} |
sahilmgandhi | 18:6a4db94011d3 | 528 | * @event{@ref BLE_GATTS_EVT_HVC, Confirmation received from peer.} |
sahilmgandhi | 18:6a4db94011d3 | 529 | * @endevents |
sahilmgandhi | 18:6a4db94011d3 | 530 | * |
sahilmgandhi | 18:6a4db94011d3 | 531 | * @mscs |
sahilmgandhi | 18:6a4db94011d3 | 532 | * @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 533 | * @mmsc{@ref BLE_GATTS_HVN_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 534 | * @mmsc{@ref BLE_GATTS_HVI_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 535 | * @mmsc{@ref BLE_GATTS_HVX_DISABLED_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 536 | * @mmsc{@ref BLE_COMMON_APP_BUFF_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 537 | * @endmscs |
sahilmgandhi | 18:6a4db94011d3 | 538 | * |
sahilmgandhi | 18:6a4db94011d3 | 539 | * @param[in] conn_handle Connection handle. |
sahilmgandhi | 18:6a4db94011d3 | 540 | * @param[in] p_hvx_params Pointer to an HVx parameters structure. If the p_data member contains a non-NULL pointer the attribute value will be updated with |
sahilmgandhi | 18:6a4db94011d3 | 541 | * the contents pointed by it before sending the notification or indication. |
sahilmgandhi | 18:6a4db94011d3 | 542 | * |
sahilmgandhi | 18:6a4db94011d3 | 543 | * @retval ::NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value. |
sahilmgandhi | 18:6a4db94011d3 | 544 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
sahilmgandhi | 18:6a4db94011d3 | 545 | * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or notifications and/or indications not enabled in the CCCD. |
sahilmgandhi | 18:6a4db94011d3 | 546 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 547 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. |
sahilmgandhi | 18:6a4db94011d3 | 548 | * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate. |
sahilmgandhi | 18:6a4db94011d3 | 549 | * @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated. |
sahilmgandhi | 18:6a4db94011d3 | 550 | * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. |
sahilmgandhi | 18:6a4db94011d3 | 551 | * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. |
sahilmgandhi | 18:6a4db94011d3 | 552 | * @retval ::NRF_ERROR_BUSY Procedure already in progress. |
sahilmgandhi | 18:6a4db94011d3 | 553 | * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. |
sahilmgandhi | 18:6a4db94011d3 | 554 | * @retval ::BLE_ERROR_NO_TX_PACKETS No available application packets for this connection, applies only to notifications. |
sahilmgandhi | 18:6a4db94011d3 | 555 | */ |
sahilmgandhi | 18:6a4db94011d3 | 556 | SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params)); |
sahilmgandhi | 18:6a4db94011d3 | 557 | |
sahilmgandhi | 18:6a4db94011d3 | 558 | /**@brief Indicate the Service Changed attribute value. |
sahilmgandhi | 18:6a4db94011d3 | 559 | * |
sahilmgandhi | 18:6a4db94011d3 | 560 | * @details This call will send a Handle Value Indication to one or more peers connected to inform them that the Attribute |
sahilmgandhi | 18:6a4db94011d3 | 561 | * Table layout has changed. As soon as the peer has confirmed the indication, a @ref BLE_GATTS_EVT_SC_CONFIRM event will |
sahilmgandhi | 18:6a4db94011d3 | 562 | * be issued. |
sahilmgandhi | 18:6a4db94011d3 | 563 | * |
sahilmgandhi | 18:6a4db94011d3 | 564 | * @note Some of the restrictions and limitations that apply to @ref sd_ble_gatts_hvx also apply here. |
sahilmgandhi | 18:6a4db94011d3 | 565 | * |
sahilmgandhi | 18:6a4db94011d3 | 566 | * @events |
sahilmgandhi | 18:6a4db94011d3 | 567 | * @event{@ref BLE_GATTS_EVT_SC_CONFIRM, Confirmation of attribute table change received from peer.} |
sahilmgandhi | 18:6a4db94011d3 | 568 | * @endevents |
sahilmgandhi | 18:6a4db94011d3 | 569 | * |
sahilmgandhi | 18:6a4db94011d3 | 570 | * @mscs |
sahilmgandhi | 18:6a4db94011d3 | 571 | * @mmsc{@ref BLE_GATTS_SC_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 572 | * @endmscs |
sahilmgandhi | 18:6a4db94011d3 | 573 | * |
sahilmgandhi | 18:6a4db94011d3 | 574 | * @param[in] conn_handle Connection handle. |
sahilmgandhi | 18:6a4db94011d3 | 575 | * @param[in] start_handle Start of affected attribute handle range. |
sahilmgandhi | 18:6a4db94011d3 | 576 | * @param[in] end_handle End of affected attribute handle range. |
sahilmgandhi | 18:6a4db94011d3 | 577 | * |
sahilmgandhi | 18:6a4db94011d3 | 578 | * @retval ::NRF_SUCCESS Successfully queued the Service Changed indication for transmission. |
sahilmgandhi | 18:6a4db94011d3 | 579 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
sahilmgandhi | 18:6a4db94011d3 | 580 | * @retval ::NRF_ERROR_NOT_SUPPORTED Service Changed not enabled at initialization. See @ref sd_ble_enable and @ref ble_gatts_enable_params_t. |
sahilmgandhi | 18:6a4db94011d3 | 581 | * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or notifications and/or indications not enabled in the CCCD. |
sahilmgandhi | 18:6a4db94011d3 | 582 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. |
sahilmgandhi | 18:6a4db94011d3 | 583 | * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application. |
sahilmgandhi | 18:6a4db94011d3 | 584 | * @retval ::NRF_ERROR_BUSY Procedure already in progress. |
sahilmgandhi | 18:6a4db94011d3 | 585 | * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. |
sahilmgandhi | 18:6a4db94011d3 | 586 | */ |
sahilmgandhi | 18:6a4db94011d3 | 587 | SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle)); |
sahilmgandhi | 18:6a4db94011d3 | 588 | |
sahilmgandhi | 18:6a4db94011d3 | 589 | /**@brief Respond to a Read/Write authorization request. |
sahilmgandhi | 18:6a4db94011d3 | 590 | * |
sahilmgandhi | 18:6a4db94011d3 | 591 | * @note This call should only be used as a response to a @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application. |
sahilmgandhi | 18:6a4db94011d3 | 592 | * |
sahilmgandhi | 18:6a4db94011d3 | 593 | * @mscs |
sahilmgandhi | 18:6a4db94011d3 | 594 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 595 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 596 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 597 | * @mmsc{@ref BLE_GATTS_READ_REQ_AUTH_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 598 | * @mmsc{@ref BLE_GATTS_WRITE_REQ_AUTH_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 599 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 600 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_PEER_CANCEL_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 601 | * @endmscs |
sahilmgandhi | 18:6a4db94011d3 | 602 | * |
sahilmgandhi | 18:6a4db94011d3 | 603 | * @param[in] conn_handle Connection handle. |
sahilmgandhi | 18:6a4db94011d3 | 604 | * @param[in] p_rw_authorize_reply_params Pointer to a structure with the attribute provided by the application. |
sahilmgandhi | 18:6a4db94011d3 | 605 | * |
sahilmgandhi | 18:6a4db94011d3 | 606 | * @retval ::NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, Attribute Table updated. |
sahilmgandhi | 18:6a4db94011d3 | 607 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
sahilmgandhi | 18:6a4db94011d3 | 608 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 609 | * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no authorization request pending. |
sahilmgandhi | 18:6a4db94011d3 | 610 | * @retval ::NRF_ERROR_INVALID_PARAM Authorization op invalid, |
sahilmgandhi | 18:6a4db94011d3 | 611 | * handle supplied does not match requested handle, |
sahilmgandhi | 18:6a4db94011d3 | 612 | * or invalid data to be written provided by the application. |
sahilmgandhi | 18:6a4db94011d3 | 613 | * @retval ::NRF_ERROR_BUSY The stack is busy. Retry at later time. |
sahilmgandhi | 18:6a4db94011d3 | 614 | */ |
sahilmgandhi | 18:6a4db94011d3 | 615 | SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params)); |
sahilmgandhi | 18:6a4db94011d3 | 616 | |
sahilmgandhi | 18:6a4db94011d3 | 617 | |
sahilmgandhi | 18:6a4db94011d3 | 618 | /**@brief Update persistent system attribute information. |
sahilmgandhi | 18:6a4db94011d3 | 619 | * |
sahilmgandhi | 18:6a4db94011d3 | 620 | * @details Supply information about persistent system attributes to the stack, |
sahilmgandhi | 18:6a4db94011d3 | 621 | * previously obtained using @ref sd_ble_gatts_sys_attr_get. |
sahilmgandhi | 18:6a4db94011d3 | 622 | * This call is only allowed for active connections, and is usually |
sahilmgandhi | 18:6a4db94011d3 | 623 | * made immediately after a connection is established with an known bonded device, |
sahilmgandhi | 18:6a4db94011d3 | 624 | * often as a response to a @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. |
sahilmgandhi | 18:6a4db94011d3 | 625 | * |
sahilmgandhi | 18:6a4db94011d3 | 626 | * p_sysattrs may point directly to the application's stored copy of the system attributes |
sahilmgandhi | 18:6a4db94011d3 | 627 | * obtained using @ref sd_ble_gatts_sys_attr_get. |
sahilmgandhi | 18:6a4db94011d3 | 628 | * If the pointer is NULL, the system attribute info is initialized, assuming that |
sahilmgandhi | 18:6a4db94011d3 | 629 | * the application does not have any previously saved system attribute data for this device. |
sahilmgandhi | 18:6a4db94011d3 | 630 | * |
sahilmgandhi | 18:6a4db94011d3 | 631 | * @note The state of persistent system attributes is reset upon connection establishment and then remembered for its duration. |
sahilmgandhi | 18:6a4db94011d3 | 632 | * |
sahilmgandhi | 18:6a4db94011d3 | 633 | * @note If this call returns with an error code different from @ref NRF_SUCCESS, the storage of persistent system attributes may have been completed only partially. |
sahilmgandhi | 18:6a4db94011d3 | 634 | * This means that the state of the attribute table is undefined, and the application should either provide a new set of attributes using this same call or |
sahilmgandhi | 18:6a4db94011d3 | 635 | * reset the SoftDevice to return to a known state. |
sahilmgandhi | 18:6a4db94011d3 | 636 | * |
sahilmgandhi | 18:6a4db94011d3 | 637 | * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be modified. |
sahilmgandhi | 18:6a4db94011d3 | 638 | * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be modified. |
sahilmgandhi | 18:6a4db94011d3 | 639 | * |
sahilmgandhi | 18:6a4db94011d3 | 640 | * @mscs |
sahilmgandhi | 18:6a4db94011d3 | 641 | * @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 642 | * @mmsc{@ref BLE_GATTS_SYS_ATTRS_UNK_PEER_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 643 | * @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 644 | * @endmscs |
sahilmgandhi | 18:6a4db94011d3 | 645 | * |
sahilmgandhi | 18:6a4db94011d3 | 646 | * @param[in] conn_handle Connection handle. |
sahilmgandhi | 18:6a4db94011d3 | 647 | * @param[in] p_sys_attr_data Pointer to a saved copy of system attributes supplied to the stack, or NULL. |
sahilmgandhi | 18:6a4db94011d3 | 648 | * @param[in] len Size of data pointed by p_sys_attr_data, in octets. |
sahilmgandhi | 18:6a4db94011d3 | 649 | * @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS |
sahilmgandhi | 18:6a4db94011d3 | 650 | * |
sahilmgandhi | 18:6a4db94011d3 | 651 | * @retval ::NRF_SUCCESS Successfully set the system attribute information. |
sahilmgandhi | 18:6a4db94011d3 | 652 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
sahilmgandhi | 18:6a4db94011d3 | 653 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 654 | * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. |
sahilmgandhi | 18:6a4db94011d3 | 655 | * @retval ::NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with @ref sd_ble_gatts_sys_attr_get. |
sahilmgandhi | 18:6a4db94011d3 | 656 | * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. |
sahilmgandhi | 18:6a4db94011d3 | 657 | * @retval ::NRF_ERROR_BUSY The stack is busy. Retry at later time. |
sahilmgandhi | 18:6a4db94011d3 | 658 | */ |
sahilmgandhi | 18:6a4db94011d3 | 659 | SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const *p_sys_attr_data, uint16_t len, uint32_t flags)); |
sahilmgandhi | 18:6a4db94011d3 | 660 | |
sahilmgandhi | 18:6a4db94011d3 | 661 | |
sahilmgandhi | 18:6a4db94011d3 | 662 | /**@brief Retrieve persistent system attribute information from the stack. |
sahilmgandhi | 18:6a4db94011d3 | 663 | * |
sahilmgandhi | 18:6a4db94011d3 | 664 | * @details This call is used to retrieve information about values to be stored perisistently by the application |
sahilmgandhi | 18:6a4db94011d3 | 665 | * during the lifetime of a connection or after it has been terminated. When a new connection is established with the same bonded device, |
sahilmgandhi | 18:6a4db94011d3 | 666 | * the system attribute information retrieved with this function should be restored using using @ref sd_ble_gatts_sys_attr_set. |
sahilmgandhi | 18:6a4db94011d3 | 667 | * If retrieved after disconnection, the data should be read before a new connection established. The connection handle for |
sahilmgandhi | 18:6a4db94011d3 | 668 | * the previous, now disconnected, connection will remain valid until a new one is created to allow this API call to refer to it. |
sahilmgandhi | 18:6a4db94011d3 | 669 | * Connection handles belonging to active connections can be used as well, but care should be taken since the system attributes |
sahilmgandhi | 18:6a4db94011d3 | 670 | * may be written to at any time by the peer during a connection's lifetime. |
sahilmgandhi | 18:6a4db94011d3 | 671 | * |
sahilmgandhi | 18:6a4db94011d3 | 672 | * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be returned. |
sahilmgandhi | 18:6a4db94011d3 | 673 | * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be returned. |
sahilmgandhi | 18:6a4db94011d3 | 674 | * |
sahilmgandhi | 18:6a4db94011d3 | 675 | * @mscs |
sahilmgandhi | 18:6a4db94011d3 | 676 | * @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC} |
sahilmgandhi | 18:6a4db94011d3 | 677 | * @endmscs |
sahilmgandhi | 18:6a4db94011d3 | 678 | * |
sahilmgandhi | 18:6a4db94011d3 | 679 | * @param[in] conn_handle Connection handle of the recently terminated connection. |
sahilmgandhi | 18:6a4db94011d3 | 680 | * @param[out] p_sys_attr_data Pointer to a buffer where updated information about system attributes will be filled in. The format of the data is described |
sahilmgandhi | 18:6a4db94011d3 | 681 | * in @ref BLE_GATTS_SYS_ATTRS_FORMAT. NULL can be provided to obtain the length of the data. |
sahilmgandhi | 18:6a4db94011d3 | 682 | * @param[in,out] p_len Size of application buffer if p_sys_attr_data is not NULL. Unconditially updated to actual length of system attribute data. |
sahilmgandhi | 18:6a4db94011d3 | 683 | * @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS |
sahilmgandhi | 18:6a4db94011d3 | 684 | * |
sahilmgandhi | 18:6a4db94011d3 | 685 | * @retval ::NRF_SUCCESS Successfully retrieved the system attribute information. |
sahilmgandhi | 18:6a4db94011d3 | 686 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
sahilmgandhi | 18:6a4db94011d3 | 687 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 688 | * @retval ::NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer. |
sahilmgandhi | 18:6a4db94011d3 | 689 | * @retval ::NRF_ERROR_NOT_FOUND No system attributes found. |
sahilmgandhi | 18:6a4db94011d3 | 690 | */ |
sahilmgandhi | 18:6a4db94011d3 | 691 | SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t *p_sys_attr_data, uint16_t *p_len, uint32_t flags)); |
sahilmgandhi | 18:6a4db94011d3 | 692 | |
sahilmgandhi | 18:6a4db94011d3 | 693 | |
sahilmgandhi | 18:6a4db94011d3 | 694 | /**@brief Retrieve the first valid user attribute handle. |
sahilmgandhi | 18:6a4db94011d3 | 695 | * |
sahilmgandhi | 18:6a4db94011d3 | 696 | * @param[out] p_handle Pointer to an integer where the handle will be stored. |
sahilmgandhi | 18:6a4db94011d3 | 697 | * |
sahilmgandhi | 18:6a4db94011d3 | 698 | * @retval ::NRF_SUCCESS Successfully retrieved the handle. |
sahilmgandhi | 18:6a4db94011d3 | 699 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 700 | */ |
sahilmgandhi | 18:6a4db94011d3 | 701 | SVCALL(SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, uint32_t, sd_ble_gatts_initial_user_handle_get(uint16_t *p_handle)); |
sahilmgandhi | 18:6a4db94011d3 | 702 | |
sahilmgandhi | 18:6a4db94011d3 | 703 | /**@brief Retrieve the attribute UUID and/or metadata. |
sahilmgandhi | 18:6a4db94011d3 | 704 | * |
sahilmgandhi | 18:6a4db94011d3 | 705 | * @param[in] handle Attribute handle |
sahilmgandhi | 18:6a4db94011d3 | 706 | * @param[out] p_uuid UUID of the attribute. Use NULL to omit this field. |
sahilmgandhi | 18:6a4db94011d3 | 707 | * @param[out] p_md Metadata of the attribute. Use NULL to omit this field. |
sahilmgandhi | 18:6a4db94011d3 | 708 | * |
sahilmgandhi | 18:6a4db94011d3 | 709 | * @retval ::NRF_SUCCESS Successfully retrieved the attribute metadata, |
sahilmgandhi | 18:6a4db94011d3 | 710 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
sahilmgandhi | 18:6a4db94011d3 | 711 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied. Returned when both @c p_uuid and @c p_md are NULL. |
sahilmgandhi | 18:6a4db94011d3 | 712 | * @retval ::NRF_ERROR_NOT_FOUND Attribute was not found. |
sahilmgandhi | 18:6a4db94011d3 | 713 | */ |
sahilmgandhi | 18:6a4db94011d3 | 714 | SVCALL(SD_BLE_GATTS_ATTR_GET, uint32_t, sd_ble_gatts_attr_get(uint16_t handle, ble_uuid_t * p_uuid, ble_gatts_attr_md_t * p_md)); |
sahilmgandhi | 18:6a4db94011d3 | 715 | |
sahilmgandhi | 18:6a4db94011d3 | 716 | /** @} */ |
sahilmgandhi | 18:6a4db94011d3 | 717 | |
sahilmgandhi | 18:6a4db94011d3 | 718 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 719 | } |
sahilmgandhi | 18:6a4db94011d3 | 720 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 721 | #endif // NRF_BLE_GATTS_H__ |
sahilmgandhi | 18:6a4db94011d3 | 722 | |
sahilmgandhi | 18:6a4db94011d3 | 723 | /** |
sahilmgandhi | 18:6a4db94011d3 | 724 | @} |
sahilmgandhi | 18:6a4db94011d3 | 725 | */ |