AndroidのBLEラジコンプロポアプリ「BLEPropo」と接続し、RCサーボとDCモータを制御するプログラムです。 BLE Nanoで動作を確認しています。 BLEPropo → https://github.com/lipoyang/BLEPropo
BLEを使ったAndroid用ラジコンプロポアプリ「BLEPropo」に対応するBLE Nano用ファームウェアです。
BLEPropoは、GitHubにて公開中。
https://github.com/lipoyang/BLEPropo
ラジコンは、mbed HRM1017とRCサーボやDCモータを組み合わせて作ります。
回路図
/media/uploads/lipoyang/ministeer3.pdf
nRF51822/nordic/nrf-sdk/s110/ble_gattc.h@5:7f89fca19a9e, 2015-03-14 (annotated)
- Committer:
- lipoyang
- Date:
- Sat Mar 14 12:02:48 2015 +0000
- Revision:
- 5:7f89fca19a9e
-convert nRF51822 library to a folder
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lipoyang | 5:7f89fca19a9e | 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. |
lipoyang | 5:7f89fca19a9e | 2 | * |
lipoyang | 5:7f89fca19a9e | 3 | * The information contained herein is confidential property of Nordic Semiconductor. The use, |
lipoyang | 5:7f89fca19a9e | 4 | * copying, transfer or disclosure of such information is prohibited except by express written |
lipoyang | 5:7f89fca19a9e | 5 | * agreement with Nordic Semiconductor. |
lipoyang | 5:7f89fca19a9e | 6 | * |
lipoyang | 5:7f89fca19a9e | 7 | */ |
lipoyang | 5:7f89fca19a9e | 8 | /** |
lipoyang | 5:7f89fca19a9e | 9 | @addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client |
lipoyang | 5:7f89fca19a9e | 10 | @{ |
lipoyang | 5:7f89fca19a9e | 11 | @brief Definitions and prototypes for the GATT Client interface. |
lipoyang | 5:7f89fca19a9e | 12 | */ |
lipoyang | 5:7f89fca19a9e | 13 | |
lipoyang | 5:7f89fca19a9e | 14 | #ifndef BLE_GATTC_H__ |
lipoyang | 5:7f89fca19a9e | 15 | #define BLE_GATTC_H__ |
lipoyang | 5:7f89fca19a9e | 16 | |
lipoyang | 5:7f89fca19a9e | 17 | #include "ble_gatt.h" |
lipoyang | 5:7f89fca19a9e | 18 | #include "ble_types.h" |
lipoyang | 5:7f89fca19a9e | 19 | #include "ble_ranges.h" |
lipoyang | 5:7f89fca19a9e | 20 | #include "nrf_svc.h" |
lipoyang | 5:7f89fca19a9e | 21 | |
lipoyang | 5:7f89fca19a9e | 22 | /** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations |
lipoyang | 5:7f89fca19a9e | 23 | * @{ */ |
lipoyang | 5:7f89fca19a9e | 24 | |
lipoyang | 5:7f89fca19a9e | 25 | /**@brief GATTC API SVC numbers. */ |
lipoyang | 5:7f89fca19a9e | 26 | enum BLE_GATTC_SVCS |
lipoyang | 5:7f89fca19a9e | 27 | { |
lipoyang | 5:7f89fca19a9e | 28 | SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER = BLE_GATTC_SVC_BASE, /**< Primary Service Discovery. */ |
lipoyang | 5:7f89fca19a9e | 29 | SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, /**< Relationship Discovery. */ |
lipoyang | 5:7f89fca19a9e | 30 | SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, /**< Characteristic Discovery. */ |
lipoyang | 5:7f89fca19a9e | 31 | SD_BLE_GATTC_DESCRIPTORS_DISCOVER, /**< Characteristic Descriptor Discovery. */ |
lipoyang | 5:7f89fca19a9e | 32 | SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, /**< Read Characteristic Value by UUID. */ |
lipoyang | 5:7f89fca19a9e | 33 | SD_BLE_GATTC_READ, /**< Generic read. */ |
lipoyang | 5:7f89fca19a9e | 34 | SD_BLE_GATTC_CHAR_VALUES_READ, /**< Read multiple Characteristic Values. */ |
lipoyang | 5:7f89fca19a9e | 35 | SD_BLE_GATTC_WRITE, /**< Generic write. */ |
lipoyang | 5:7f89fca19a9e | 36 | SD_BLE_GATTC_HV_CONFIRM /**< Handle Value Confirmation. */ |
lipoyang | 5:7f89fca19a9e | 37 | }; |
lipoyang | 5:7f89fca19a9e | 38 | |
lipoyang | 5:7f89fca19a9e | 39 | /** @} */ |
lipoyang | 5:7f89fca19a9e | 40 | |
lipoyang | 5:7f89fca19a9e | 41 | /** @addtogroup BLE_GATTC_DEFINES Defines |
lipoyang | 5:7f89fca19a9e | 42 | * @{ */ |
lipoyang | 5:7f89fca19a9e | 43 | |
lipoyang | 5:7f89fca19a9e | 44 | /** @defgroup BLE_ERRORS_GATTC SVC return values specific to GATTC |
lipoyang | 5:7f89fca19a9e | 45 | * @{ */ |
lipoyang | 5:7f89fca19a9e | 46 | #define BLE_ERROR_GATTC_PROC_NOT_PERMITTED (NRF_GATTC_ERR_BASE + 0x000) |
lipoyang | 5:7f89fca19a9e | 47 | /** @} */ |
lipoyang | 5:7f89fca19a9e | 48 | |
lipoyang | 5:7f89fca19a9e | 49 | /**@brief Last Attribute Handle. */ |
lipoyang | 5:7f89fca19a9e | 50 | #define BLE_GATTC_HANDLE_END 0xFFFF |
lipoyang | 5:7f89fca19a9e | 51 | |
lipoyang | 5:7f89fca19a9e | 52 | /** @} */ |
lipoyang | 5:7f89fca19a9e | 53 | |
lipoyang | 5:7f89fca19a9e | 54 | /** @addtogroup BLE_GATTC_STRUCTURES Structures |
lipoyang | 5:7f89fca19a9e | 55 | * @{ */ |
lipoyang | 5:7f89fca19a9e | 56 | |
lipoyang | 5:7f89fca19a9e | 57 | /**@brief Operation Handle Range. */ |
lipoyang | 5:7f89fca19a9e | 58 | typedef struct |
lipoyang | 5:7f89fca19a9e | 59 | { |
lipoyang | 5:7f89fca19a9e | 60 | uint16_t start_handle; /**< Start Handle. */ |
lipoyang | 5:7f89fca19a9e | 61 | uint16_t end_handle; /**< End Handle. */ |
lipoyang | 5:7f89fca19a9e | 62 | } ble_gattc_handle_range_t; |
lipoyang | 5:7f89fca19a9e | 63 | |
lipoyang | 5:7f89fca19a9e | 64 | |
lipoyang | 5:7f89fca19a9e | 65 | /**@brief GATT service. */ |
lipoyang | 5:7f89fca19a9e | 66 | typedef struct |
lipoyang | 5:7f89fca19a9e | 67 | { |
lipoyang | 5:7f89fca19a9e | 68 | ble_uuid_t uuid; /**< Service UUID. */ |
lipoyang | 5:7f89fca19a9e | 69 | ble_gattc_handle_range_t handle_range; /**< Service Handle Range. */ |
lipoyang | 5:7f89fca19a9e | 70 | } ble_gattc_service_t; |
lipoyang | 5:7f89fca19a9e | 71 | |
lipoyang | 5:7f89fca19a9e | 72 | |
lipoyang | 5:7f89fca19a9e | 73 | /**@brief GATT include. */ |
lipoyang | 5:7f89fca19a9e | 74 | typedef struct |
lipoyang | 5:7f89fca19a9e | 75 | { |
lipoyang | 5:7f89fca19a9e | 76 | uint16_t handle; /**< Include Handle. */ |
lipoyang | 5:7f89fca19a9e | 77 | ble_gattc_service_t included_srvc; /**< Handle of the included service. */ |
lipoyang | 5:7f89fca19a9e | 78 | } ble_gattc_include_t; |
lipoyang | 5:7f89fca19a9e | 79 | |
lipoyang | 5:7f89fca19a9e | 80 | |
lipoyang | 5:7f89fca19a9e | 81 | /**@brief GATT characteristic. */ |
lipoyang | 5:7f89fca19a9e | 82 | typedef struct |
lipoyang | 5:7f89fca19a9e | 83 | { |
lipoyang | 5:7f89fca19a9e | 84 | ble_uuid_t uuid; /**< Characteristic UUID. */ |
lipoyang | 5:7f89fca19a9e | 85 | ble_gatt_char_props_t char_props; /**< Characteristic Properties. */ |
lipoyang | 5:7f89fca19a9e | 86 | uint8_t char_ext_props : 1; /**< Extended properties present. */ |
lipoyang | 5:7f89fca19a9e | 87 | uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */ |
lipoyang | 5:7f89fca19a9e | 88 | uint16_t handle_value; /**< Handle of the Characteristic Value. */ |
lipoyang | 5:7f89fca19a9e | 89 | } ble_gattc_char_t; |
lipoyang | 5:7f89fca19a9e | 90 | |
lipoyang | 5:7f89fca19a9e | 91 | |
lipoyang | 5:7f89fca19a9e | 92 | /**@brief GATT descriptor. */ |
lipoyang | 5:7f89fca19a9e | 93 | typedef struct |
lipoyang | 5:7f89fca19a9e | 94 | { |
lipoyang | 5:7f89fca19a9e | 95 | uint16_t handle; /**< Descriptor Handle. */ |
lipoyang | 5:7f89fca19a9e | 96 | ble_uuid_t uuid; /**< Descriptor UUID. */ |
lipoyang | 5:7f89fca19a9e | 97 | } ble_gattc_desc_t; |
lipoyang | 5:7f89fca19a9e | 98 | |
lipoyang | 5:7f89fca19a9e | 99 | |
lipoyang | 5:7f89fca19a9e | 100 | /**@brief Write Parameters. */ |
lipoyang | 5:7f89fca19a9e | 101 | typedef struct |
lipoyang | 5:7f89fca19a9e | 102 | { |
lipoyang | 5:7f89fca19a9e | 103 | uint8_t write_op; /**< Write Operation to be performed, see @ref BLE_GATT_WRITE_OPS. */ |
lipoyang | 5:7f89fca19a9e | 104 | uint16_t handle; /**< Handle to the attribute to be written. */ |
lipoyang | 5:7f89fca19a9e | 105 | uint16_t offset; /**< Offset in bytes. @note For WRITE_CMD and WRITE_REQ, offset must be 0. */ |
lipoyang | 5:7f89fca19a9e | 106 | uint16_t len; /**< Length of data in bytes. */ |
lipoyang | 5:7f89fca19a9e | 107 | uint8_t* p_value; /**< Pointer to the value data. */ |
lipoyang | 5:7f89fca19a9e | 108 | uint8_t flags; /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */ |
lipoyang | 5:7f89fca19a9e | 109 | } ble_gattc_write_params_t; |
lipoyang | 5:7f89fca19a9e | 110 | |
lipoyang | 5:7f89fca19a9e | 111 | |
lipoyang | 5:7f89fca19a9e | 112 | /** |
lipoyang | 5:7f89fca19a9e | 113 | * @brief GATT Client Event IDs. |
lipoyang | 5:7f89fca19a9e | 114 | */ |
lipoyang | 5:7f89fca19a9e | 115 | enum BLE_GATTC_EVTS |
lipoyang | 5:7f89fca19a9e | 116 | { |
lipoyang | 5:7f89fca19a9e | 117 | BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE, /**< Primary Service Discovery Response event. */ |
lipoyang | 5:7f89fca19a9e | 118 | BLE_GATTC_EVT_REL_DISC_RSP, /**< Relationship Discovery Response event. */ |
lipoyang | 5:7f89fca19a9e | 119 | BLE_GATTC_EVT_CHAR_DISC_RSP, /**< Characteristic Discovery Response event. */ |
lipoyang | 5:7f89fca19a9e | 120 | BLE_GATTC_EVT_DESC_DISC_RSP, /**< Descriptor Discovery Response event. */ |
lipoyang | 5:7f89fca19a9e | 121 | BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, /**< Read By UUID Response event. */ |
lipoyang | 5:7f89fca19a9e | 122 | BLE_GATTC_EVT_READ_RSP, /**< Read Response event. */ |
lipoyang | 5:7f89fca19a9e | 123 | BLE_GATTC_EVT_CHAR_VALS_READ_RSP, /**< Read multiple Response event. */ |
lipoyang | 5:7f89fca19a9e | 124 | BLE_GATTC_EVT_WRITE_RSP, /**< Write Response event. */ |
lipoyang | 5:7f89fca19a9e | 125 | BLE_GATTC_EVT_HVX, /**< Handle Value Notification or Indication event. */ |
lipoyang | 5:7f89fca19a9e | 126 | BLE_GATTC_EVT_TIMEOUT /**< Timeout event. */ |
lipoyang | 5:7f89fca19a9e | 127 | }; |
lipoyang | 5:7f89fca19a9e | 128 | |
lipoyang | 5:7f89fca19a9e | 129 | /**@brief Event structure for BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP. */ |
lipoyang | 5:7f89fca19a9e | 130 | typedef struct |
lipoyang | 5:7f89fca19a9e | 131 | { |
lipoyang | 5:7f89fca19a9e | 132 | uint16_t count; /**< Service count. */ |
lipoyang | 5:7f89fca19a9e | 133 | ble_gattc_service_t services[1]; /**< Service data, variable length. */ |
lipoyang | 5:7f89fca19a9e | 134 | } ble_gattc_evt_prim_srvc_disc_rsp_t; |
lipoyang | 5:7f89fca19a9e | 135 | |
lipoyang | 5:7f89fca19a9e | 136 | /**@brief Event structure for BLE_GATTC_EVT_REL_DISC_RSP. */ |
lipoyang | 5:7f89fca19a9e | 137 | typedef struct |
lipoyang | 5:7f89fca19a9e | 138 | { |
lipoyang | 5:7f89fca19a9e | 139 | uint16_t count; /**< Include count. */ |
lipoyang | 5:7f89fca19a9e | 140 | ble_gattc_include_t includes[1]; /**< Include data, variable length. */ |
lipoyang | 5:7f89fca19a9e | 141 | } ble_gattc_evt_rel_disc_rsp_t; |
lipoyang | 5:7f89fca19a9e | 142 | |
lipoyang | 5:7f89fca19a9e | 143 | /**@brief Event structure for BLE_GATTC_EVT_CHAR_DISC_RSP. */ |
lipoyang | 5:7f89fca19a9e | 144 | typedef struct |
lipoyang | 5:7f89fca19a9e | 145 | { |
lipoyang | 5:7f89fca19a9e | 146 | uint16_t count; /**< Characteristic count. */ |
lipoyang | 5:7f89fca19a9e | 147 | ble_gattc_char_t chars[1]; /**< Characteristic data, variable length. */ |
lipoyang | 5:7f89fca19a9e | 148 | } ble_gattc_evt_char_disc_rsp_t; |
lipoyang | 5:7f89fca19a9e | 149 | |
lipoyang | 5:7f89fca19a9e | 150 | /**@brief Event structure for BLE_GATTC_EVT_DESC_DISC_RSP. */ |
lipoyang | 5:7f89fca19a9e | 151 | typedef struct |
lipoyang | 5:7f89fca19a9e | 152 | { |
lipoyang | 5:7f89fca19a9e | 153 | uint16_t count; /**< Descriptor count. */ |
lipoyang | 5:7f89fca19a9e | 154 | ble_gattc_desc_t descs[1]; /**< Descriptor data, variable length. */ |
lipoyang | 5:7f89fca19a9e | 155 | } ble_gattc_evt_desc_disc_rsp_t; |
lipoyang | 5:7f89fca19a9e | 156 | |
lipoyang | 5:7f89fca19a9e | 157 | /**@brief GATT read by UUID handle value pair. */ |
lipoyang | 5:7f89fca19a9e | 158 | typedef struct |
lipoyang | 5:7f89fca19a9e | 159 | { |
lipoyang | 5:7f89fca19a9e | 160 | uint16_t handle; /**< Attribute Handle. */ |
lipoyang | 5:7f89fca19a9e | 161 | uint8_t *p_value; /**< Pointer to value, variable length (length available as value_len in ble_gattc_evt_read_by_uuid_rsp_t). |
lipoyang | 5:7f89fca19a9e | 162 | Please note that this pointer is absolute to the memory provided by the user when retrieving the event, |
lipoyang | 5:7f89fca19a9e | 163 | so it will effectively point to a location inside the handle_value array. */ |
lipoyang | 5:7f89fca19a9e | 164 | } ble_gattc_handle_value_t; |
lipoyang | 5:7f89fca19a9e | 165 | |
lipoyang | 5:7f89fca19a9e | 166 | /**@brief Event structure for BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */ |
lipoyang | 5:7f89fca19a9e | 167 | typedef struct |
lipoyang | 5:7f89fca19a9e | 168 | { |
lipoyang | 5:7f89fca19a9e | 169 | uint16_t count; /**< Handle-Value Pair Count. */ |
lipoyang | 5:7f89fca19a9e | 170 | uint16_t value_len; /**< Length of the value in Handle-Value(s) list. */ |
lipoyang | 5:7f89fca19a9e | 171 | ble_gattc_handle_value_t handle_value[1]; /**< Handle-Value(s) list, variable length. */ |
lipoyang | 5:7f89fca19a9e | 172 | } ble_gattc_evt_char_val_by_uuid_read_rsp_t; |
lipoyang | 5:7f89fca19a9e | 173 | |
lipoyang | 5:7f89fca19a9e | 174 | /**@brief Event structure for BLE_GATTC_EVT_READ_RSP. */ |
lipoyang | 5:7f89fca19a9e | 175 | typedef struct |
lipoyang | 5:7f89fca19a9e | 176 | { |
lipoyang | 5:7f89fca19a9e | 177 | uint16_t handle; /**< Attribute Handle. */ |
lipoyang | 5:7f89fca19a9e | 178 | uint16_t offset; /**< Offset of the attribute data. */ |
lipoyang | 5:7f89fca19a9e | 179 | uint16_t len; /**< Attribute data length. */ |
lipoyang | 5:7f89fca19a9e | 180 | uint8_t data[1]; /**< Attribute data, variable length. */ |
lipoyang | 5:7f89fca19a9e | 181 | } ble_gattc_evt_read_rsp_t; |
lipoyang | 5:7f89fca19a9e | 182 | |
lipoyang | 5:7f89fca19a9e | 183 | /**@brief Event structure for BLE_GATTC_EVT_CHAR_VALS_READ_RSP. */ |
lipoyang | 5:7f89fca19a9e | 184 | typedef struct |
lipoyang | 5:7f89fca19a9e | 185 | { |
lipoyang | 5:7f89fca19a9e | 186 | uint16_t len; /**< Concatenated Attribute values length. */ |
lipoyang | 5:7f89fca19a9e | 187 | uint8_t values[1]; /**< Attribute values, variable length. */ |
lipoyang | 5:7f89fca19a9e | 188 | } ble_gattc_evt_char_vals_read_rsp_t; |
lipoyang | 5:7f89fca19a9e | 189 | |
lipoyang | 5:7f89fca19a9e | 190 | /**@brief Event structure for BLE_GATTC_EVT_WRITE_RSP. */ |
lipoyang | 5:7f89fca19a9e | 191 | typedef struct |
lipoyang | 5:7f89fca19a9e | 192 | { |
lipoyang | 5:7f89fca19a9e | 193 | uint16_t handle; /**< Attribute Handle. */ |
lipoyang | 5:7f89fca19a9e | 194 | uint8_t write_op; /**< Type of write operation, see @ref BLE_GATT_WRITE_OPS. */ |
lipoyang | 5:7f89fca19a9e | 195 | uint16_t offset; /**< Data Offset. */ |
lipoyang | 5:7f89fca19a9e | 196 | uint16_t len; /**< Data length. */ |
lipoyang | 5:7f89fca19a9e | 197 | uint8_t data[1]; /**< Data, variable length. */ |
lipoyang | 5:7f89fca19a9e | 198 | } ble_gattc_evt_write_rsp_t; |
lipoyang | 5:7f89fca19a9e | 199 | |
lipoyang | 5:7f89fca19a9e | 200 | /**@brief Event structure for BLE_GATTC_EVT_HVX. */ |
lipoyang | 5:7f89fca19a9e | 201 | typedef struct |
lipoyang | 5:7f89fca19a9e | 202 | { |
lipoyang | 5:7f89fca19a9e | 203 | uint16_t handle; /**< Handle to which the HVx operation applies. */ |
lipoyang | 5:7f89fca19a9e | 204 | uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */ |
lipoyang | 5:7f89fca19a9e | 205 | uint16_t len; /**< Attribute data length. */ |
lipoyang | 5:7f89fca19a9e | 206 | uint8_t data[1]; /**< Attribute data, variable length. */ |
lipoyang | 5:7f89fca19a9e | 207 | } ble_gattc_evt_hvx_t; |
lipoyang | 5:7f89fca19a9e | 208 | |
lipoyang | 5:7f89fca19a9e | 209 | /**@brief Event structure for BLE_GATTC_EVT_TIMEOUT. */ |
lipoyang | 5:7f89fca19a9e | 210 | typedef struct |
lipoyang | 5:7f89fca19a9e | 211 | { |
lipoyang | 5:7f89fca19a9e | 212 | uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */ |
lipoyang | 5:7f89fca19a9e | 213 | } ble_gattc_evt_timeout_t; |
lipoyang | 5:7f89fca19a9e | 214 | |
lipoyang | 5:7f89fca19a9e | 215 | /**@brief GATTC event type. */ |
lipoyang | 5:7f89fca19a9e | 216 | typedef struct |
lipoyang | 5:7f89fca19a9e | 217 | { |
lipoyang | 5:7f89fca19a9e | 218 | uint16_t conn_handle; /**< Connection Handle on which event occured. */ |
lipoyang | 5:7f89fca19a9e | 219 | uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */ |
lipoyang | 5:7f89fca19a9e | 220 | uint16_t error_handle; /**< In case of error: The handle causing the error. In all other cases BLE_GATT_HANDLE_INVALID. */ |
lipoyang | 5:7f89fca19a9e | 221 | union |
lipoyang | 5:7f89fca19a9e | 222 | { |
lipoyang | 5:7f89fca19a9e | 223 | ble_gattc_evt_prim_srvc_disc_rsp_t prim_srvc_disc_rsp; /**< Primary Service Discovery Response Event Parameters. */ |
lipoyang | 5:7f89fca19a9e | 224 | ble_gattc_evt_rel_disc_rsp_t rel_disc_rsp; /**< Relationship Discovery Response Event Parameters. */ |
lipoyang | 5:7f89fca19a9e | 225 | ble_gattc_evt_char_disc_rsp_t char_disc_rsp; /**< Characteristic Discovery Response Event Parameters. */ |
lipoyang | 5:7f89fca19a9e | 226 | ble_gattc_evt_desc_disc_rsp_t desc_disc_rsp; /**< Descriptor Discovery Response Event Parameters. */ |
lipoyang | 5:7f89fca19a9e | 227 | ble_gattc_evt_char_val_by_uuid_read_rsp_t char_val_by_uuid_read_rsp; /**< Characteristic Value Read by UUID Response Event Parameters. */ |
lipoyang | 5:7f89fca19a9e | 228 | ble_gattc_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. */ |
lipoyang | 5:7f89fca19a9e | 229 | ble_gattc_evt_char_vals_read_rsp_t char_vals_read_rsp; /**< Characteristic Values Read Response Event Parameters. */ |
lipoyang | 5:7f89fca19a9e | 230 | ble_gattc_evt_write_rsp_t write_rsp; /**< Write Response Event Parameters. */ |
lipoyang | 5:7f89fca19a9e | 231 | ble_gattc_evt_hvx_t hvx; /**< Handle Value Notification/Indication Event Parameters. */ |
lipoyang | 5:7f89fca19a9e | 232 | ble_gattc_evt_timeout_t timeout; /**< Timeout Event Parameters. */ |
lipoyang | 5:7f89fca19a9e | 233 | } params; /**< Event Parameters. @note Only valid if @ref gatt_status == BLE_GATT_STATUS_SUCCESS. */ |
lipoyang | 5:7f89fca19a9e | 234 | } ble_gattc_evt_t; |
lipoyang | 5:7f89fca19a9e | 235 | /** @} */ |
lipoyang | 5:7f89fca19a9e | 236 | |
lipoyang | 5:7f89fca19a9e | 237 | /** @addtogroup BLE_GATTC_FUNCTIONS Functions |
lipoyang | 5:7f89fca19a9e | 238 | * @{ */ |
lipoyang | 5:7f89fca19a9e | 239 | |
lipoyang | 5:7f89fca19a9e | 240 | /**@brief Initiate or continue a GATT Primary Service Discovery procedure. |
lipoyang | 5:7f89fca19a9e | 241 | * |
lipoyang | 5:7f89fca19a9e | 242 | * @details This function initiates a Primary Service discovery, starting from the supplied handle. |
lipoyang | 5:7f89fca19a9e | 243 | * If the last service has not been reached, this must be called again with an updated start handle value to continue the search. |
lipoyang | 5:7f89fca19a9e | 244 | * |
lipoyang | 5:7f89fca19a9e | 245 | * @note If any of the discovered services have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with |
lipoyang | 5:7f89fca19a9e | 246 | * type BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event. |
lipoyang | 5:7f89fca19a9e | 247 | * |
lipoyang | 5:7f89fca19a9e | 248 | * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 249 | * @param[in] start_handle Handle to start searching from. |
lipoyang | 5:7f89fca19a9e | 250 | * @param[in] p_srvc_uuid Pointer to the service UUID to be found. If it is NULL, all primary services will be returned. |
lipoyang | 5:7f89fca19a9e | 251 | * |
lipoyang | 5:7f89fca19a9e | 252 | * @return @ref NRF_SUCCESS Successfully started or resumed the Primary Service Discovery procedure. |
lipoyang | 5:7f89fca19a9e | 253 | * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
lipoyang | 5:7f89fca19a9e | 254 | * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. |
lipoyang | 5:7f89fca19a9e | 255 | * @return @ref NRF_ERROR_BUSY Client procedure already in progress. |
lipoyang | 5:7f89fca19a9e | 256 | */ |
lipoyang | 5:7f89fca19a9e | 257 | SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const * const p_srvc_uuid)); |
lipoyang | 5:7f89fca19a9e | 258 | |
lipoyang | 5:7f89fca19a9e | 259 | |
lipoyang | 5:7f89fca19a9e | 260 | /**@brief Initiate or continue a GATT Relationship Discovery procedure. |
lipoyang | 5:7f89fca19a9e | 261 | * |
lipoyang | 5:7f89fca19a9e | 262 | * @details This function initiates the Find Included Services sub-procedure. If the last included service has not been reached, |
lipoyang | 5:7f89fca19a9e | 263 | * this must be called again with an updated handle range to continue the search. |
lipoyang | 5:7f89fca19a9e | 264 | * |
lipoyang | 5:7f89fca19a9e | 265 | * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 266 | * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 267 | * |
lipoyang | 5:7f89fca19a9e | 268 | * @return @ref NRF_SUCCESS Successfully started or resumed the Relationship Discovery procedure. |
lipoyang | 5:7f89fca19a9e | 269 | * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
lipoyang | 5:7f89fca19a9e | 270 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
lipoyang | 5:7f89fca19a9e | 271 | * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. |
lipoyang | 5:7f89fca19a9e | 272 | * @return @ref NRF_ERROR_BUSY Client procedure already in progress. |
lipoyang | 5:7f89fca19a9e | 273 | */ |
lipoyang | 5:7f89fca19a9e | 274 | SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range)); |
lipoyang | 5:7f89fca19a9e | 275 | |
lipoyang | 5:7f89fca19a9e | 276 | |
lipoyang | 5:7f89fca19a9e | 277 | /**@brief Initiate or continue a GATT Characteristic Discovery procedure. |
lipoyang | 5:7f89fca19a9e | 278 | * |
lipoyang | 5:7f89fca19a9e | 279 | * @details This function initiates a Characteristic discovery procedure. If the last Characteristic has not been reached, |
lipoyang | 5:7f89fca19a9e | 280 | * this must be called again with an updated handle range to continue the discovery. |
lipoyang | 5:7f89fca19a9e | 281 | * |
lipoyang | 5:7f89fca19a9e | 282 | * @note If any of the discovered characteristics have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with |
lipoyang | 5:7f89fca19a9e | 283 | * type BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event. |
lipoyang | 5:7f89fca19a9e | 284 | * |
lipoyang | 5:7f89fca19a9e | 285 | * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 286 | * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 287 | * |
lipoyang | 5:7f89fca19a9e | 288 | * @return @ref NRF_SUCCESS Successfully started or resumed the Characteristic Discovery procedure. |
lipoyang | 5:7f89fca19a9e | 289 | * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
lipoyang | 5:7f89fca19a9e | 290 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
lipoyang | 5:7f89fca19a9e | 291 | * @return @ref NRF_ERROR_BUSY Client procedure already in progress. |
lipoyang | 5:7f89fca19a9e | 292 | */ |
lipoyang | 5:7f89fca19a9e | 293 | SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range)); |
lipoyang | 5:7f89fca19a9e | 294 | |
lipoyang | 5:7f89fca19a9e | 295 | |
lipoyang | 5:7f89fca19a9e | 296 | /**@brief Initiate or continue a GATT Characteristic Descriptor Discovery procedure. |
lipoyang | 5:7f89fca19a9e | 297 | * |
lipoyang | 5:7f89fca19a9e | 298 | * @details This function initiates the Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached, |
lipoyang | 5:7f89fca19a9e | 299 | * this must be called again with an updated handle range to continue the discovery. |
lipoyang | 5:7f89fca19a9e | 300 | * |
lipoyang | 5:7f89fca19a9e | 301 | * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 302 | * @param[in] p_handle_range A pointer to the range of handles of the Characteristic to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 303 | * |
lipoyang | 5:7f89fca19a9e | 304 | * @return @ref NRF_SUCCESS Successfully started or resumed the Descriptor Discovery procedure. |
lipoyang | 5:7f89fca19a9e | 305 | * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
lipoyang | 5:7f89fca19a9e | 306 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
lipoyang | 5:7f89fca19a9e | 307 | * @return @ref NRF_ERROR_BUSY Client procedure already in progress. |
lipoyang | 5:7f89fca19a9e | 308 | */ |
lipoyang | 5:7f89fca19a9e | 309 | SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range)); |
lipoyang | 5:7f89fca19a9e | 310 | |
lipoyang | 5:7f89fca19a9e | 311 | |
lipoyang | 5:7f89fca19a9e | 312 | /**@brief Initiate or continue a GATT Read using Characteristic UUID procedure. |
lipoyang | 5:7f89fca19a9e | 313 | * |
lipoyang | 5:7f89fca19a9e | 314 | * @details This function initiates the Read using Characteristic UUID procedure. If the last Characteristic has not been reached, |
lipoyang | 5:7f89fca19a9e | 315 | * this must be called again with an updated handle range to continue the discovery. |
lipoyang | 5:7f89fca19a9e | 316 | * |
lipoyang | 5:7f89fca19a9e | 317 | * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 318 | * @param[in] p_uuid Pointer to a Characteristic value UUID to read. |
lipoyang | 5:7f89fca19a9e | 319 | * @param[in] p_handle_range A pointer to the range of handles to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 320 | * |
lipoyang | 5:7f89fca19a9e | 321 | * @return @ref NRF_SUCCESS Successfully started or resumed the Read using Characteristic UUID procedure. |
lipoyang | 5:7f89fca19a9e | 322 | * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
lipoyang | 5:7f89fca19a9e | 323 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
lipoyang | 5:7f89fca19a9e | 324 | * @return @ref NRF_ERROR_BUSY Client procedure already in progress. |
lipoyang | 5:7f89fca19a9e | 325 | */ |
lipoyang | 5:7f89fca19a9e | 326 | SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const * const p_uuid, ble_gattc_handle_range_t const * const p_handle_range)); |
lipoyang | 5:7f89fca19a9e | 327 | |
lipoyang | 5:7f89fca19a9e | 328 | |
lipoyang | 5:7f89fca19a9e | 329 | /**@brief Initiate or continue a GATT Read (Long) Characteristic or Descriptor procedure. |
lipoyang | 5:7f89fca19a9e | 330 | * |
lipoyang | 5:7f89fca19a9e | 331 | * @details This function initiates a GATT Read (Long) Characteristic or Descriptor procedure. If the Characteristic or Descriptor |
lipoyang | 5:7f89fca19a9e | 332 | * to be read is longer than GATT_MTU - 1, this function must be called multiple times with appropriate offset to read the |
lipoyang | 5:7f89fca19a9e | 333 | * complete value. |
lipoyang | 5:7f89fca19a9e | 334 | * |
lipoyang | 5:7f89fca19a9e | 335 | * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 336 | * @param[in] handle The handle of the attribute to be read. |
lipoyang | 5:7f89fca19a9e | 337 | * @param[in] offset Offset into the attribute value to be read. |
lipoyang | 5:7f89fca19a9e | 338 | * |
lipoyang | 5:7f89fca19a9e | 339 | * @return @ref NRF_SUCCESS Successfully started or resumed the Read (Long) procedure. |
lipoyang | 5:7f89fca19a9e | 340 | * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
lipoyang | 5:7f89fca19a9e | 341 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
lipoyang | 5:7f89fca19a9e | 342 | * @return @ref NRF_ERROR_BUSY Client procedure already in progress. |
lipoyang | 5:7f89fca19a9e | 343 | */ |
lipoyang | 5:7f89fca19a9e | 344 | SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset)); |
lipoyang | 5:7f89fca19a9e | 345 | |
lipoyang | 5:7f89fca19a9e | 346 | |
lipoyang | 5:7f89fca19a9e | 347 | /**@brief Initiate a GATT Read Multiple Characteristic Values procedure. |
lipoyang | 5:7f89fca19a9e | 348 | * |
lipoyang | 5:7f89fca19a9e | 349 | * @details This function initiates a GATT Read Multiple Characteristic Values procedure. |
lipoyang | 5:7f89fca19a9e | 350 | * |
lipoyang | 5:7f89fca19a9e | 351 | * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 352 | * @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read. |
lipoyang | 5:7f89fca19a9e | 353 | * @param[in] handle_count The number of handles in p_handles. |
lipoyang | 5:7f89fca19a9e | 354 | * |
lipoyang | 5:7f89fca19a9e | 355 | * @return @ref NRF_SUCCESS Successfully started the Read Multiple Characteristic Values procedure. |
lipoyang | 5:7f89fca19a9e | 356 | * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
lipoyang | 5:7f89fca19a9e | 357 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
lipoyang | 5:7f89fca19a9e | 358 | * @return @ref NRF_ERROR_BUSY Client procedure already in progress. |
lipoyang | 5:7f89fca19a9e | 359 | */ |
lipoyang | 5:7f89fca19a9e | 360 | SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const * const p_handles, uint16_t handle_count)); |
lipoyang | 5:7f89fca19a9e | 361 | |
lipoyang | 5:7f89fca19a9e | 362 | |
lipoyang | 5:7f89fca19a9e | 363 | /**@brief Perform a Write (Characteristic Value or Descriptor, with or without response, signed or not, long or reliable) procedure. |
lipoyang | 5:7f89fca19a9e | 364 | * |
lipoyang | 5:7f89fca19a9e | 365 | * @details This function can perform all write procedures described in GATT. |
lipoyang | 5:7f89fca19a9e | 366 | * |
lipoyang | 5:7f89fca19a9e | 367 | * @note It is important to note that a write without response will <b>consume an application buffer</b>, and will therefore |
lipoyang | 5:7f89fca19a9e | 368 | * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. A write on the other hand will use the |
lipoyang | 5:7f89fca19a9e | 369 | * standard client internal buffer and thus will only generate a @ref BLE_GATTC_EVT_WRITE_RSP event as soon as the write response |
lipoyang | 5:7f89fca19a9e | 370 | * has been received from the peer. Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details. |
lipoyang | 5:7f89fca19a9e | 371 | * |
lipoyang | 5:7f89fca19a9e | 372 | * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 373 | * @param[in] p_write_params A pointer to a write parameters structure. |
lipoyang | 5:7f89fca19a9e | 374 | * |
lipoyang | 5:7f89fca19a9e | 375 | * @return @ref NRF_SUCCESS Successfully started the Write procedure. |
lipoyang | 5:7f89fca19a9e | 376 | * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
lipoyang | 5:7f89fca19a9e | 377 | * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
lipoyang | 5:7f89fca19a9e | 378 | * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. |
lipoyang | 5:7f89fca19a9e | 379 | * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. |
lipoyang | 5:7f89fca19a9e | 380 | * @return @ref NRF_ERROR_BUSY Procedure already in progress. |
lipoyang | 5:7f89fca19a9e | 381 | * @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers left. |
lipoyang | 5:7f89fca19a9e | 382 | */ |
lipoyang | 5:7f89fca19a9e | 383 | SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const * const p_write_params)); |
lipoyang | 5:7f89fca19a9e | 384 | |
lipoyang | 5:7f89fca19a9e | 385 | |
lipoyang | 5:7f89fca19a9e | 386 | /**@brief Send a Handle Value Confirmation to the GATT Server. |
lipoyang | 5:7f89fca19a9e | 387 | * |
lipoyang | 5:7f89fca19a9e | 388 | * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. |
lipoyang | 5:7f89fca19a9e | 389 | * @param[in] handle The handle of the attribute in the indication. |
lipoyang | 5:7f89fca19a9e | 390 | * |
lipoyang | 5:7f89fca19a9e | 391 | * @return @ref NRF_SUCCESS Successfully queued the Handle Value Confirmation for transmission. |
lipoyang | 5:7f89fca19a9e | 392 | * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
lipoyang | 5:7f89fca19a9e | 393 | * @return @ref NRF_ERROR_INVALID_STATE No Indication pending to be confirmed. |
lipoyang | 5:7f89fca19a9e | 394 | * @return @ref BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle. |
lipoyang | 5:7f89fca19a9e | 395 | * @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers left. |
lipoyang | 5:7f89fca19a9e | 396 | */ |
lipoyang | 5:7f89fca19a9e | 397 | SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle)); |
lipoyang | 5:7f89fca19a9e | 398 | |
lipoyang | 5:7f89fca19a9e | 399 | /** @} */ |
lipoyang | 5:7f89fca19a9e | 400 | |
lipoyang | 5:7f89fca19a9e | 401 | #endif /* BLE_GATTC_H__ */ |
lipoyang | 5:7f89fca19a9e | 402 | |
lipoyang | 5:7f89fca19a9e | 403 | /** |
lipoyang | 5:7f89fca19a9e | 404 | @} |
lipoyang | 5:7f89fca19a9e | 405 | @} |
lipoyang | 5:7f89fca19a9e | 406 | */ |