The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_NRF51_DONGLE/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/sdk/softdevice/s130/headers/nrf_ble_l2cap.h@169:a7c7b631e539
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 148:fd96258d940d 1 /*
Kojto 148:fd96258d940d 2 * Copyright (c) 2000 Nordic Semiconductor ASA
Kojto 148:fd96258d940d 3 * All rights reserved.
Kojto 148:fd96258d940d 4 *
Kojto 148:fd96258d940d 5 * Redistribution and use in source and binary forms, with or without modification,
Kojto 148:fd96258d940d 6 * are permitted provided that the following conditions are met:
Kojto 148:fd96258d940d 7 *
Kojto 148:fd96258d940d 8 * 1. Redistributions of source code must retain the above copyright notice, this list
Kojto 148:fd96258d940d 9 * of conditions and the following disclaimer.
Kojto 148:fd96258d940d 10 *
Kojto 148:fd96258d940d 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
Kojto 148:fd96258d940d 12 * integrated circuit in a product or a software update for such product, must reproduce
Kojto 148:fd96258d940d 13 * the above copyright notice, this list of conditions and the following disclaimer in
Kojto 148:fd96258d940d 14 * the documentation and/or other materials provided with the distribution.
Kojto 148:fd96258d940d 15 *
Kojto 148:fd96258d940d 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
Kojto 148:fd96258d940d 17 * used to endorse or promote products derived from this software without specific prior
Kojto 148:fd96258d940d 18 * written permission.
Kojto 148:fd96258d940d 19 *
Kojto 148:fd96258d940d 20 * 4. This software, with or without modification, must only be used with a
Kojto 148:fd96258d940d 21 * Nordic Semiconductor ASA integrated circuit.
Kojto 148:fd96258d940d 22 *
Kojto 148:fd96258d940d 23 * 5. Any software provided in binary or object form under this license must not be reverse
Kojto 148:fd96258d940d 24 * engineered, decompiled, modified and/or disassembled.
Kojto 148:fd96258d940d 25 *
Kojto 148:fd96258d940d 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Kojto 148:fd96258d940d 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Kojto 148:fd96258d940d 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 148:fd96258d940d 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Kojto 148:fd96258d940d 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Kojto 148:fd96258d940d 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Kojto 148:fd96258d940d 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Kojto 148:fd96258d940d 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Kojto 148:fd96258d940d 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Kojto 148:fd96258d940d 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 148:fd96258d940d 36 *
Kojto 148:fd96258d940d 37 */
Kojto 148:fd96258d940d 38
Kojto 148:fd96258d940d 39
Kojto 148:fd96258d940d 40 /**
Kojto 148:fd96258d940d 41 @addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP)
Kojto 148:fd96258d940d 42 @{
Kojto 148:fd96258d940d 43 @brief Definitions and prototypes for the L2CAP interface.
Kojto 148:fd96258d940d 44 */
Kojto 148:fd96258d940d 45
Kojto 148:fd96258d940d 46 #ifndef NRF_BLE_L2CAP_H__
Kojto 148:fd96258d940d 47 #define NRF_BLE_L2CAP_H__
Kojto 148:fd96258d940d 48
Kojto 148:fd96258d940d 49 #include "nrf_ble_types.h"
Kojto 148:fd96258d940d 50 #include "nrf_ble_ranges.h"
Kojto 148:fd96258d940d 51 #include "nrf_ble_err.h"
Kojto 148:fd96258d940d 52 #include "nrf_svc.h"
Kojto 148:fd96258d940d 53
Kojto 148:fd96258d940d 54 #ifdef __cplusplus
Kojto 148:fd96258d940d 55 extern "C" {
Kojto 148:fd96258d940d 56 #endif
Kojto 148:fd96258d940d 57
Kojto 148:fd96258d940d 58 /**@addtogroup BLE_L2CAP_ENUMERATIONS Enumerations
Kojto 148:fd96258d940d 59 * @{ */
Kojto 148:fd96258d940d 60
Kojto 148:fd96258d940d 61 /**@brief L2CAP API SVC numbers. */
Kojto 148:fd96258d940d 62 enum BLE_L2CAP_SVCS
Kojto 148:fd96258d940d 63 {
Kojto 148:fd96258d940d 64 SD_BLE_L2CAP_CID_REGISTER = BLE_L2CAP_SVC_BASE, /**< Register a CID. */
Kojto 148:fd96258d940d 65 SD_BLE_L2CAP_CID_UNREGISTER, /**< Unregister a CID. */
Kojto 148:fd96258d940d 66 SD_BLE_L2CAP_TX /**< Transmit a packet. */
Kojto 148:fd96258d940d 67 };
Kojto 148:fd96258d940d 68
Kojto 148:fd96258d940d 69 /**@brief L2CAP Event IDs. */
Kojto 148:fd96258d940d 70 enum BLE_L2CAP_EVTS
Kojto 148:fd96258d940d 71 {
Kojto 148:fd96258d940d 72 BLE_L2CAP_EVT_RX = BLE_L2CAP_EVT_BASE /**< L2CAP packet received. */
Kojto 148:fd96258d940d 73 };
Kojto 148:fd96258d940d 74
Kojto 148:fd96258d940d 75 /** @} */
Kojto 148:fd96258d940d 76
Kojto 148:fd96258d940d 77 /**@addtogroup BLE_L2CAP_DEFINES Defines
Kojto 148:fd96258d940d 78 * @{ */
Kojto 148:fd96258d940d 79
Kojto 148:fd96258d940d 80 /**@defgroup BLE_ERRORS_L2CAP SVC return values specific to L2CAP
Kojto 148:fd96258d940d 81 * @{ */
Kojto 148:fd96258d940d 82 #define BLE_ERROR_L2CAP_CID_IN_USE (NRF_L2CAP_ERR_BASE + 0x000) /**< CID already in use. */
Kojto 148:fd96258d940d 83 /** @} */
Kojto 148:fd96258d940d 84
Kojto 148:fd96258d940d 85 /**@brief Default L2CAP MTU. */
Kojto 148:fd96258d940d 86 #define BLE_L2CAP_MTU_DEF (23)
Kojto 148:fd96258d940d 87
Kojto 148:fd96258d940d 88 /**@brief Invalid Channel Identifier. */
Kojto 148:fd96258d940d 89 #define BLE_L2CAP_CID_INVALID (0x0000)
Kojto 148:fd96258d940d 90
Kojto 148:fd96258d940d 91 /**@brief Dynamic Channel Identifier base. */
Kojto 148:fd96258d940d 92 #define BLE_L2CAP_CID_DYN_BASE (0x0040)
Kojto 148:fd96258d940d 93
Kojto 148:fd96258d940d 94 /**@brief Maximum amount of dynamic CIDs. */
Kojto 148:fd96258d940d 95 #define BLE_L2CAP_CID_DYN_MAX (8)
Kojto 148:fd96258d940d 96
Kojto 148:fd96258d940d 97 /** @} */
Kojto 148:fd96258d940d 98
Kojto 148:fd96258d940d 99 /**@addtogroup BLE_L2CAP_STRUCTURES Structures
Kojto 148:fd96258d940d 100 * @{ */
Kojto 148:fd96258d940d 101
Kojto 148:fd96258d940d 102 /**@brief Packet header format for L2CAP transmission. */
Kojto 148:fd96258d940d 103 typedef struct
Kojto 148:fd96258d940d 104 {
Kojto 148:fd96258d940d 105 uint16_t len; /**< Length of valid info in data member. */
Kojto 148:fd96258d940d 106 uint16_t cid; /**< Channel ID on which packet is transmitted. */
Kojto 148:fd96258d940d 107 } ble_l2cap_header_t;
Kojto 148:fd96258d940d 108
Kojto 148:fd96258d940d 109
Kojto 148:fd96258d940d 110 /**@brief L2CAP Received packet event report. */
Kojto 148:fd96258d940d 111 typedef struct
Kojto 148:fd96258d940d 112 {
Kojto 148:fd96258d940d 113 ble_l2cap_header_t header; /**< L2CAP packet header. */
Kojto 148:fd96258d940d 114 uint8_t data[1]; /**< Packet data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
Kojto 148:fd96258d940d 115 See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
Kojto 148:fd96258d940d 116 } ble_l2cap_evt_rx_t;
Kojto 148:fd96258d940d 117
Kojto 148:fd96258d940d 118
Kojto 148:fd96258d940d 119 /**@brief L2CAP event callback event structure. */
Kojto 148:fd96258d940d 120 typedef struct
Kojto 148:fd96258d940d 121 {
Kojto 148:fd96258d940d 122 uint16_t conn_handle; /**< Connection Handle on which event occured. */
Kojto 148:fd96258d940d 123 union
Kojto 148:fd96258d940d 124 {
Kojto 148:fd96258d940d 125 ble_l2cap_evt_rx_t rx; /**< RX Event parameters. */
Kojto 148:fd96258d940d 126 } params; /**< Event Parameters. */
Kojto 148:fd96258d940d 127 } ble_l2cap_evt_t;
Kojto 148:fd96258d940d 128
Kojto 148:fd96258d940d 129 /** @} */
Kojto 148:fd96258d940d 130
Kojto 148:fd96258d940d 131 /**@addtogroup BLE_L2CAP_FUNCTIONS Functions
Kojto 148:fd96258d940d 132 * @{ */
Kojto 148:fd96258d940d 133
Kojto 148:fd96258d940d 134 /**@brief Register a CID with L2CAP.
Kojto 148:fd96258d940d 135 *
Kojto 148:fd96258d940d 136 * @details This registers a higher protocol layer with the L2CAP multiplexer, and is requried prior to all operations on the CID.
Kojto 148:fd96258d940d 137 *
Kojto 148:fd96258d940d 138 * @mscs
Kojto 148:fd96258d940d 139 * @mmsc{@ref BLE_L2CAP_API_MSC}
Kojto 148:fd96258d940d 140 * @endmscs
Kojto 148:fd96258d940d 141 *
Kojto 148:fd96258d940d 142 * @param[in] cid L2CAP CID.
Kojto 148:fd96258d940d 143 *
Kojto 148:fd96258d940d 144 * @retval ::NRF_SUCCESS Successfully registered a CID with the L2CAP layer.
Kojto 148:fd96258d940d 145 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CID must be above @ref BLE_L2CAP_CID_DYN_BASE.
Kojto 148:fd96258d940d 146 * @retval ::BLE_ERROR_L2CAP_CID_IN_USE L2CAP CID already in use.
Kojto 148:fd96258d940d 147 * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
Kojto 148:fd96258d940d 148 */
Kojto 148:fd96258d940d 149 SVCALL(SD_BLE_L2CAP_CID_REGISTER, uint32_t, sd_ble_l2cap_cid_register(uint16_t cid));
Kojto 148:fd96258d940d 150
Kojto 148:fd96258d940d 151 /**@brief Unregister a CID with L2CAP.
Kojto 148:fd96258d940d 152 *
Kojto 148:fd96258d940d 153 * @details This unregisters a previously registerd higher protocol layer with the L2CAP multiplexer.
Kojto 148:fd96258d940d 154 *
Kojto 148:fd96258d940d 155 * @mscs
Kojto 148:fd96258d940d 156 * @mmsc{@ref BLE_L2CAP_API_MSC}
Kojto 148:fd96258d940d 157 * @endmscs
Kojto 148:fd96258d940d 158 *
Kojto 148:fd96258d940d 159 * @param[in] cid L2CAP CID.
Kojto 148:fd96258d940d 160 *
Kojto 148:fd96258d940d 161 * @retval ::NRF_SUCCESS Successfully unregistered the CID.
Kojto 148:fd96258d940d 162 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
Kojto 148:fd96258d940d 163 * @retval ::NRF_ERROR_NOT_FOUND CID not previously registered.
Kojto 148:fd96258d940d 164 */
Kojto 148:fd96258d940d 165 SVCALL(SD_BLE_L2CAP_CID_UNREGISTER, uint32_t, sd_ble_l2cap_cid_unregister(uint16_t cid));
Kojto 148:fd96258d940d 166
Kojto 148:fd96258d940d 167 /**@brief Transmit an L2CAP packet.
Kojto 148:fd96258d940d 168 *
Kojto 148:fd96258d940d 169 * @note It is important to note that a call to this function will <b>consume an application packet</b>, and will therefore
Kojto 148:fd96258d940d 170 * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted.
Kojto 148:fd96258d940d 171 * Please see the documentation of @ref sd_ble_tx_packet_count_get for more details.
Kojto 148:fd96258d940d 172 *
Kojto 148:fd96258d940d 173 * @events
Kojto 148:fd96258d940d 174 * @event{@ref BLE_EVT_TX_COMPLETE}
Kojto 148:fd96258d940d 175 * @event{@ref BLE_L2CAP_EVT_RX}
Kojto 148:fd96258d940d 176 * @endevents
Kojto 148:fd96258d940d 177 *
Kojto 148:fd96258d940d 178 * @mscs
Kojto 148:fd96258d940d 179 * @mmsc{@ref BLE_L2CAP_API_MSC}
Kojto 148:fd96258d940d 180 * @endmscs
Kojto 148:fd96258d940d 181 *
Kojto 148:fd96258d940d 182 * @param[in] conn_handle Connection Handle.
Kojto 148:fd96258d940d 183 * @param[in] p_header Pointer to a packet header containing length and CID.
Kojto 148:fd96258d940d 184 * @param[in] p_data Pointer to the data to be transmitted.
Kojto 148:fd96258d940d 185 *
Kojto 148:fd96258d940d 186 * @retval ::NRF_SUCCESS Successfully queued an L2CAP packet for transmission.
Kojto 148:fd96258d940d 187 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
Kojto 148:fd96258d940d 188 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CIDs must be registered beforehand with @ref sd_ble_l2cap_cid_register.
Kojto 148:fd96258d940d 189 * @retval ::NRF_ERROR_NOT_FOUND CID not found.
Kojto 148:fd96258d940d 190 * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
Kojto 148:fd96258d940d 191 * @retval ::BLE_ERROR_NO_TX_PACKETS Not enough application packets available.
Kojto 148:fd96258d940d 192 * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, see @ref BLE_L2CAP_MTU_DEF.
Kojto 148:fd96258d940d 193 */
Kojto 148:fd96258d940d 194 SVCALL(SD_BLE_L2CAP_TX, uint32_t, sd_ble_l2cap_tx(uint16_t conn_handle, ble_l2cap_header_t const *p_header, uint8_t const *p_data));
Kojto 148:fd96258d940d 195
Kojto 148:fd96258d940d 196 /** @} */
Kojto 148:fd96258d940d 197
Kojto 148:fd96258d940d 198 #ifdef __cplusplus
Kojto 148:fd96258d940d 199 }
Kojto 148:fd96258d940d 200 #endif
Kojto 148:fd96258d940d 201 #endif // NRF_BLE_L2CAP_H__
Kojto 148:fd96258d940d 202
Kojto 148:fd96258d940d 203 /**
Kojto 148:fd96258d940d 204 @}
Kojto 148:fd96258d940d 205 */