meh

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Fri Aug 15 15:28:31 2014 +0100
Revision:
88:9327015d4013
Parent:
TARGET_HRM1017/TARGET_NORDIC/TARGET_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_API/include/ble_l2cap.h@87:6213f644d804
Release 88 of the mbed library

Main changes:

- changed "error.h" to "mbed_error.h" to avoid conflicts with 3rd party code
- LPC1549 SPI driver fixes
- K64F Ethernet TX buffer reclaim mechanism fix
- STDIO initialization fix
- NUCLEO_F334R8 I2C clock fix
- various other fixes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 87:6213f644d804 1 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
bogdanm 87:6213f644d804 2 *
bogdanm 87:6213f644d804 3 * The information contained herein is confidential property of Nordic Semiconductor. The use,
bogdanm 87:6213f644d804 4 * copying, transfer or disclosure of such information is prohibited except by express written
bogdanm 87:6213f644d804 5 * agreement with Nordic Semiconductor.
bogdanm 87:6213f644d804 6 *
bogdanm 87:6213f644d804 7 */
bogdanm 87:6213f644d804 8 /**
bogdanm 87:6213f644d804 9 @addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP)
bogdanm 87:6213f644d804 10 @{
bogdanm 87:6213f644d804 11 @brief Definitions and prototypes for the L2CAP interface.
bogdanm 87:6213f644d804 12 */
bogdanm 87:6213f644d804 13
bogdanm 87:6213f644d804 14 #ifndef BLE_L2CAP_H__
bogdanm 87:6213f644d804 15 #define BLE_L2CAP_H__
bogdanm 87:6213f644d804 16
bogdanm 87:6213f644d804 17 #include "ble_types.h"
bogdanm 87:6213f644d804 18 #include "ble_ranges.h"
bogdanm 87:6213f644d804 19 #include "ble_err.h"
bogdanm 87:6213f644d804 20 #include "nrf_svc.h"
bogdanm 87:6213f644d804 21
bogdanm 87:6213f644d804 22 /**@addtogroup BLE_L2CAP_ENUMERATIONS Enumerations
bogdanm 87:6213f644d804 23 * @{ */
bogdanm 87:6213f644d804 24
bogdanm 87:6213f644d804 25 /**@brief L2CAP API SVC numbers. */
bogdanm 87:6213f644d804 26 enum BLE_L2CAP_SVCS
bogdanm 87:6213f644d804 27 {
bogdanm 87:6213f644d804 28 SD_BLE_L2CAP_CID_REGISTER = BLE_L2CAP_SVC_BASE, /**< Register a CID. */
bogdanm 87:6213f644d804 29 SD_BLE_L2CAP_CID_UNREGISTER, /**< Unregister a CID. */
bogdanm 87:6213f644d804 30 SD_BLE_L2CAP_TX /**< Transmit a packet. */
bogdanm 87:6213f644d804 31 };
bogdanm 87:6213f644d804 32
bogdanm 87:6213f644d804 33 /** @} */
bogdanm 87:6213f644d804 34
bogdanm 87:6213f644d804 35 /**@addtogroup BLE_L2CAP_DEFINES Defines
bogdanm 87:6213f644d804 36 * @{ */
bogdanm 87:6213f644d804 37
bogdanm 87:6213f644d804 38 /**@defgroup BLE_ERRORS_L2CAP SVC return values specific to L2CAP
bogdanm 87:6213f644d804 39 * @{ */
bogdanm 87:6213f644d804 40 #define BLE_ERROR_L2CAP_CID_IN_USE (NRF_L2CAP_ERR_BASE + 0x000) /**< CID already in use. */
bogdanm 87:6213f644d804 41 /** @} */
bogdanm 87:6213f644d804 42
bogdanm 87:6213f644d804 43 /**@brief Default L2CAP MTU. */
bogdanm 87:6213f644d804 44 #define BLE_L2CAP_MTU_DEF (23)
bogdanm 87:6213f644d804 45
bogdanm 87:6213f644d804 46 /**@brief Invalid Channel Identifier. */
bogdanm 87:6213f644d804 47 #define BLE_L2CAP_CID_INVALID (0x0000)
bogdanm 87:6213f644d804 48
bogdanm 87:6213f644d804 49 /**@brief Dynamic Channel Identifier base. */
bogdanm 87:6213f644d804 50 #define BLE_L2CAP_CID_DYN_BASE (0x0040)
bogdanm 87:6213f644d804 51
bogdanm 87:6213f644d804 52 /**@brief Maximum amount of dynamic CIDs. */
bogdanm 87:6213f644d804 53 #define BLE_L2CAP_CID_DYN_MAX (8)
bogdanm 87:6213f644d804 54
bogdanm 87:6213f644d804 55 /** @} */
bogdanm 87:6213f644d804 56
bogdanm 87:6213f644d804 57 /**@addtogroup BLE_L2CAP_STRUCTURES Structures
bogdanm 87:6213f644d804 58 * @{ */
bogdanm 87:6213f644d804 59
bogdanm 87:6213f644d804 60 /**@brief Packet header format for L2CAP transmission. */
bogdanm 87:6213f644d804 61 typedef struct
bogdanm 87:6213f644d804 62 {
bogdanm 87:6213f644d804 63 uint16_t len; /**< Length of valid info in data member. */
bogdanm 87:6213f644d804 64 uint16_t cid; /**< Channel ID on which packet is transmitted. */
bogdanm 87:6213f644d804 65 } ble_l2cap_header_t;
bogdanm 87:6213f644d804 66
bogdanm 87:6213f644d804 67 /**@brief L2CAP Event IDs. */
bogdanm 87:6213f644d804 68 enum BLE_L2CAP_EVTS
bogdanm 87:6213f644d804 69 {
bogdanm 87:6213f644d804 70 BLE_L2CAP_EVT_RX = BLE_L2CAP_EVT_BASE /**< L2CAP packet received. */
bogdanm 87:6213f644d804 71 };
bogdanm 87:6213f644d804 72
bogdanm 87:6213f644d804 73
bogdanm 87:6213f644d804 74 /**@brief L2CAP Received packet event report. */
bogdanm 87:6213f644d804 75 typedef struct
bogdanm 87:6213f644d804 76 {
bogdanm 87:6213f644d804 77 ble_l2cap_header_t header; /** L2CAP packet header. */
bogdanm 87:6213f644d804 78 uint8_t data[1]; /**< Packet data, variable length. */
bogdanm 87:6213f644d804 79 } ble_l2cap_evt_rx_t;
bogdanm 87:6213f644d804 80
bogdanm 87:6213f644d804 81
bogdanm 87:6213f644d804 82 /**@brief L2CAP event callback event structure. */
bogdanm 87:6213f644d804 83 typedef struct
bogdanm 87:6213f644d804 84 {
bogdanm 87:6213f644d804 85 uint16_t conn_handle; /**< Connection Handle on which event occured. */
bogdanm 87:6213f644d804 86 union
bogdanm 87:6213f644d804 87 {
bogdanm 87:6213f644d804 88 ble_l2cap_evt_rx_t rx; /**< RX Event parameters. */
bogdanm 87:6213f644d804 89 } params;
bogdanm 87:6213f644d804 90 } ble_l2cap_evt_t;
bogdanm 87:6213f644d804 91
bogdanm 87:6213f644d804 92
bogdanm 87:6213f644d804 93 /**@brief Register a CID with L2CAP.
bogdanm 87:6213f644d804 94 *
bogdanm 87:6213f644d804 95 * @details This registers a higher protocol layer with the L2CAP multiplexer, and is requried prior to all operations on the CID.
bogdanm 87:6213f644d804 96 *
bogdanm 87:6213f644d804 97 * @param[in] cid L2CAP CID.
bogdanm 87:6213f644d804 98 *
bogdanm 87:6213f644d804 99 * @return @ref NRF_SUCCESS Successfully registered a CID with the L2CAP layer.
bogdanm 87:6213f644d804 100 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CID must be above @ref BLE_L2CAP_CID_DYN_BASE.
bogdanm 87:6213f644d804 101 * @return @ref BLE_ERROR_L2CAP_CID_IN_USE L2CAP CID already in use.
bogdanm 87:6213f644d804 102 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
bogdanm 87:6213f644d804 103 */
bogdanm 87:6213f644d804 104 SVCALL(SD_BLE_L2CAP_CID_REGISTER, uint32_t, sd_ble_l2cap_cid_register(uint16_t cid));
bogdanm 87:6213f644d804 105
bogdanm 87:6213f644d804 106 /**@brief Unregister a CID with L2CAP.
bogdanm 87:6213f644d804 107 *
bogdanm 87:6213f644d804 108 * @details This unregisters a previously registerd higher protocol layer with the L2CAP multiplexer.
bogdanm 87:6213f644d804 109 *
bogdanm 87:6213f644d804 110 * @param[in] cid L2CAP CID.
bogdanm 87:6213f644d804 111 *
bogdanm 87:6213f644d804 112 * @return @ref NRF_SUCCESS Successfully unregistered the CID.
bogdanm 87:6213f644d804 113 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
bogdanm 87:6213f644d804 114 * @return @ref NRF_ERROR_NOT_FOUND CID not previously registered.
bogdanm 87:6213f644d804 115 */
bogdanm 87:6213f644d804 116 SVCALL(SD_BLE_L2CAP_CID_UNREGISTER, uint32_t, sd_ble_l2cap_cid_unregister(uint16_t cid));
bogdanm 87:6213f644d804 117
bogdanm 87:6213f644d804 118 /**@brief Transmit an L2CAP packet.
bogdanm 87:6213f644d804 119 *
bogdanm 87:6213f644d804 120 * @note It is important to note that a call to this function will <b>consume an application buffer</b>, and will therefore
bogdanm 87:6213f644d804 121 * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted.
bogdanm 87:6213f644d804 122 * Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details.
bogdanm 87:6213f644d804 123 *
bogdanm 87:6213f644d804 124 * @param[in] conn_handle Connection Handle.
bogdanm 87:6213f644d804 125 * @param[in] p_header Pointer to a packet header containing length and CID.
bogdanm 87:6213f644d804 126 * @param[in] p_data Pointer to the data to be transmitted.
bogdanm 87:6213f644d804 127 *
bogdanm 87:6213f644d804 128 * @return @ref NRF_SUCCESS Successfully queued an L2CAP packet for transmission.
bogdanm 87:6213f644d804 129 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
bogdanm 87:6213f644d804 130 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CIDs must be registered beforehand with @ref sd_ble_l2cap_cid_register.
bogdanm 87:6213f644d804 131 * @return @ref NRF_ERROR_NOT_FOUND CID not found.
bogdanm 87:6213f644d804 132 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
bogdanm 87:6213f644d804 133 * @return @ref BLE_ERROR_NO_TX_BUFFERS Not enough application buffers available.
bogdanm 87:6213f644d804 134 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, see @ref BLE_L2CAP_MTU_DEF.
bogdanm 87:6213f644d804 135 */
bogdanm 87:6213f644d804 136 SVCALL(SD_BLE_L2CAP_TX, uint32_t, sd_ble_l2cap_tx(uint16_t conn_handle, ble_l2cap_header_t const * const p_header, uint8_t const * const p_data));
bogdanm 87:6213f644d804 137
bogdanm 87:6213f644d804 138 /** @} */
bogdanm 87:6213f644d804 139
bogdanm 87:6213f644d804 140 #endif // BLE_L2CAP_H__
bogdanm 87:6213f644d804 141
bogdanm 87:6213f644d804 142 /**
bogdanm 87:6213f644d804 143 @}
bogdanm 87:6213f644d804 144 */