iOSのBLEコントローラアプリ「RCBController」とmbed HRM1017を接続し、RCサーボモータを操作するテストプログラムです。

Dependencies:   BLE_API_Native_IRC Servo mbed

Fork of BLE_RCBController by Junichi Katsu

  • 古いBLEライブラリを使っているのでプラットフォームは”Nordic nRF51822”を選択してください。
  • ライブラリ類はUpdateしないでください。コンパイルエラーになります。

うまく接続できない時は、iPhone/iPadのBluetoothをOFF->ONしてキャッシュをクリアしてみてください。

/media/uploads/robo8080/img_1560.jpg

Committer:
jksoft
Date:
Thu Jul 10 14:21:52 2014 +0000
Revision:
0:8c643bfe55b7
??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:8c643bfe55b7 1 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
jksoft 0:8c643bfe55b7 2 *
jksoft 0:8c643bfe55b7 3 * The information contained herein is confidential property of Nordic Semiconductor. The use,
jksoft 0:8c643bfe55b7 4 * copying, transfer or disclosure of such information is prohibited except by express written
jksoft 0:8c643bfe55b7 5 * agreement with Nordic Semiconductor.
jksoft 0:8c643bfe55b7 6 *
jksoft 0:8c643bfe55b7 7 */
jksoft 0:8c643bfe55b7 8 /**
jksoft 0:8c643bfe55b7 9 @addtogroup BLE_GAP Generic Access Profile (GAP)
jksoft 0:8c643bfe55b7 10 @{
jksoft 0:8c643bfe55b7 11 @brief Definitions and prototypes for the GAP interface.
jksoft 0:8c643bfe55b7 12 */
jksoft 0:8c643bfe55b7 13
jksoft 0:8c643bfe55b7 14 #ifndef BLE_GAP_H__
jksoft 0:8c643bfe55b7 15 #define BLE_GAP_H__
jksoft 0:8c643bfe55b7 16
jksoft 0:8c643bfe55b7 17 #include "nordic_global.h"
jksoft 0:8c643bfe55b7 18 #include "ble_types.h"
jksoft 0:8c643bfe55b7 19 #include "ble_ranges.h"
jksoft 0:8c643bfe55b7 20 #include "nrf_svc.h"
jksoft 0:8c643bfe55b7 21
jksoft 0:8c643bfe55b7 22 /**
jksoft 0:8c643bfe55b7 23 * @brief GAP API SVC numbers.
jksoft 0:8c643bfe55b7 24 */
jksoft 0:8c643bfe55b7 25 enum BLE_GAP_SVCS
jksoft 0:8c643bfe55b7 26 {
jksoft 0:8c643bfe55b7 27 SD_BLE_GAP_ADDRESS_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */
jksoft 0:8c643bfe55b7 28 SD_BLE_GAP_ADDRESS_GET, /**< Get own Bluetooth Address. */
jksoft 0:8c643bfe55b7 29 SD_BLE_GAP_ADV_DATA_SET, /**< Set Advertisement Data. */
jksoft 0:8c643bfe55b7 30 SD_BLE_GAP_ADV_START, /**< Start Advertising. */
jksoft 0:8c643bfe55b7 31 SD_BLE_GAP_ADV_STOP, /**< Stop Advertising. */
jksoft 0:8c643bfe55b7 32 SD_BLE_GAP_CONN_PARAM_UPDATE, /**< Connection Parameter Update. */
jksoft 0:8c643bfe55b7 33 SD_BLE_GAP_DISCONNECT, /**< Disconnect. */
jksoft 0:8c643bfe55b7 34 SD_BLE_GAP_TX_POWER_SET, /**< Set TX Power. */
jksoft 0:8c643bfe55b7 35 SD_BLE_GAP_APPEARANCE_SET, /**< Set Appearance. */
jksoft 0:8c643bfe55b7 36 SD_BLE_GAP_APPEARANCE_GET, /**< Get Appearance. */
jksoft 0:8c643bfe55b7 37 SD_BLE_GAP_PPCP_SET, /**< Set PPCP. */
jksoft 0:8c643bfe55b7 38 SD_BLE_GAP_PPCP_GET, /**< Get PPCP. */
jksoft 0:8c643bfe55b7 39 SD_BLE_GAP_DEVICE_NAME_SET, /**< Set Device Name. */
jksoft 0:8c643bfe55b7 40 SD_BLE_GAP_DEVICE_NAME_GET, /**< Get Device Name. */
jksoft 0:8c643bfe55b7 41 SD_BLE_GAP_AUTHENTICATE, /**< Initiate Pairing/Bonding. */
jksoft 0:8c643bfe55b7 42 SD_BLE_GAP_SEC_PARAMS_REPLY, /**< Reply with Security Parameters. */
jksoft 0:8c643bfe55b7 43 SD_BLE_GAP_AUTH_KEY_REPLY, /**< Reply with an authentication key. */
jksoft 0:8c643bfe55b7 44 SD_BLE_GAP_SEC_INFO_REPLY, /**< Reply with Security Information. */
jksoft 0:8c643bfe55b7 45 SD_BLE_GAP_CONN_SEC_GET, /**< Obtain connection security level. */
jksoft 0:8c643bfe55b7 46 SD_BLE_GAP_RSSI_START, /**< Start reporting of changes in RSSI. */
jksoft 0:8c643bfe55b7 47 SD_BLE_GAP_RSSI_STOP, /**< Stop reporting of changes in RSSI. */
jksoft 0:8c643bfe55b7 48 };
jksoft 0:8c643bfe55b7 49
jksoft 0:8c643bfe55b7 50
jksoft 0:8c643bfe55b7 51 /** @addtogroup BLE_GAP_DEFINES Defines
jksoft 0:8c643bfe55b7 52 * @{ */
jksoft 0:8c643bfe55b7 53
jksoft 0:8c643bfe55b7 54 /** @defgroup BLE_ERRORS_GAP SVC return values specific to GAP
jksoft 0:8c643bfe55b7 55 * @{ */
jksoft 0:8c643bfe55b7 56 #define BLE_ERROR_GAP_UUID_LIST_MISMATCH (NRF_GAP_ERR_BASE + 0x000) /**< UUID list does not contain an integral number of UUIDs. */
jksoft 0:8c643bfe55b7 57 #define BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST (NRF_GAP_ERR_BASE + 0x001) /**< Use of Whitelist not permitted with discoverable advertising. */
jksoft 0:8c643bfe55b7 58 #define BLE_ERROR_GAP_INVALID_BLE_ADDR (NRF_GAP_ERR_BASE + 0x002) /**< The upper two bits of the address do not correspond to the specified address type. */
jksoft 0:8c643bfe55b7 59 /** @} */
jksoft 0:8c643bfe55b7 60
jksoft 0:8c643bfe55b7 61
jksoft 0:8c643bfe55b7 62 /** @defgroup BLE_GAP_ROLES GAP Roles
jksoft 0:8c643bfe55b7 63 * @note Not explicitly used in peripheral API, but will be relevant for central API.
jksoft 0:8c643bfe55b7 64 * @{ */
jksoft 0:8c643bfe55b7 65 #define BLE_GAP_ROLE_INVALID 0x0 /**< Invalid Role. */
jksoft 0:8c643bfe55b7 66 #define BLE_GAP_ROLE_PERIPH 0x1 /**< Peripheral Role. */
jksoft 0:8c643bfe55b7 67 #define BLE_GAP_ROLE_CENTRAL 0x2 /**< Central Role. */
jksoft 0:8c643bfe55b7 68 /** @} */
jksoft 0:8c643bfe55b7 69
jksoft 0:8c643bfe55b7 70
jksoft 0:8c643bfe55b7 71 /** @defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources
jksoft 0:8c643bfe55b7 72 * @{ */
jksoft 0:8c643bfe55b7 73 #define BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT 0x00 /**< Advertisement timeout. */
jksoft 0:8c643bfe55b7 74 #define BLE_GAP_TIMEOUT_SRC_SECURITY_REQUEST 0x01 /**< Security request timeout. */
jksoft 0:8c643bfe55b7 75 /** @} */
jksoft 0:8c643bfe55b7 76
jksoft 0:8c643bfe55b7 77
jksoft 0:8c643bfe55b7 78 /** @defgroup BLE_GAP_ADDR_TYPES GAP Address types
jksoft 0:8c643bfe55b7 79 * @{ */
jksoft 0:8c643bfe55b7 80 #define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public address. */
jksoft 0:8c643bfe55b7 81 #define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random Static address. */
jksoft 0:8c643bfe55b7 82 #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Private Resolvable address. */
jksoft 0:8c643bfe55b7 83 #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Private Non-Resolvable address. */
jksoft 0:8c643bfe55b7 84 /** @} */
jksoft 0:8c643bfe55b7 85
jksoft 0:8c643bfe55b7 86
jksoft 0:8c643bfe55b7 87 /** @brief BLE address length. */
jksoft 0:8c643bfe55b7 88 #define BLE_GAP_ADDR_LEN 6
jksoft 0:8c643bfe55b7 89
jksoft 0:8c643bfe55b7 90
jksoft 0:8c643bfe55b7 91 /** @defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format
jksoft 0:8c643bfe55b7 92 * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm
jksoft 0:8c643bfe55b7 93 * @{ */
jksoft 0:8c643bfe55b7 94 #define BLE_GAP_AD_TYPE_FLAGS 0x01 /**< Flags for discoverability. */
jksoft 0:8c643bfe55b7 95 #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE 0x02 /**< Partial list of 16 bit service UUIDs. */
jksoft 0:8c643bfe55b7 96 #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE 0x03 /**< Complete list of 16 bit service UUIDs. */
jksoft 0:8c643bfe55b7 97 #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE 0x04 /**< Partial list of 32 bit service UUIDs. */
jksoft 0:8c643bfe55b7 98 #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE 0x05 /**< Complete list of 32 bit service UUIDs. */
jksoft 0:8c643bfe55b7 99 #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE 0x06 /**< Partial list of 128 bit service UUIDs. */
jksoft 0:8c643bfe55b7 100 #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE 0x07 /**< Complete list of 128 bit service UUIDs. */
jksoft 0:8c643bfe55b7 101 #define BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME 0x08 /**< Short local device name. */
jksoft 0:8c643bfe55b7 102 #define BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME 0x09 /**< Complete local device name. */
jksoft 0:8c643bfe55b7 103 #define BLE_GAP_AD_TYPE_TX_POWER_LEVEL 0x0A /**< Transmit power level. */
jksoft 0:8c643bfe55b7 104 #define BLE_GAP_AD_TYPE_CLASS_OF_DEVICE 0x0D /**< Class of device. */
jksoft 0:8c643bfe55b7 105 #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C 0x0E /**< Simple Pairing Hash C. */
jksoft 0:8c643bfe55b7 106 #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R 0x0F /**< Simple Pairing Randomizer R. */
jksoft 0:8c643bfe55b7 107 #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_TK_VALUE 0x10 /**< Security Manager TK Value. */
jksoft 0:8c643bfe55b7 108 #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS 0x11 /**< Security Manager Out Of Band Flags. */
jksoft 0:8c643bfe55b7 109 #define BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE 0x12 /**< Slave Connection Interval Range. */
jksoft 0:8c643bfe55b7 110 #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT 0x14 /**< List of 16-bit Service Solicitation UUIDs. */
jksoft 0:8c643bfe55b7 111 #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT 0x15 /**< List of 128-bit Service Solicitation UUIDs. */
jksoft 0:8c643bfe55b7 112 #define BLE_GAP_AD_TYPE_SERVICE_DATA 0x16 /**< Service Data. */
jksoft 0:8c643bfe55b7 113 #define BLE_GAP_AD_TYPE_PUBLIC_TARGET_ADDRESS 0x17 /**< Public Target Address. */
jksoft 0:8c643bfe55b7 114 #define BLE_GAP_AD_TYPE_RANDOM_TARGET_ADDRESS 0x18 /**< Random Target Address. */
jksoft 0:8c643bfe55b7 115 #define BLE_GAP_AD_TYPE_APPEARANCE 0x19 /**< Appearance. */
jksoft 0:8c643bfe55b7 116 #define BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA 0xFF /**< Manufacturer Specific Data. */
jksoft 0:8c643bfe55b7 117 /** @} */
jksoft 0:8c643bfe55b7 118
jksoft 0:8c643bfe55b7 119
jksoft 0:8c643bfe55b7 120 /** @defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags
jksoft 0:8c643bfe55b7 121 * @{ */
jksoft 0:8c643bfe55b7 122 #define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE (0x01) /**< LE Limited Discoverable Mode. */
jksoft 0:8c643bfe55b7 123 #define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) /**< LE General Discoverable Mode. */
jksoft 0:8c643bfe55b7 124 #define BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED (0x04) /**< BR/EDR not supported. */
jksoft 0:8c643bfe55b7 125 #define BLE_GAP_ADV_FLAG_LE_BR_EDR_CONTROLLER (0x08) /**< Simultaneous LE and BR/EDR, Controller. */
jksoft 0:8c643bfe55b7 126 #define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST (0x10) /**< Simultaneous LE and BR/EDR, Host. */
jksoft 0:8c643bfe55b7 127 #define BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE (BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE Limited Discoverable Mode, BR/EDR not supported. */
jksoft 0:8c643bfe55b7 128 #define BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE (BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE General Discoverable Mode, BR/EDR not supported. */
jksoft 0:8c643bfe55b7 129 /** @} */
jksoft 0:8c643bfe55b7 130
jksoft 0:8c643bfe55b7 131
jksoft 0:8c643bfe55b7 132 /** @defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min
jksoft 0:8c643bfe55b7 133 * @{ */
jksoft 0:8c643bfe55b7 134 #define BLE_GAP_ADV_INTERVAL_MIN 0x0020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */
jksoft 0:8c643bfe55b7 135 #define BLE_GAP_ADV_NONCON_INTERVAL_MIN 0x00A0 /**< Minimum Advertising interval in 625 us units for non connectable mode, i.e. 100 ms. */
jksoft 0:8c643bfe55b7 136 #define BLE_GAP_ADV_INTERVAL_MAX 0x4000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */
jksoft 0:8c643bfe55b7 137 /** @} */
jksoft 0:8c643bfe55b7 138
jksoft 0:8c643bfe55b7 139
jksoft 0:8c643bfe55b7 140 /** @brief Maximum size of advertising data in octets. */
jksoft 0:8c643bfe55b7 141 #define BLE_GAP_ADV_MAX_SIZE 31
jksoft 0:8c643bfe55b7 142
jksoft 0:8c643bfe55b7 143
jksoft 0:8c643bfe55b7 144 /** @defgroup BLE_GAP_ADV_TYPES GAP Advertising types
jksoft 0:8c643bfe55b7 145 * @{ */
jksoft 0:8c643bfe55b7 146 #define BLE_GAP_ADV_TYPE_ADV_IND 0x00 /**< Connectable undirected. */
jksoft 0:8c643bfe55b7 147 #define BLE_GAP_ADV_TYPE_ADV_DIRECT_IND 0x01 /**< Connectable directed. */
jksoft 0:8c643bfe55b7 148 #define BLE_GAP_ADV_TYPE_ADV_SCAN_IND 0x02 /**< Scannable undirected. */
jksoft 0:8c643bfe55b7 149 #define BLE_GAP_ADV_TYPE_ADV_NONCONN_IND 0x03 /**< Non connectable undirected. */
jksoft 0:8c643bfe55b7 150 /** @} */
jksoft 0:8c643bfe55b7 151
jksoft 0:8c643bfe55b7 152
jksoft 0:8c643bfe55b7 153 /** @defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies
jksoft 0:8c643bfe55b7 154 * @{ */
jksoft 0:8c643bfe55b7 155 #define BLE_GAP_ADV_FP_ANY 0x00 /**< Allow scan requests and connect requests from any device. */
jksoft 0:8c643bfe55b7 156 #define BLE_GAP_ADV_FP_FILTER_SCANREQ 0x01 /**< Filter scan requests with whitelist. */
jksoft 0:8c643bfe55b7 157 #define BLE_GAP_ADV_FP_FILTER_CONNREQ 0x02 /**< Filter connect requests with whitelist. */
jksoft 0:8c643bfe55b7 158 #define BLE_GAP_ADV_FP_FILTER_BOTH 0x03 /**< Filter both scan and connect requests with whitelist. */
jksoft 0:8c643bfe55b7 159 /** @} */
jksoft 0:8c643bfe55b7 160
jksoft 0:8c643bfe55b7 161
jksoft 0:8c643bfe55b7 162 /** @defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values
jksoft 0:8c643bfe55b7 163 * @{ */
jksoft 0:8c643bfe55b7 164 #define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX 180 /**< Maximum advertising time in limited discoverable mode (TGAP(lim_adv_timeout) = 180s in spec (Addendum 2)). */
jksoft 0:8c643bfe55b7 165 #define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED 0 /**< Unlimited advertising in general discoverable mode. */
jksoft 0:8c643bfe55b7 166 /** @} */
jksoft 0:8c643bfe55b7 167
jksoft 0:8c643bfe55b7 168
jksoft 0:8c643bfe55b7 169 /** @defgroup BLE_GAP_DISC_MODES GAP Discovery modes
jksoft 0:8c643bfe55b7 170 * @{ */
jksoft 0:8c643bfe55b7 171 #define BLE_GAP_DISC_MODE_NOT_DISCOVERABLE 0x00 /**< Not discoverable discovery Mode. */
jksoft 0:8c643bfe55b7 172 #define BLE_GAP_DISC_MODE_LIMITED 0x01 /**< Limited Discovery Mode. */
jksoft 0:8c643bfe55b7 173 #define BLE_GAP_DISC_MODE_GENERAL 0x02 /**< General Discovery Mode. */
jksoft 0:8c643bfe55b7 174 /** @} */
jksoft 0:8c643bfe55b7 175
jksoft 0:8c643bfe55b7 176 /** @defgroup BLE_GAP_IO_CAPS GAP IO Capabilities
jksoft 0:8c643bfe55b7 177 * @{ */
jksoft 0:8c643bfe55b7 178 #define BLE_GAP_IO_CAPS_DISPLAY_ONLY 0x00 /**< Display Only. */
jksoft 0:8c643bfe55b7 179 #define BLE_GAP_IO_CAPS_DISPLAY_YESNO 0x01 /**< Display and Yes/No entry. */
jksoft 0:8c643bfe55b7 180 #define BLE_GAP_IO_CAPS_KEYBOARD_ONLY 0x02 /**< Keyboard Only. */
jksoft 0:8c643bfe55b7 181 #define BLE_GAP_IO_CAPS_NONE 0x03 /**< No I/O capabilities. */
jksoft 0:8c643bfe55b7 182 #define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY 0x04 /**< Keyboard and Display. */
jksoft 0:8c643bfe55b7 183 /** @} */
jksoft 0:8c643bfe55b7 184
jksoft 0:8c643bfe55b7 185
jksoft 0:8c643bfe55b7 186 /** @defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types
jksoft 0:8c643bfe55b7 187 * @{ */
jksoft 0:8c643bfe55b7 188 #define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00 /**< No key (may be used to reject). */
jksoft 0:8c643bfe55b7 189 #define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01 /**< 6-digit Passkey. */
jksoft 0:8c643bfe55b7 190 #define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02 /**< Out Of Band data. */
jksoft 0:8c643bfe55b7 191 /** @} */
jksoft 0:8c643bfe55b7 192
jksoft 0:8c643bfe55b7 193 /** @defgroup BLE_GAP_SEC_STATUS GAP Security status
jksoft 0:8c643bfe55b7 194 * @{ */
jksoft 0:8c643bfe55b7 195 #define BLE_GAP_SEC_STATUS_SUCCESS 0x00 /**< Successful parameters. */
jksoft 0:8c643bfe55b7 196 #define BLE_GAP_SEC_STATUS_TIMEOUT 0x01 /**< Procedure timed out. */
jksoft 0:8c643bfe55b7 197 #define BLE_GAP_SEC_STATUS_PDU_INVALID 0x02 /**< Invalid PDU received. */
jksoft 0:8c643bfe55b7 198 #define BLE_GAP_SEC_STATUS_PASSKEY_ENTRY_FAILED 0x81 /**< Passkey entry failed (user cancelled or other). */
jksoft 0:8c643bfe55b7 199 #define BLE_GAP_SEC_STATUS_OOB_NOT_AVAILABLE 0x82 /**< Out of Band Key not available. */
jksoft 0:8c643bfe55b7 200 #define BLE_GAP_SEC_STATUS_AUTH_REQ 0x83 /**< Authentication requirements not met. */
jksoft 0:8c643bfe55b7 201 #define BLE_GAP_SEC_STATUS_CONFIRM_VALUE 0x84 /**< Confirm value failed. */
jksoft 0:8c643bfe55b7 202 #define BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP 0x85 /**< Pairing not supported. */
jksoft 0:8c643bfe55b7 203 #define BLE_GAP_SEC_STATUS_ENC_KEY_SIZE 0x86 /**< Encryption key size. */
jksoft 0:8c643bfe55b7 204 #define BLE_GAP_SEC_STATUS_SMP_CMD_UNSUPPORTED 0x87 /**< Unsupported SMP command. */
jksoft 0:8c643bfe55b7 205 #define BLE_GAP_SEC_STATUS_UNSPECIFIED 0x88 /**< Unspecified reason. */
jksoft 0:8c643bfe55b7 206 #define BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS 0x89 /**< Too little time elapsed since last attempt. */
jksoft 0:8c643bfe55b7 207 #define BLE_GAP_SEC_STATUS_INVALID_PARAMS 0x8A /**< Invalid parameters. */
jksoft 0:8c643bfe55b7 208 /** @} */
jksoft 0:8c643bfe55b7 209
jksoft 0:8c643bfe55b7 210 /** @defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources
jksoft 0:8c643bfe55b7 211 * @{ */
jksoft 0:8c643bfe55b7 212 #define BLE_GAP_SEC_STATUS_SOURCE_LOCAL 0x00 /**< Local failure. */
jksoft 0:8c643bfe55b7 213 #define BLE_GAP_SEC_STATUS_SOURCE_REMOTE 0x01 /**< Remote failure. */
jksoft 0:8c643bfe55b7 214 /** @} */
jksoft 0:8c643bfe55b7 215
jksoft 0:8c643bfe55b7 216 /** @defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits
jksoft 0:8c643bfe55b7 217 * @{ */
jksoft 0:8c643bfe55b7 218 #define BLE_GAP_CP_MIN_CONN_INTVL_NONE 0xFFFF /**< No new minimum connction interval specified in connect parameters. */
jksoft 0:8c643bfe55b7 219 #define BLE_GAP_CP_MIN_CONN_INTVL_MIN 0x0006 /**< Lowest mimimum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */
jksoft 0:8c643bfe55b7 220 #define BLE_GAP_CP_MIN_CONN_INTVL_MAX 0x0C80 /**< Highest minimum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */
jksoft 0:8c643bfe55b7 221 #define BLE_GAP_CP_MAX_CONN_INTVL_NONE 0xFFFF /**< No new maximum connction interval specified in connect parameters. */
jksoft 0:8c643bfe55b7 222 #define BLE_GAP_CP_MAX_CONN_INTVL_MIN 0x0006 /**< Lowest maximum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */
jksoft 0:8c643bfe55b7 223 #define BLE_GAP_CP_MAX_CONN_INTVL_MAX 0x0C80 /**< Highest maximum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */
jksoft 0:8c643bfe55b7 224 #define BLE_GAP_CP_SLAVE_LATENCY_MAX 0x03E8 /**< Highest slave latency permitted, in connection events. */
jksoft 0:8c643bfe55b7 225 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_NONE 0xFFFF /**< No new supervision timeout specified in connect parameters. */
jksoft 0:8c643bfe55b7 226 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MIN 0x000A /**< Lowest supervision timeout permitted, in units of 10 ms, i.e. 100 ms. */
jksoft 0:8c643bfe55b7 227 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MAX 0x0C80 /**< Highest supervision timeout permitted, in units of 10 ms, i.e. 32 s. */
jksoft 0:8c643bfe55b7 228 /** @} */
jksoft 0:8c643bfe55b7 229
jksoft 0:8c643bfe55b7 230
jksoft 0:8c643bfe55b7 231 /**@brief GAP device name maximum length. */
jksoft 0:8c643bfe55b7 232 #define BLE_GAP_DEVNAME_MAX_LEN 31
jksoft 0:8c643bfe55b7 233
jksoft 0:8c643bfe55b7 234
jksoft 0:8c643bfe55b7 235 /** @defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters
jksoft 0:8c643bfe55b7 236 *
jksoft 0:8c643bfe55b7 237 * See @ref ble_gap_conn_sec_mode_t.
jksoft 0:8c643bfe55b7 238 * @{ */
jksoft 0:8c643bfe55b7 239 /** @brief Set sec_mode pointed to by ptr to have no access rights.*/
jksoft 0:8c643bfe55b7 240 #define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr) do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0)
jksoft 0:8c643bfe55b7 241 /** @brief Set sec_mode pointed to by ptr to require no protection, open link.*/
jksoft 0:8c643bfe55b7 242 #define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr) do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0)
jksoft 0:8c643bfe55b7 243 /** @brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/
jksoft 0:8c643bfe55b7 244 #define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0)
jksoft 0:8c643bfe55b7 245 /** @brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/
jksoft 0:8c643bfe55b7 246 #define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0)
jksoft 0:8c643bfe55b7 247 /** @brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/
jksoft 0:8c643bfe55b7 248 #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0)
jksoft 0:8c643bfe55b7 249 /** @brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/
jksoft 0:8c643bfe55b7 250 #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0)
jksoft 0:8c643bfe55b7 251 /** @} */
jksoft 0:8c643bfe55b7 252
jksoft 0:8c643bfe55b7 253
jksoft 0:8c643bfe55b7 254 /**@brief GAP Security Key Length. */
jksoft 0:8c643bfe55b7 255 #define BLE_GAP_SEC_KEY_LEN 16
jksoft 0:8c643bfe55b7 256
jksoft 0:8c643bfe55b7 257 /**@brief Maximum amount of addresses in a whitelist. */
jksoft 0:8c643bfe55b7 258 #define BLE_GAP_WHITELIST_ADDR_MAX_COUNT (8)
jksoft 0:8c643bfe55b7 259
jksoft 0:8c643bfe55b7 260 /**@brief Maximum amount of IRKs in a whitelist.
jksoft 0:8c643bfe55b7 261 * @note The number of IRKs is limited to 8, even if the hardware supports more.
jksoft 0:8c643bfe55b7 262 */
jksoft 0:8c643bfe55b7 263 #define BLE_GAP_WHITELIST_IRK_MAX_COUNT (8)
jksoft 0:8c643bfe55b7 264
jksoft 0:8c643bfe55b7 265 /** @defgroup GAP_SEC_MODES GAP Security Modes
jksoft 0:8c643bfe55b7 266 * @{ */
jksoft 0:8c643bfe55b7 267 #define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */
jksoft 0:8c643bfe55b7 268
jksoft 0:8c643bfe55b7 269 /** @} */
jksoft 0:8c643bfe55b7 270
jksoft 0:8c643bfe55b7 271
jksoft 0:8c643bfe55b7 272 /** @} */
jksoft 0:8c643bfe55b7 273
jksoft 0:8c643bfe55b7 274 /**@brief Bluetooth Low Energy address. */
jksoft 0:8c643bfe55b7 275 typedef struct
jksoft 0:8c643bfe55b7 276 {
jksoft 0:8c643bfe55b7 277 uint8_t addr_type; /**< See @ref BLE_GAP_ADDR_TYPES. */
jksoft 0:8c643bfe55b7 278 uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format. */
jksoft 0:8c643bfe55b7 279 } ble_gap_addr_t;
jksoft 0:8c643bfe55b7 280
jksoft 0:8c643bfe55b7 281
jksoft 0:8c643bfe55b7 282 /**@brief GAP connection parameters.
jksoft 0:8c643bfe55b7 283 *
jksoft 0:8c643bfe55b7 284 * @note When ble_conn_params_t is received in an event, both min_conn_interval and
jksoft 0:8c643bfe55b7 285 * max_conn_interval will be equal to the connection interval set by the central.
jksoft 0:8c643bfe55b7 286 */
jksoft 0:8c643bfe55b7 287 typedef struct
jksoft 0:8c643bfe55b7 288 {
jksoft 0:8c643bfe55b7 289 uint16_t min_conn_interval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
jksoft 0:8c643bfe55b7 290 uint16_t max_conn_interval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
jksoft 0:8c643bfe55b7 291 uint16_t slave_latency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/
jksoft 0:8c643bfe55b7 292 uint16_t conn_sup_timeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/
jksoft 0:8c643bfe55b7 293 } ble_gap_conn_params_t;
jksoft 0:8c643bfe55b7 294
jksoft 0:8c643bfe55b7 295
jksoft 0:8c643bfe55b7 296 /**@brief GAP link requirements.
jksoft 0:8c643bfe55b7 297 *
jksoft 0:8c643bfe55b7 298 * See Bluetooth Core specification, Volume 3 Part C 10.2 for details.
jksoft 0:8c643bfe55b7 299 *
jksoft 0:8c643bfe55b7 300 * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n
jksoft 0:8c643bfe55b7 301 * Security Mode 1 Level 1: No security is needed (aka open link).\n
jksoft 0:8c643bfe55b7 302 * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n
jksoft 0:8c643bfe55b7 303 * Security Mode 1 Level 3: MITM protected encrypted link required.\n
jksoft 0:8c643bfe55b7 304 * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n
jksoft 0:8c643bfe55b7 305 * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n
jksoft 0:8c643bfe55b7 306 */
jksoft 0:8c643bfe55b7 307 typedef struct
jksoft 0:8c643bfe55b7 308 {
jksoft 0:8c643bfe55b7 309 uint8_t sm : 4; /**< Security Mode (1 or 2), 0 for no permissions at all. */
jksoft 0:8c643bfe55b7 310 uint8_t lv : 4; /**< Level (1, 2 or 3), 0 for no permissions at all. */
jksoft 0:8c643bfe55b7 311
jksoft 0:8c643bfe55b7 312 } ble_gap_conn_sec_mode_t;
jksoft 0:8c643bfe55b7 313
jksoft 0:8c643bfe55b7 314
jksoft 0:8c643bfe55b7 315
jksoft 0:8c643bfe55b7 316 /**@brief GAP connection security status.*/
jksoft 0:8c643bfe55b7 317 typedef struct
jksoft 0:8c643bfe55b7 318 {
jksoft 0:8c643bfe55b7 319 ble_gap_conn_sec_mode_t sec_mode; /**< Currently active security mode for this connection.*/
jksoft 0:8c643bfe55b7 320 uint8_t encr_key_size; /**< Length of currently active encryption key, 7 to 16 octets.*/
jksoft 0:8c643bfe55b7 321 } ble_gap_conn_sec_t;
jksoft 0:8c643bfe55b7 322
jksoft 0:8c643bfe55b7 323
jksoft 0:8c643bfe55b7 324
jksoft 0:8c643bfe55b7 325 /**@brief Identity Resolving Key. */
jksoft 0:8c643bfe55b7 326 typedef struct
jksoft 0:8c643bfe55b7 327 {
jksoft 0:8c643bfe55b7 328 uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Array containing IRK. */
jksoft 0:8c643bfe55b7 329 } ble_gap_irk_t;
jksoft 0:8c643bfe55b7 330
jksoft 0:8c643bfe55b7 331
jksoft 0:8c643bfe55b7 332 /**@brief Whitelist structure. */
jksoft 0:8c643bfe55b7 333 typedef struct
jksoft 0:8c643bfe55b7 334 {
jksoft 0:8c643bfe55b7 335 ble_gap_addr_t ** pp_addrs; /**< Pointer to array of device address pointers, pointing to addresses to be used in whitelist. NULL if none are given. */
jksoft 0:8c643bfe55b7 336 uint8_t addr_count; /**< Count of device addresses in array, up to @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT. */
jksoft 0:8c643bfe55b7 337 ble_gap_irk_t ** pp_irks; /**< Pointer to array of Identity Resolving Key (IRK) pointers, each pointing to an IRK in the whitelist. NULL if none are given. */
jksoft 0:8c643bfe55b7 338 uint8_t irk_count; /**< Count of IRKs in array, up to @ref BLE_GAP_WHITELIST_IRK_MAX_COUNT. */
jksoft 0:8c643bfe55b7 339 } ble_gap_whitelist_t;
jksoft 0:8c643bfe55b7 340
jksoft 0:8c643bfe55b7 341
jksoft 0:8c643bfe55b7 342 /**@brief GAP advertising parameters.*/
jksoft 0:8c643bfe55b7 343 typedef struct
jksoft 0:8c643bfe55b7 344 {
jksoft 0:8c643bfe55b7 345 uint8_t type; /**< See @ref BLE_GAP_ADV_TYPES. */
jksoft 0:8c643bfe55b7 346 ble_gap_addr_t* p_peer_addr; /**< For BLE_GAP_CONN_MODE_DIRECTED mode only, known peer address. */
jksoft 0:8c643bfe55b7 347 uint8_t fp; /**< Filter Policy, see @ref BLE_GAP_ADV_FILTER_POLICIES. */
jksoft 0:8c643bfe55b7 348 ble_gap_whitelist_t * p_whitelist; /**< Pointer to whitelist, NULL if none is given. */
jksoft 0:8c643bfe55b7 349 uint16_t interval; /**< Advertising interval between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s), see @ref BLE_GAP_ADV_INTERVALS. This parameter must be set to 0 if type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND. */
jksoft 0:8c643bfe55b7 350 uint16_t timeout; /**< Advertising timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. See also @ref BLE_GAP_ADV_TIMEOUT_VALUES. This parameter must be set to 0 if type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND. */
jksoft 0:8c643bfe55b7 351 } ble_gap_adv_params_t;
jksoft 0:8c643bfe55b7 352
jksoft 0:8c643bfe55b7 353
jksoft 0:8c643bfe55b7 354 /**@brief GAP scanning parameters. */
jksoft 0:8c643bfe55b7 355 typedef struct
jksoft 0:8c643bfe55b7 356 {
jksoft 0:8c643bfe55b7 357 uint8_t filter; /**< Filter based on discovery mode, see @ref BLE_GAP_DISC_MODES. */
jksoft 0:8c643bfe55b7 358 uint8_t active : 1; /**< If 1, perform active scanning (scan requests). */
jksoft 0:8c643bfe55b7 359 uint8_t selective : 1; /**< If 1, ignore unknown devices (non whitelisted). */
jksoft 0:8c643bfe55b7 360 uint16_t interval; /**< Scan interval between 0x0020 and 0x4000 in 0.625ms units (20ms to 10.24s). */
jksoft 0:8c643bfe55b7 361 uint16_t window; /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
jksoft 0:8c643bfe55b7 362 uint16_t timeout; /**< Scan timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. */
jksoft 0:8c643bfe55b7 363 } ble_gap_scan_params_t;
jksoft 0:8c643bfe55b7 364
jksoft 0:8c643bfe55b7 365
jksoft 0:8c643bfe55b7 366 /**@brief GAP security parameters. */
jksoft 0:8c643bfe55b7 367 typedef struct
jksoft 0:8c643bfe55b7 368 {
jksoft 0:8c643bfe55b7 369 uint16_t timeout; /**< Timeout for SMP transactions or Security Request in seconds, see @ref sd_ble_gap_authenticate and @ref sd_ble_gap_sec_params_reply for more information. */
jksoft 0:8c643bfe55b7 370 uint8_t bond : 1; /**< Perform bonding. */
jksoft 0:8c643bfe55b7 371 uint8_t mitm : 1; /**< Man In The Middle protection required. */
jksoft 0:8c643bfe55b7 372 uint8_t io_caps : 3; /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */
jksoft 0:8c643bfe55b7 373 uint8_t oob : 1; /**< Out Of Band data available. */
jksoft 0:8c643bfe55b7 374 uint8_t min_key_size; /**< Minimum encryption key size in octets between 7 and 16. */
jksoft 0:8c643bfe55b7 375 uint8_t max_key_size; /**< Maximum encryption key size in octets between min_key_size and 16. */
jksoft 0:8c643bfe55b7 376 } ble_gap_sec_params_t;
jksoft 0:8c643bfe55b7 377
jksoft 0:8c643bfe55b7 378
jksoft 0:8c643bfe55b7 379 /**@brief GAP Encryption Information. */
jksoft 0:8c643bfe55b7 380 typedef struct
jksoft 0:8c643bfe55b7 381 {
jksoft 0:8c643bfe55b7 382 uint16_t div; /**< Encryption Diversifier. */
jksoft 0:8c643bfe55b7 383 uint8_t ltk[BLE_GAP_SEC_KEY_LEN]; /**< Long Term Key. */
jksoft 0:8c643bfe55b7 384 uint8_t auth : 1; /**< Authenticated Key. */
jksoft 0:8c643bfe55b7 385 uint8_t ltk_len : 7; /**< LTK length in octets. */
jksoft 0:8c643bfe55b7 386 } ble_gap_enc_info_t;
jksoft 0:8c643bfe55b7 387
jksoft 0:8c643bfe55b7 388
jksoft 0:8c643bfe55b7 389 /**@brief GAP Master Identification. */
jksoft 0:8c643bfe55b7 390 typedef struct
jksoft 0:8c643bfe55b7 391 {
jksoft 0:8c643bfe55b7 392 uint16_t ediv; /**< Encrypted Diversifier. */
jksoft 0:8c643bfe55b7 393 uint8_t rand[8]; /**< Random Number. */
jksoft 0:8c643bfe55b7 394 } ble_gap_master_id_t;
jksoft 0:8c643bfe55b7 395
jksoft 0:8c643bfe55b7 396
jksoft 0:8c643bfe55b7 397 /**@brief GAP Identity Information. */
jksoft 0:8c643bfe55b7 398 typedef struct
jksoft 0:8c643bfe55b7 399 {
jksoft 0:8c643bfe55b7 400 ble_gap_addr_t addr; /**< Bluetooth address to which this key applies. */
jksoft 0:8c643bfe55b7 401 uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Identity Resolution Key. */
jksoft 0:8c643bfe55b7 402 } ble_gap_id_info_t;
jksoft 0:8c643bfe55b7 403
jksoft 0:8c643bfe55b7 404
jksoft 0:8c643bfe55b7 405 /**@brief GAP Signing Information. */
jksoft 0:8c643bfe55b7 406 typedef struct
jksoft 0:8c643bfe55b7 407 {
jksoft 0:8c643bfe55b7 408 uint8_t csrk[BLE_GAP_SEC_KEY_LEN]; /* Connection Signature Resolving Key. */
jksoft 0:8c643bfe55b7 409 } ble_gap_sign_info_t;
jksoft 0:8c643bfe55b7 410
jksoft 0:8c643bfe55b7 411
jksoft 0:8c643bfe55b7 412
jksoft 0:8c643bfe55b7 413 /**
jksoft 0:8c643bfe55b7 414 * @brief GAP Event IDs.
jksoft 0:8c643bfe55b7 415 * Those IDs uniquely identify an event coming from the stack to the application.
jksoft 0:8c643bfe55b7 416 */
jksoft 0:8c643bfe55b7 417 enum BLE_GAP_EVTS
jksoft 0:8c643bfe55b7 418 {
jksoft 0:8c643bfe55b7 419 BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connection established. */
jksoft 0:8c643bfe55b7 420 BLE_GAP_EVT_DISCONNECTED, /**< Disconnected from peer. */
jksoft 0:8c643bfe55b7 421 BLE_GAP_EVT_CONN_PARAM_UPDATE, /**< Connection Parameters updated. */
jksoft 0:8c643bfe55b7 422 BLE_GAP_EVT_SEC_PARAMS_REQUEST, /**< Request to provide security parameters. */
jksoft 0:8c643bfe55b7 423 BLE_GAP_EVT_SEC_INFO_REQUEST, /**< Request to provide security information. */
jksoft 0:8c643bfe55b7 424 BLE_GAP_EVT_PASSKEY_DISPLAY, /**< Request to display a passkey to the user. */
jksoft 0:8c643bfe55b7 425 BLE_GAP_EVT_AUTH_KEY_REQUEST, /**< Request to provide an authentication key. */
jksoft 0:8c643bfe55b7 426 BLE_GAP_EVT_AUTH_STATUS, /**< Authentication procedure completed with status. */
jksoft 0:8c643bfe55b7 427 BLE_GAP_EVT_CONN_SEC_UPDATE, /**< Connection security updated. */
jksoft 0:8c643bfe55b7 428 BLE_GAP_EVT_TIMEOUT, /**< Timeout expired. */
jksoft 0:8c643bfe55b7 429 BLE_GAP_EVT_RSSI_CHANGED, /**< Signal strength measurement report. */
jksoft 0:8c643bfe55b7 430 };
jksoft 0:8c643bfe55b7 431
jksoft 0:8c643bfe55b7 432
jksoft 0:8c643bfe55b7 433 /** @brief Event data for connected event. */
jksoft 0:8c643bfe55b7 434 typedef struct
jksoft 0:8c643bfe55b7 435 {
jksoft 0:8c643bfe55b7 436 ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
jksoft 0:8c643bfe55b7 437 uint8_t irk_match :1; /**< If 1, peer device's address resolved using an IRK. */
jksoft 0:8c643bfe55b7 438 uint8_t irk_match_idx :7; /**< Index in IRK list where the address was matched. */
jksoft 0:8c643bfe55b7 439 ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
jksoft 0:8c643bfe55b7 440 } ble_gap_evt_connected_t;
jksoft 0:8c643bfe55b7 441
jksoft 0:8c643bfe55b7 442
jksoft 0:8c643bfe55b7 443 /** @brief Event data for disconnected event. */
jksoft 0:8c643bfe55b7 444 typedef struct
jksoft 0:8c643bfe55b7 445 {
jksoft 0:8c643bfe55b7 446 uint8_t reason; /**< HCI error code. */
jksoft 0:8c643bfe55b7 447 } ble_gap_evt_disconnected_t;
jksoft 0:8c643bfe55b7 448
jksoft 0:8c643bfe55b7 449
jksoft 0:8c643bfe55b7 450 /** @brief Event data for connection parameter update event. */
jksoft 0:8c643bfe55b7 451 typedef struct
jksoft 0:8c643bfe55b7 452 {
jksoft 0:8c643bfe55b7 453 ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
jksoft 0:8c643bfe55b7 454 } ble_gap_evt_conn_param_update_t;
jksoft 0:8c643bfe55b7 455
jksoft 0:8c643bfe55b7 456
jksoft 0:8c643bfe55b7 457 /** @brief Event data for security parameters request event. */
jksoft 0:8c643bfe55b7 458 typedef struct
jksoft 0:8c643bfe55b7 459 {
jksoft 0:8c643bfe55b7 460 ble_gap_sec_params_t peer_params; /**< Initiator Security Parameters. */
jksoft 0:8c643bfe55b7 461 } ble_gap_evt_sec_params_request_t;
jksoft 0:8c643bfe55b7 462
jksoft 0:8c643bfe55b7 463
jksoft 0:8c643bfe55b7 464 /** @brief Event data for securito info request event. */
jksoft 0:8c643bfe55b7 465 typedef struct
jksoft 0:8c643bfe55b7 466 {
jksoft 0:8c643bfe55b7 467 ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
jksoft 0:8c643bfe55b7 468 uint16_t div; /**< Encryption diversifier for LTK lookup. */
jksoft 0:8c643bfe55b7 469 uint8_t enc_info : 1; /**< If 1, Encryption Information required. */
jksoft 0:8c643bfe55b7 470 uint8_t id_info : 1; /**< If 1, Identity Information required. */
jksoft 0:8c643bfe55b7 471 uint8_t sign_info : 1; /**< If 1, Signing Information required. */
jksoft 0:8c643bfe55b7 472 } ble_gap_evt_sec_info_request_t;
jksoft 0:8c643bfe55b7 473
jksoft 0:8c643bfe55b7 474
jksoft 0:8c643bfe55b7 475 /** @brief Event data for passkey display event. */
jksoft 0:8c643bfe55b7 476 typedef struct
jksoft 0:8c643bfe55b7 477 {
jksoft 0:8c643bfe55b7 478 uint8_t passkey[6]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */
jksoft 0:8c643bfe55b7 479 } ble_gap_evt_passkey_display_t;
jksoft 0:8c643bfe55b7 480
jksoft 0:8c643bfe55b7 481
jksoft 0:8c643bfe55b7 482 /** @brief Event data for authentication key request event. */
jksoft 0:8c643bfe55b7 483 typedef struct
jksoft 0:8c643bfe55b7 484 {
jksoft 0:8c643bfe55b7 485 uint8_t key_type; /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */
jksoft 0:8c643bfe55b7 486 } ble_gap_evt_auth_key_request_t;
jksoft 0:8c643bfe55b7 487
jksoft 0:8c643bfe55b7 488
jksoft 0:8c643bfe55b7 489 /** @brief Security levels supported.
jksoft 0:8c643bfe55b7 490 * @note See Bluetooth Specification Version 4.0 Volume 3, Chapter 10.
jksoft 0:8c643bfe55b7 491 */
jksoft 0:8c643bfe55b7 492 typedef struct
jksoft 0:8c643bfe55b7 493 {
jksoft 0:8c643bfe55b7 494 uint8_t lv1 : 1; /**< If 1: Level 1 is supported. */
jksoft 0:8c643bfe55b7 495 uint8_t lv2 : 1; /**< If 1: Level 2 is supported. */
jksoft 0:8c643bfe55b7 496 uint8_t lv3 : 1; /**< If 1: Level 3 is supported. */
jksoft 0:8c643bfe55b7 497 } ble_gap_sec_levels_t;
jksoft 0:8c643bfe55b7 498
jksoft 0:8c643bfe55b7 499
jksoft 0:8c643bfe55b7 500 /** @brief Keys that have been exchanged. */
jksoft 0:8c643bfe55b7 501 typedef struct
jksoft 0:8c643bfe55b7 502 {
jksoft 0:8c643bfe55b7 503 uint8_t ltk : 1; /**< Long Term Key. */
jksoft 0:8c643bfe55b7 504 uint8_t ediv_rand : 1; /**< Encrypted Diversifier and Random value. */
jksoft 0:8c643bfe55b7 505 uint8_t irk : 1; /**< Identity Resolving Key. */
jksoft 0:8c643bfe55b7 506 uint8_t address : 1; /**< Public or static random address. */
jksoft 0:8c643bfe55b7 507 uint8_t csrk : 1; /**< Connection Signature Resolving Key. */
jksoft 0:8c643bfe55b7 508 } ble_gap_sec_keys_t;
jksoft 0:8c643bfe55b7 509
jksoft 0:8c643bfe55b7 510
jksoft 0:8c643bfe55b7 511 /** @brief Event data for authentication status event. */
jksoft 0:8c643bfe55b7 512 typedef struct
jksoft 0:8c643bfe55b7 513 {
jksoft 0:8c643bfe55b7 514 uint8_t auth_status; /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */
jksoft 0:8c643bfe55b7 515 uint8_t error_src; /**< On error, source that caused the failure, see @ref BLE_GAP_SEC_STATUS_SOURCES. */
jksoft 0:8c643bfe55b7 516 ble_gap_sec_levels_t sm1_levels; /**< Levels supported in Security Mode 1. */
jksoft 0:8c643bfe55b7 517 ble_gap_sec_levels_t sm2_levels; /**< Levels supported in Security Mode 2. */
jksoft 0:8c643bfe55b7 518 ble_gap_sec_keys_t periph_kex; /**< Bitmap stating which keys were exchanged (distributed) by the peripheral. */
jksoft 0:8c643bfe55b7 519 ble_gap_sec_keys_t central_kex; /**< Bitmap stating which keys were exchanged (distributed) by the central. */
jksoft 0:8c643bfe55b7 520 struct periph_keys_t
jksoft 0:8c643bfe55b7 521 {
jksoft 0:8c643bfe55b7 522 ble_gap_enc_info_t enc_info; /**< Peripheral's Encryption information. */
jksoft 0:8c643bfe55b7 523 } periph_keys; /**< Actual keys distributed from the Peripheral to the Central. */
jksoft 0:8c643bfe55b7 524 struct central_keys_t
jksoft 0:8c643bfe55b7 525 {
jksoft 0:8c643bfe55b7 526 ble_gap_irk_t irk; /**< Central's IRK. */
jksoft 0:8c643bfe55b7 527 ble_gap_addr_t id_info; /**< Central's Identity Info. */
jksoft 0:8c643bfe55b7 528 } central_keys; /**< Actual keys distributed from the Central to the Peripheral. */
jksoft 0:8c643bfe55b7 529 } ble_gap_evt_auth_status_t;
jksoft 0:8c643bfe55b7 530
jksoft 0:8c643bfe55b7 531
jksoft 0:8c643bfe55b7 532 /** @brief Event data for connection security update event. */
jksoft 0:8c643bfe55b7 533 typedef struct
jksoft 0:8c643bfe55b7 534 {
jksoft 0:8c643bfe55b7 535 ble_gap_conn_sec_t conn_sec; /**< Connection security level. */
jksoft 0:8c643bfe55b7 536 } ble_gap_evt_conn_sec_update_t;
jksoft 0:8c643bfe55b7 537
jksoft 0:8c643bfe55b7 538
jksoft 0:8c643bfe55b7 539 /** @brief Event data for timeout event. */
jksoft 0:8c643bfe55b7 540 typedef struct
jksoft 0:8c643bfe55b7 541 {
jksoft 0:8c643bfe55b7 542 uint8_t src; /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */
jksoft 0:8c643bfe55b7 543 } ble_gap_evt_timeout_t;
jksoft 0:8c643bfe55b7 544
jksoft 0:8c643bfe55b7 545
jksoft 0:8c643bfe55b7 546 /** @brief Event data for advertisement report event. */
jksoft 0:8c643bfe55b7 547 typedef struct
jksoft 0:8c643bfe55b7 548 {
jksoft 0:8c643bfe55b7 549 int8_t rssi; /**< Received Signal Strength Indication in dBm. */
jksoft 0:8c643bfe55b7 550 } ble_gap_evt_rssi_changed_t;
jksoft 0:8c643bfe55b7 551
jksoft 0:8c643bfe55b7 552
jksoft 0:8c643bfe55b7 553
jksoft 0:8c643bfe55b7 554 /**@brief GAP event callback event structure. */
jksoft 0:8c643bfe55b7 555 typedef struct
jksoft 0:8c643bfe55b7 556 {
jksoft 0:8c643bfe55b7 557 uint16_t conn_handle; /**< Connection Handle on which event occured. */
jksoft 0:8c643bfe55b7 558 union /**< union alternative identified by evt_id in enclosing struct. */
jksoft 0:8c643bfe55b7 559 {
jksoft 0:8c643bfe55b7 560 ble_gap_evt_connected_t connected; /**< Connected Event Parameters. */
jksoft 0:8c643bfe55b7 561 ble_gap_evt_disconnected_t disconnected; /**< Disconnected Event Parameters. */
jksoft 0:8c643bfe55b7 562 ble_gap_evt_conn_param_update_t conn_param_update; /**< Connection Parameter Update Parameters. */
jksoft 0:8c643bfe55b7 563 ble_gap_evt_sec_params_request_t sec_params_request; /**< Security Parameters Request Event Parameters. */
jksoft 0:8c643bfe55b7 564 ble_gap_evt_sec_info_request_t sec_info_request; /**< Security Information Request Event Parameters. */
jksoft 0:8c643bfe55b7 565 ble_gap_evt_passkey_display_t passkey_display; /**< Passkey Display Event Parameters. */
jksoft 0:8c643bfe55b7 566 ble_gap_evt_auth_key_request_t auth_key_request; /**< Authentication Key Request Event Parameters. */
jksoft 0:8c643bfe55b7 567 ble_gap_evt_auth_status_t auth_status; /**< Authentication Status Event Parameters. */
jksoft 0:8c643bfe55b7 568 ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */
jksoft 0:8c643bfe55b7 569 ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */
jksoft 0:8c643bfe55b7 570 ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event parameters. */
jksoft 0:8c643bfe55b7 571 } params;
jksoft 0:8c643bfe55b7 572
jksoft 0:8c643bfe55b7 573 } ble_gap_evt_t;
jksoft 0:8c643bfe55b7 574
jksoft 0:8c643bfe55b7 575
jksoft 0:8c643bfe55b7 576 /**@brief Set local Bluetooth address.
jksoft 0:8c643bfe55b7 577 *
jksoft 0:8c643bfe55b7 578 * @param[in] p_addr Pointer to address structure.
jksoft 0:8c643bfe55b7 579 *
jksoft 0:8c643bfe55b7 580 * @return @ref NRF_SUCCESS Address successfully set.
jksoft 0:8c643bfe55b7 581 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 582 * @return @ref BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address.
jksoft 0:8c643bfe55b7 583 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry.
jksoft 0:8c643bfe55b7 584 */
jksoft 0:8c643bfe55b7 585 SVCALL(SD_BLE_GAP_ADDRESS_SET, uint32_t, sd_ble_gap_address_set(ble_gap_addr_t const * const p_addr));
jksoft 0:8c643bfe55b7 586
jksoft 0:8c643bfe55b7 587
jksoft 0:8c643bfe55b7 588 /**@brief Get local Bluetooth address.
jksoft 0:8c643bfe55b7 589 *
jksoft 0:8c643bfe55b7 590 * @param[out] p_addr Pointer to address structure.
jksoft 0:8c643bfe55b7 591 *
jksoft 0:8c643bfe55b7 592 * @return @ref NRF_SUCCESS Address successfully retrieved.
jksoft 0:8c643bfe55b7 593 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 594 */
jksoft 0:8c643bfe55b7 595 SVCALL(SD_BLE_GAP_ADDRESS_GET, uint32_t, sd_ble_gap_address_get(ble_gap_addr_t * const p_addr));
jksoft 0:8c643bfe55b7 596
jksoft 0:8c643bfe55b7 597
jksoft 0:8c643bfe55b7 598 /**@brief Set, clear or update advertisement and scan response data.
jksoft 0:8c643bfe55b7 599 *
jksoft 0:8c643bfe55b7 600 * @note The format of the advertisement data will be checked by this call to ensure interoperability.
jksoft 0:8c643bfe55b7 601 * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and
jksoft 0:8c643bfe55b7 602 * duplicating the local name in the advertisement data and scan response data.
jksoft 0:8c643bfe55b7 603 *
jksoft 0:8c643bfe55b7 604 * @note: To clear the advertisement data and set it to a 0-length packet, simply provide a valid pointer (p_data/p_sr_data) with its corresponding
jksoft 0:8c643bfe55b7 605 * length (dlen/srdlen) set to 0.
jksoft 0:8c643bfe55b7 606 *
jksoft 0:8c643bfe55b7 607 * @note: The call will fail if p_data and p_sr_data are both NULL since this would have no effect.
jksoft 0:8c643bfe55b7 608 *
jksoft 0:8c643bfe55b7 609 * @param[in] p_data Raw data to be placed in advertisement packet. If NULL, no changes are made to the current advertisement packet data.
jksoft 0:8c643bfe55b7 610 * @param[in] dlen Data length for p_data. Max size: @ref BLE_GAP_ADV_MAX_SIZE octets. Should be 0 if p_data is NULL, can be 0 if p_data is not NULL.
jksoft 0:8c643bfe55b7 611 * @param[in] p_sr_data Raw data to be placed in scan response packet. If NULL, no changes are made to the current scan response packet data.
jksoft 0:8c643bfe55b7 612 * @param[in] srdlen Data length for p_sr_data. Max size: @ref BLE_GAP_ADV_MAX_SIZE octets. Should be 0 if p_sr_data is NULL, can be 0 if p_data is not NULL.
jksoft 0:8c643bfe55b7 613 *
jksoft 0:8c643bfe55b7 614 * @return @ref NRF_SUCCESS Advertisement data successfully updated or cleared.
jksoft 0:8c643bfe55b7 615 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 616 * @return @ref NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied.
jksoft 0:8c643bfe55b7 617 * @return @ref NRF_ERROR_INVALID_DATA Invalid data type(s) supplied, check the advertising data format specification.
jksoft 0:8c643bfe55b7 618 * @return @ref NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied.
jksoft 0:8c643bfe55b7 619 * @return @ref BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied.
jksoft 0:8c643bfe55b7 620 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry.
jksoft 0:8c643bfe55b7 621 */
jksoft 0:8c643bfe55b7 622 SVCALL(SD_BLE_GAP_ADV_DATA_SET, uint32_t, sd_ble_gap_adv_data_set(uint8_t const * const p_data, uint8_t dlen, uint8_t const * const p_sr_data, uint8_t srdlen));
jksoft 0:8c643bfe55b7 623
jksoft 0:8c643bfe55b7 624
jksoft 0:8c643bfe55b7 625 /**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
jksoft 0:8c643bfe55b7 626 *
jksoft 0:8c643bfe55b7 627 * @param[in] p_adv_params Pointer to advertising parameters structure.
jksoft 0:8c643bfe55b7 628 *
jksoft 0:8c643bfe55b7 629 * @return @ref NRF_SUCCESS The BLE stack has started advertising.
jksoft 0:8c643bfe55b7 630 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 631 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
jksoft 0:8c643bfe55b7 632 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check the accepted ranges and limits.
jksoft 0:8c643bfe55b7 633 * @return @ref BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Bluetooth address supplied.
jksoft 0:8c643bfe55b7 634 * @return @ref BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible.
jksoft 0:8c643bfe55b7 635 */
jksoft 0:8c643bfe55b7 636 SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(ble_gap_adv_params_t const * const p_adv_params));
jksoft 0:8c643bfe55b7 637
jksoft 0:8c643bfe55b7 638
jksoft 0:8c643bfe55b7 639 /**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
jksoft 0:8c643bfe55b7 640 *
jksoft 0:8c643bfe55b7 641 * @return @ref NRF_SUCCESS The BLE stack has stopped advertising.
jksoft 0:8c643bfe55b7 642 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation (most probably not in advertising state).
jksoft 0:8c643bfe55b7 643 */
jksoft 0:8c643bfe55b7 644 SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(void));
jksoft 0:8c643bfe55b7 645
jksoft 0:8c643bfe55b7 646
jksoft 0:8c643bfe55b7 647 /**@brief Update connection parameters.
jksoft 0:8c643bfe55b7 648 *
jksoft 0:8c643bfe55b7 649 * @details In the central role this will initiate a Link Layer connection parameter update procedure,
jksoft 0:8c643bfe55b7 650 * otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for
jksoft 0:8c643bfe55b7 651 * the central to perform the procedure. In both cases, and regardless of success or failure, the application
jksoft 0:8c643bfe55b7 652 * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event.
jksoft 0:8c643bfe55b7 653 *
jksoft 0:8c643bfe55b7 654 * @note If both a connection supervision timeout and a maximum connection interval are specified, then the following constraint
jksoft 0:8c643bfe55b7 655 * applies: (conn_sup_timeout * 8) >= (max_conn_interval * (slave_latency + 1))
jksoft 0:8c643bfe55b7 656 *
jksoft 0:8c643bfe55b7 657 * @param[in] conn_handle Connection handle.
jksoft 0:8c643bfe55b7 658 * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role,
jksoft 0:8c643bfe55b7 659 * the parameters in the PPCP characteristic of the GAP service will be used instead.
jksoft 0:8c643bfe55b7 660 *
jksoft 0:8c643bfe55b7 661 * @return @ref NRF_SUCCESS The Connection Update procedure has been started successfully.
jksoft 0:8c643bfe55b7 662 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 663 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
jksoft 0:8c643bfe55b7 664 * @return @ref NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, process pending events and retry.
jksoft 0:8c643bfe55b7 665 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
jksoft 0:8c643bfe55b7 666 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
jksoft 0:8c643bfe55b7 667 */
jksoft 0:8c643bfe55b7 668 SVCALL(SD_BLE_GAP_CONN_PARAM_UPDATE, uint32_t, sd_ble_gap_conn_param_update(uint16_t conn_handle, ble_gap_conn_params_t const * const p_conn_params));
jksoft 0:8c643bfe55b7 669
jksoft 0:8c643bfe55b7 670
jksoft 0:8c643bfe55b7 671 /**@brief Disconnect (GAP Link Termination).
jksoft 0:8c643bfe55b7 672 *
jksoft 0:8c643bfe55b7 673 * @details This call initiates the disconnection procedure, and its completion will be communicated to the application
jksoft 0:8c643bfe55b7 674 * with a BLE_GAP_EVT_DISCONNECTED event.
jksoft 0:8c643bfe55b7 675 *
jksoft 0:8c643bfe55b7 676 * @param[in] conn_handle Connection handle.
jksoft 0:8c643bfe55b7 677 * @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES (accepted values are BTLE_REMOTE_USER_TERMINATED_CONNECTION and BTLE_CONN_INTERVAL_UNACCEPTABLE).
jksoft 0:8c643bfe55b7 678 *
jksoft 0:8c643bfe55b7 679 * @return @ref NRF_SUCCESS The disconnection procedure has been started successfully.
jksoft 0:8c643bfe55b7 680 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
jksoft 0:8c643bfe55b7 681 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
jksoft 0:8c643bfe55b7 682 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation (disconnection is already in progress or not connected at all).
jksoft 0:8c643bfe55b7 683 */
jksoft 0:8c643bfe55b7 684 SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code));
jksoft 0:8c643bfe55b7 685
jksoft 0:8c643bfe55b7 686
jksoft 0:8c643bfe55b7 687 /**@brief Set the radio's transmit power.
jksoft 0:8c643bfe55b7 688 *
jksoft 0:8c643bfe55b7 689 * @param[in] tx_power Radio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, and 4 dBm).
jksoft 0:8c643bfe55b7 690 *
jksoft 0:8c643bfe55b7 691 * @note -40 dBm will not actually give -40 dBm, but will instead be remapped to -30 dBm.
jksoft 0:8c643bfe55b7 692 *
jksoft 0:8c643bfe55b7 693 * @return @ref NRF_SUCCESS Successfully changed the transmit power.
jksoft 0:8c643bfe55b7 694 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
jksoft 0:8c643bfe55b7 695 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry.
jksoft 0:8c643bfe55b7 696 */
jksoft 0:8c643bfe55b7 697 SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(int8_t tx_power));
jksoft 0:8c643bfe55b7 698
jksoft 0:8c643bfe55b7 699
jksoft 0:8c643bfe55b7 700 /**@brief Set GAP Appearance value.
jksoft 0:8c643bfe55b7 701 *
jksoft 0:8c643bfe55b7 702 * @param[in] appearance Appearance (16-bit), see @ref BLE_APPEARANCES.
jksoft 0:8c643bfe55b7 703 *
jksoft 0:8c643bfe55b7 704 * @return @ref NRF_SUCCESS Appearance value set successfully.
jksoft 0:8c643bfe55b7 705 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
jksoft 0:8c643bfe55b7 706 */
jksoft 0:8c643bfe55b7 707 SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance));
jksoft 0:8c643bfe55b7 708
jksoft 0:8c643bfe55b7 709
jksoft 0:8c643bfe55b7 710 /**@brief Get GAP Appearance value.
jksoft 0:8c643bfe55b7 711 *
jksoft 0:8c643bfe55b7 712 * @param[out] p_appearance Appearance (16-bit), see @ref BLE_APPEARANCES.
jksoft 0:8c643bfe55b7 713 *
jksoft 0:8c643bfe55b7 714 * @return @ref NRF_SUCCESS Appearance value retrieved successfully.
jksoft 0:8c643bfe55b7 715 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 716 */
jksoft 0:8c643bfe55b7 717 SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t * const p_appearance));
jksoft 0:8c643bfe55b7 718
jksoft 0:8c643bfe55b7 719
jksoft 0:8c643bfe55b7 720 /**@brief Set GAP Peripheral Preferred Connection Parameters.
jksoft 0:8c643bfe55b7 721 *
jksoft 0:8c643bfe55b7 722 * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the desired parameters.
jksoft 0:8c643bfe55b7 723 *
jksoft 0:8c643bfe55b7 724 * @return @ref NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully.
jksoft 0:8c643bfe55b7 725 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 726 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
jksoft 0:8c643bfe55b7 727 */
jksoft 0:8c643bfe55b7 728 SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const * const p_conn_params));
jksoft 0:8c643bfe55b7 729
jksoft 0:8c643bfe55b7 730
jksoft 0:8c643bfe55b7 731 /**@brief Get GAP Peripheral Preferred Connection Parameters.
jksoft 0:8c643bfe55b7 732 *
jksoft 0:8c643bfe55b7 733 * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters will be stored.
jksoft 0:8c643bfe55b7 734 *
jksoft 0:8c643bfe55b7 735 * @return @ref NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully.
jksoft 0:8c643bfe55b7 736 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 737 */
jksoft 0:8c643bfe55b7 738 SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t * const p_conn_params));
jksoft 0:8c643bfe55b7 739
jksoft 0:8c643bfe55b7 740
jksoft 0:8c643bfe55b7 741 /**@brief Set GAP device name.
jksoft 0:8c643bfe55b7 742 *
jksoft 0:8c643bfe55b7 743 * @param[in] p_write_perm Write permissions for the Device Name characteristic see @ref ble_gap_conn_sec_mode_t.
jksoft 0:8c643bfe55b7 744 * @param[in] p_dev_name Pointer to a UTF-8 encoded, <b>non NULL-terminated</b> string.
jksoft 0:8c643bfe55b7 745 * @param[in] len Length of the UTF-8, <b>non NULL-terminated</b> string pointed to by p_dev_name in octets (must be smaller or equal than @ref BLE_GAP_DEVNAME_MAX_LEN).
jksoft 0:8c643bfe55b7 746 *
jksoft 0:8c643bfe55b7 747 * @return @ref NRF_SUCCESS GAP device name and permissions set successfully.
jksoft 0:8c643bfe55b7 748 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 749 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
jksoft 0:8c643bfe55b7 750 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
jksoft 0:8c643bfe55b7 751 */
jksoft 0:8c643bfe55b7 752 SVCALL(SD_BLE_GAP_DEVICE_NAME_SET, uint32_t, sd_ble_gap_device_name_set(ble_gap_conn_sec_mode_t const * const p_write_perm, uint8_t const * const p_dev_name, uint16_t len));
jksoft 0:8c643bfe55b7 753
jksoft 0:8c643bfe55b7 754
jksoft 0:8c643bfe55b7 755 /**@brief Get GAP device name.
jksoft 0:8c643bfe55b7 756 *
jksoft 0:8c643bfe55b7 757 * @param[in] p_dev_name Pointer to an empty buffer where the UTF-8 <b>non NULL-terminated</b> string will be placed. Set to NULL to obtain the complete device name length.
jksoft 0:8c643bfe55b7 758 * @param[in,out] p_len Length of the buffer pointed by p_dev_name, complete device name length on output.
jksoft 0:8c643bfe55b7 759 *
jksoft 0:8c643bfe55b7 760 * @note If the device name is longer than the size of the supplied buffer,
jksoft 0:8c643bfe55b7 761 * p_len will return the complete device name length,
jksoft 0:8c643bfe55b7 762 * and not the number of bytes actually returned in p_dev_name.
jksoft 0:8c643bfe55b7 763 * The application may use this information to allocate a suitable buffer size.
jksoft 0:8c643bfe55b7 764 *
jksoft 0:8c643bfe55b7 765 * @return @ref NRF_SUCCESS GAP device name retrieved successfully.
jksoft 0:8c643bfe55b7 766 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 767 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
jksoft 0:8c643bfe55b7 768 */
jksoft 0:8c643bfe55b7 769 SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t * const p_dev_name, uint16_t * const p_len));
jksoft 0:8c643bfe55b7 770
jksoft 0:8c643bfe55b7 771
jksoft 0:8c643bfe55b7 772 /**@brief Initiate GAP Authentication procedure.
jksoft 0:8c643bfe55b7 773 *
jksoft 0:8c643bfe55b7 774 * @param[in] conn_handle Connection handle.
jksoft 0:8c643bfe55b7 775 * @param[in] p_sec_params Pointer to the @ref ble_gap_sec_params_t structure with the security parameters to be used during the pairing procedure.
jksoft 0:8c643bfe55b7 776 *
jksoft 0:8c643bfe55b7 777 * @details In the central role, this function will send an SMP Pairing Request, otherwise in the peripheral role, an SMP Security Request will be sent.
jksoft 0:8c643bfe55b7 778 * In the peripheral role, only the timeout, bond and mitm fields of @ref ble_gap_sec_params_t are used.
jksoft 0:8c643bfe55b7 779 *
jksoft 0:8c643bfe55b7 780 * @note The GAP Authentication procedure may be triggered by the central without calling this function when accessing a secure service.
jksoft 0:8c643bfe55b7 781 * @note Calling this function may result in the following events depending on the outcome and parameters: @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST,
jksoft 0:8c643bfe55b7 782 * @ref BLE_GAP_EVT_SEC_INFO_REQUEST, @ref BLE_GAP_EVT_AUTH_KEY_REQUEST, @ref BLE_GAP_EVT_AUTH_STATUS.
jksoft 0:8c643bfe55b7 783 * @note The timeout parameter in @ref ble_gap_sec_params_t is interpreted here as the Security Request timeout
jksoft 0:8c643bfe55b7 784 *
jksoft 0:8c643bfe55b7 785 *
jksoft 0:8c643bfe55b7 786 * @return @ref NRF_SUCCESS Successfully initiated authentication procedure.
jksoft 0:8c643bfe55b7 787 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 788 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
jksoft 0:8c643bfe55b7 789 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
jksoft 0:8c643bfe55b7 790 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
jksoft 0:8c643bfe55b7 791 */
jksoft 0:8c643bfe55b7 792 SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const * const p_sec_params));
jksoft 0:8c643bfe55b7 793
jksoft 0:8c643bfe55b7 794
jksoft 0:8c643bfe55b7 795 /**@brief Reply with GAP security parameters.
jksoft 0:8c643bfe55b7 796 *
jksoft 0:8c643bfe55b7 797 * @param[in] conn_handle Connection handle.
jksoft 0:8c643bfe55b7 798 * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS.
jksoft 0:8c643bfe55b7 799 * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure.
jksoft 0:8c643bfe55b7 800 *
jksoft 0:8c643bfe55b7 801 * @details This function is only used to reply to a @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST, calling it at other times will result in an NRF_ERROR_INVALID_STATE.
jksoft 0:8c643bfe55b7 802 * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
jksoft 0:8c643bfe55b7 803 * @note The timeout parameter in @ref ble_gap_sec_params_t is interpreted here as the SMP procedure timeout, and must be 30 seconds. The function will fail
jksoft 0:8c643bfe55b7 804 * if the application supplies a different value.
jksoft 0:8c643bfe55b7 805 *
jksoft 0:8c643bfe55b7 806 * @return @ref NRF_SUCCESS Successfully accepted security parameter from the application.
jksoft 0:8c643bfe55b7 807 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 808 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
jksoft 0:8c643bfe55b7 809 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
jksoft 0:8c643bfe55b7 810 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
jksoft 0:8c643bfe55b7 811 */
jksoft 0:8c643bfe55b7 812 SVCALL(SD_BLE_GAP_SEC_PARAMS_REPLY, uint32_t, sd_ble_gap_sec_params_reply(uint16_t conn_handle, uint8_t sec_status, ble_gap_sec_params_t const * const p_sec_params));
jksoft 0:8c643bfe55b7 813
jksoft 0:8c643bfe55b7 814
jksoft 0:8c643bfe55b7 815 /**@brief Reply with an authentication key.
jksoft 0:8c643bfe55b7 816 *
jksoft 0:8c643bfe55b7 817 * @param[in] conn_handle Connection handle.
jksoft 0:8c643bfe55b7 818 * @param[in] key_type See @ref BLE_GAP_AUTH_KEY_TYPES.
jksoft 0:8c643bfe55b7 819 * @param[in] key If key type is BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL.
jksoft 0:8c643bfe55b7 820 * If key type is BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination).
jksoft 0:8c643bfe55b7 821 * If key type is BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in Little Endian format.
jksoft 0:8c643bfe55b7 822 *
jksoft 0:8c643bfe55b7 823 * @details This function is only used to reply to a @ref BLE_GAP_EVT_AUTH_KEY_REQUEST, calling it at other times will result in an NRF_ERROR_INVALID_STATE.
jksoft 0:8c643bfe55b7 824 * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
jksoft 0:8c643bfe55b7 825 *
jksoft 0:8c643bfe55b7 826 * @return @ref NRF_SUCCESS Authentication key successfully set.
jksoft 0:8c643bfe55b7 827 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 828 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
jksoft 0:8c643bfe55b7 829 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
jksoft 0:8c643bfe55b7 830 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
jksoft 0:8c643bfe55b7 831 */
jksoft 0:8c643bfe55b7 832 SVCALL(SD_BLE_GAP_AUTH_KEY_REPLY, uint32_t, sd_ble_gap_auth_key_reply(uint16_t conn_handle, uint8_t key_type, uint8_t const * const key));
jksoft 0:8c643bfe55b7 833
jksoft 0:8c643bfe55b7 834
jksoft 0:8c643bfe55b7 835 /**@brief Reply with GAP security information.
jksoft 0:8c643bfe55b7 836 *
jksoft 0:8c643bfe55b7 837 * @param[in] conn_handle Connection handle.
jksoft 0:8c643bfe55b7 838 * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure. May be NULL to signal none is available.
jksoft 0:8c643bfe55b7 839 * @param[in] p_sign_info Pointer to a @ref ble_gap_sign_info_t signing information structure. May be NULL to signal none is available.
jksoft 0:8c643bfe55b7 840 *
jksoft 0:8c643bfe55b7 841 * @details This function is only used to reply to a @ref BLE_GAP_EVT_SEC_INFO_REQUEST, calling it at other times will result in NRF_ERROR_INVALID_STATE.
jksoft 0:8c643bfe55b7 842 * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
jksoft 0:8c643bfe55b7 843 * @note Data signing is not implemented yet. p_sign_info must therefore be NULL.
jksoft 0:8c643bfe55b7 844 *
jksoft 0:8c643bfe55b7 845 * @return @ref NRF_SUCCESS Successfully accepted security information.
jksoft 0:8c643bfe55b7 846 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
jksoft 0:8c643bfe55b7 847 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
jksoft 0:8c643bfe55b7 848 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
jksoft 0:8c643bfe55b7 849 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry.
jksoft 0:8c643bfe55b7 850 */
jksoft 0:8c643bfe55b7 851 SVCALL(SD_BLE_GAP_SEC_INFO_REPLY, uint32_t, sd_ble_gap_sec_info_reply(uint16_t conn_handle, ble_gap_enc_info_t const * const p_enc_info, ble_gap_sign_info_t const * const p_sign_info));
jksoft 0:8c643bfe55b7 852
jksoft 0:8c643bfe55b7 853
jksoft 0:8c643bfe55b7 854 /**@brief Get the current connection security.
jksoft 0:8c643bfe55b7 855 *
jksoft 0:8c643bfe55b7 856 * @param[in] conn_handle Connection handle.
jksoft 0:8c643bfe55b7 857 * @param[out] p_conn_sec Pointer to a @ref ble_gap_conn_sec_t structure to be filled in.
jksoft 0:8c643bfe55b7 858 *
jksoft 0:8c643bfe55b7 859 * @return @ref NRF_SUCCESS Current connection security successfully retrieved.
jksoft 0:8c643bfe55b7 860 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
jksoft 0:8c643bfe55b7 861 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
jksoft 0:8c643bfe55b7 862 */
jksoft 0:8c643bfe55b7 863 SVCALL(SD_BLE_GAP_CONN_SEC_GET, uint32_t, sd_ble_gap_conn_sec_get(uint16_t conn_handle, ble_gap_conn_sec_t * const p_conn_sec));
jksoft 0:8c643bfe55b7 864
jksoft 0:8c643bfe55b7 865
jksoft 0:8c643bfe55b7 866 /**@brief Start reporting the received signal strength to the application.
jksoft 0:8c643bfe55b7 867 *
jksoft 0:8c643bfe55b7 868 * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called.
jksoft 0:8c643bfe55b7 869 *
jksoft 0:8c643bfe55b7 870 * @param[in] conn_handle Connection handle.
jksoft 0:8c643bfe55b7 871 *
jksoft 0:8c643bfe55b7 872 * @return @ref NRF_SUCCESS Successfully activated RSSI reporting.
jksoft 0:8c643bfe55b7 873 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
jksoft 0:8c643bfe55b7 874 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
jksoft 0:8c643bfe55b7 875 */
jksoft 0:8c643bfe55b7 876 SVCALL(SD_BLE_GAP_RSSI_START, uint32_t, sd_ble_gap_rssi_start(uint16_t conn_handle));
jksoft 0:8c643bfe55b7 877
jksoft 0:8c643bfe55b7 878
jksoft 0:8c643bfe55b7 879 /**@brief Stop reporting the received singnal strength.
jksoft 0:8c643bfe55b7 880 *
jksoft 0:8c643bfe55b7 881 * An RSSI change detected before the call but not yet received by the application
jksoft 0:8c643bfe55b7 882 * may be reported after @ref sd_ble_gap_rssi_stop has been called.
jksoft 0:8c643bfe55b7 883 *
jksoft 0:8c643bfe55b7 884 * @param[in] conn_handle Connection handle.
jksoft 0:8c643bfe55b7 885 *
jksoft 0:8c643bfe55b7 886 * @return @ref NRF_SUCCESS Successfully deactivated RSSI reporting.
jksoft 0:8c643bfe55b7 887 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
jksoft 0:8c643bfe55b7 888 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
jksoft 0:8c643bfe55b7 889 */
jksoft 0:8c643bfe55b7 890 SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle));
jksoft 0:8c643bfe55b7 891
jksoft 0:8c643bfe55b7 892 #endif // BLE_GAP_H__
jksoft 0:8c643bfe55b7 893
jksoft 0:8c643bfe55b7 894 /**
jksoft 0:8c643bfe55b7 895 @}
jksoft 0:8c643bfe55b7 896 */