BLE temperature profile using digital DS1820 or analog LM35 sensors
Embed:
(wiki syntax)
Show/hide line numbers
ble_l2cap.h
00001 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. 00002 * 00003 * The information contained herein is confidential property of Nordic Semiconductor. The use, 00004 * copying, transfer or disclosure of such information is prohibited except by express written 00005 * agreement with Nordic Semiconductor. 00006 * 00007 */ 00008 /** 00009 @addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP) 00010 @{ 00011 @brief Definitions and prototypes for the L2CAP interface. 00012 */ 00013 00014 #ifndef BLE_L2CAP_H__ 00015 #define BLE_L2CAP_H__ 00016 00017 #include "nordic_global.h" 00018 #include "ble_types.h" 00019 #include "ble_ranges.h" 00020 #include "ble_err.h" 00021 #include "nrf_svc.h" 00022 00023 /**@brief L2CAP API SVC numbers. */ 00024 enum BLE_L2CAP_SVCS 00025 { 00026 SD_BLE_L2CAP_CID_REGISTER = BLE_L2CAP_SVC_BASE, /**< Register a CID. */ 00027 SD_BLE_L2CAP_CID_UNREGISTER, /**< Unregister a CID. */ 00028 SD_BLE_L2CAP_TX /**< Transmit a packet. */ 00029 }; 00030 00031 /**@addtogroup BLE_L2CAP_DEFINES Defines 00032 * @{ */ 00033 00034 /**@defgroup BLE_ERRORS_L2CAP SVC return values specific to L2CAP 00035 * @{ */ 00036 #define BLE_ERROR_L2CAP_CID_IN_USE (NRF_L2CAP_ERR_BASE + 0x000) /**< CID already in use. */ 00037 /** @} */ 00038 00039 /**@brief Default L2CAP MTU. */ 00040 #define BLE_L2CAP_MTU_DEF (23) 00041 00042 /**@brief Invalid Channel Identifier. */ 00043 #define BLE_L2CAP_CID_INVALID (0x0000) 00044 00045 /**@brief Dynamic Channel Identifier base. */ 00046 #define BLE_L2CAP_CID_DYN_BASE (0x0040) 00047 00048 /**@brief Maximum amount of dynamic CIDs. */ 00049 #define BLE_L2CAP_CID_DYN_MAX (8) 00050 00051 /** @} */ 00052 00053 /**@brief Packet header format for L2CAP transmission. */ 00054 typedef struct 00055 { 00056 uint16_t len; /**< Length of valid info in data member. */ 00057 uint16_t cid; /**< Channel ID on which packet is transmitted. */ 00058 } ble_l2cap_header_t; 00059 00060 /**@brief L2CAP Event IDs. */ 00061 enum BLE_L2CAP_EVTS 00062 { 00063 BLE_L2CAP_EVT_RX = BLE_L2CAP_EVT_BASE /**< L2CAP packet received. */ 00064 }; 00065 00066 00067 /**@brief L2CAP Received packet event report. */ 00068 typedef struct 00069 { 00070 ble_l2cap_header_t header; /** L2CAP packet header. */ 00071 uint8_t data[1]; /**< Packet data, variable length. */ 00072 } ble_l2cap_evt_rx_t; 00073 00074 00075 /**@brief L2CAP event callback event structure. */ 00076 typedef struct 00077 { 00078 uint16_t conn_handle; /**< Connection Handle on which event occured. */ 00079 union 00080 { 00081 ble_l2cap_evt_rx_t rx; /**< RX Event parameters. */ 00082 } params; 00083 } ble_l2cap_evt_t; 00084 00085 00086 /**@brief Register a CID with L2CAP. 00087 * 00088 * @details This registers a higher protocol layer with the L2CAP multiplexer, and is requried prior to all operations on the CID. 00089 * 00090 * @param[in] cid L2CAP CID. 00091 * 00092 * @return @ref NRF_SUCCESS Successfully registered a CID with the L2CAP layer. 00093 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CID must be above @ref BLE_L2CAP_CID_DYN_BASE. 00094 * @return @ref BLE_ERROR_L2CAP_CID_IN_USE L2CAP CID already in use. 00095 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. 00096 */ 00097 SVCALL(SD_BLE_L2CAP_CID_REGISTER, uint32_t, sd_ble_l2cap_cid_register(uint16_t cid)); 00098 00099 /**@brief Unregister a CID with L2CAP. 00100 * 00101 * @details This unregisters a previously registerd higher protocol layer with the L2CAP multiplexer. 00102 * 00103 * @param[in] cid L2CAP CID. 00104 * 00105 * @return @ref NRF_SUCCESS Successfully unregistered the CID. 00106 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. 00107 * @return @ref NRF_ERROR_NOT_FOUND CID not previously registered. 00108 */ 00109 SVCALL(SD_BLE_L2CAP_CID_UNREGISTER, uint32_t, sd_ble_l2cap_cid_unregister(uint16_t cid)); 00110 00111 /**@brief Transmit an L2CAP packet. 00112 * 00113 * @note It is important to note that a call to this function will <b>consume an application buffer</b>, and will therefore 00114 * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. 00115 * Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details. 00116 * 00117 * @param[in] conn_handle Connection Handle. 00118 * @param[in] p_header Pointer to a packet header containing length and CID. 00119 * @param[in] p_data Pointer to the data to be transmitted. 00120 * 00121 * @return @ref NRF_SUCCESS Successfully queued an L2CAP packet for transmission. 00122 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00123 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CIDs must be registered beforehand with @ref sd_ble_l2cap_cid_register. 00124 * @return @ref NRF_ERROR_NOT_FOUND CID not found. 00125 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. 00126 * @return @ref BLE_ERROR_NO_TX_BUFFERS Not enough application buffers available. 00127 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, see @ref BLE_L2CAP_MTU_DEF. 00128 */ 00129 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)); 00130 00131 00132 #endif // BLE_L2CAP_H__ 00133 00134 /** 00135 @} 00136 */
Generated on Tue Jul 12 2022 15:07:12 by 1.7.2