iOSのBLEコントローラアプリ「RCBController」と接続し、コントローラの操作を取得するサンプルプログラムです。 mbed HRM1017で動作を確認しています。 2014.08.20時点でのBLEライブラリに対応しました。

Dependencies:   BLE_API mbed

Fork of BLE_RCBController by Junichi Katsu

Committer:
jksoft
Date:
Wed Aug 20 13:41:01 2014 +0000
Revision:
4:ebda47d22091
Parent:
nRF51822/nordic/nrf-sdk/s110/ble_l2cap.h@1:48f6e08a3ac2
?????????

Who changed what in which revision?

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