BLE temperature profile using digital DS1820 or analog LM35 sensors

Dependencies:   DS1820

Committer:
gkroussos
Date:
Sat Mar 07 16:23:41 2015 +0000
Revision:
0:637031152314
Working version 1.0

Who changed what in which revision?

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