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/app_common/hci_slip.h@1:48f6e08a3ac2
?????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 1:48f6e08a3ac2 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
jksoft 1:48f6e08a3ac2 2 *
jksoft 1:48f6e08a3ac2 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 1:48f6e08a3ac2 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 1:48f6e08a3ac2 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 1:48f6e08a3ac2 6 *
jksoft 1:48f6e08a3ac2 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 1:48f6e08a3ac2 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 1:48f6e08a3ac2 9 * the file.
jksoft 1:48f6e08a3ac2 10 *
jksoft 1:48f6e08a3ac2 11 */
jksoft 1:48f6e08a3ac2 12
jksoft 1:48f6e08a3ac2 13 /** @file
jksoft 1:48f6e08a3ac2 14 *
jksoft 1:48f6e08a3ac2 15 * @defgroup hci_slip SLIP module
jksoft 1:48f6e08a3ac2 16 * @{
jksoft 1:48f6e08a3ac2 17 * @ingroup app_common
jksoft 1:48f6e08a3ac2 18 *
jksoft 1:48f6e08a3ac2 19 * @brief SLIP layer for supporting packet framing in HCI transport.
jksoft 1:48f6e08a3ac2 20 *
jksoft 1:48f6e08a3ac2 21 * @details This module implements SLIP packet framing as described in the Bluetooth Core
jksoft 1:48f6e08a3ac2 22 * Specification 4.0, Volume 4, Part D, Chapter 3 SLIP Layer.
jksoft 1:48f6e08a3ac2 23 *
jksoft 1:48f6e08a3ac2 24 * SLIP framing ensures that all packets sent on the UART are framed as:
jksoft 1:48f6e08a3ac2 25 * <0xC0> SLIP packet 1 <0xC0> <0xC0> SLIP packet 2 <0xC0>.
jksoft 1:48f6e08a3ac2 26 *
jksoft 1:48f6e08a3ac2 27 * The SLIP layer uses events to notify the upper layer when data transmission is complete
jksoft 1:48f6e08a3ac2 28 * and when a SLIP packet is received.
jksoft 1:48f6e08a3ac2 29 */
jksoft 1:48f6e08a3ac2 30
jksoft 1:48f6e08a3ac2 31 #ifndef HCI_SLIP_H__
jksoft 1:48f6e08a3ac2 32 #define HCI_SLIP_H__
jksoft 1:48f6e08a3ac2 33
jksoft 1:48f6e08a3ac2 34 #include <stdint.h>
jksoft 1:48f6e08a3ac2 35
jksoft 1:48f6e08a3ac2 36 /**@brief Event types from the SLIP Layer. */
jksoft 1:48f6e08a3ac2 37 typedef enum
jksoft 1:48f6e08a3ac2 38 {
jksoft 1:48f6e08a3ac2 39 HCI_SLIP_RX_RDY, /**< An event indicating that an RX packet is ready to be read. */
jksoft 1:48f6e08a3ac2 40 HCI_SLIP_TX_DONE, /**< An event indicating write completion of the TX packet provided in the function call \ref hci_slip_write . */
jksoft 1:48f6e08a3ac2 41 HCI_SLIP_RX_OVERFLOW, /**< An event indicating that RX data has been discarded due to lack of free RX memory. */
jksoft 1:48f6e08a3ac2 42 HCI_SLIP_ERROR, /**< An event indicating that an unrecoverable error has occurred. */
jksoft 1:48f6e08a3ac2 43 HCI_SLIP_EVT_TYPE_MAX /**< Enumeration upper bound. */
jksoft 1:48f6e08a3ac2 44 } hci_slip_evt_type_t;
jksoft 1:48f6e08a3ac2 45
jksoft 1:48f6e08a3ac2 46 /**@brief Structure containing an event from the SLIP layer.
jksoft 1:48f6e08a3ac2 47 */
jksoft 1:48f6e08a3ac2 48 typedef struct
jksoft 1:48f6e08a3ac2 49 {
jksoft 1:48f6e08a3ac2 50 hci_slip_evt_type_t evt_type; /**< Type of event. */
jksoft 1:48f6e08a3ac2 51 const uint8_t * packet; /**< This field contains a pointer to the packet for which the event relates, i.e. SLIP_TX_DONE: the packet transmitted, SLIP_RX_RDY: the packet received, SLIP_RX_OVERFLOW: The packet which overflow/or NULL if no receive buffer is available. */
jksoft 1:48f6e08a3ac2 52 uint32_t packet_length; /**< Packet length, i.e. SLIP_TX_DONE: Bytes transmitted, SLIP_RX_RDY: Bytes received, SLIP_RX_OVERFLOW: index at which the packet overflowed. */
jksoft 1:48f6e08a3ac2 53 } hci_slip_evt_t;
jksoft 1:48f6e08a3ac2 54
jksoft 1:48f6e08a3ac2 55 /**@brief Function for the SLIP layer event callback.
jksoft 1:48f6e08a3ac2 56 */
jksoft 1:48f6e08a3ac2 57 typedef void (*hci_slip_event_handler_t)(hci_slip_evt_t event);
jksoft 1:48f6e08a3ac2 58
jksoft 1:48f6e08a3ac2 59 /**@brief Function for registering the event handler provided as parameter and this event handler
jksoft 1:48f6e08a3ac2 60 * will be used by SLIP layer to send events described in \ref hci_slip_evt_type_t.
jksoft 1:48f6e08a3ac2 61 *
jksoft 1:48f6e08a3ac2 62 * @note Multiple registration requests will overwrite any existing registration.
jksoft 1:48f6e08a3ac2 63 *
jksoft 1:48f6e08a3ac2 64 * @param[in] event_handler This function is called by the SLIP layer upon an event.
jksoft 1:48f6e08a3ac2 65 *
jksoft 1:48f6e08a3ac2 66 * @retval NRF_SUCCESS Operation success.
jksoft 1:48f6e08a3ac2 67 */
jksoft 1:48f6e08a3ac2 68 uint32_t hci_slip_evt_handler_register(hci_slip_event_handler_t event_handler);
jksoft 1:48f6e08a3ac2 69
jksoft 1:48f6e08a3ac2 70 /**@brief Function for opening the SLIP layer. This function must be called before
jksoft 1:48f6e08a3ac2 71 * \ref hci_slip_write and before any data can be received.
jksoft 1:48f6e08a3ac2 72 *
jksoft 1:48f6e08a3ac2 73 * @note Can be called multiple times.
jksoft 1:48f6e08a3ac2 74 *
jksoft 1:48f6e08a3ac2 75 * @retval NRF_SUCCESS Operation success.
jksoft 1:48f6e08a3ac2 76 *
jksoft 1:48f6e08a3ac2 77 * The SLIP layer module will propagate errors from underlying sub-modules.
jksoft 1:48f6e08a3ac2 78 * This implementation is using UART module as a physical transmission layer, and hci_slip_open
jksoft 1:48f6e08a3ac2 79 * executes \ref app_uart_init . For an extended error list, please refer to \ref app_uart_init .
jksoft 1:48f6e08a3ac2 80 */
jksoft 1:48f6e08a3ac2 81 uint32_t hci_slip_open(void);
jksoft 1:48f6e08a3ac2 82
jksoft 1:48f6e08a3ac2 83 /**@brief Function for closing the SLIP layer. After this function is called no data can be
jksoft 1:48f6e08a3ac2 84 * transmitted or received in this layer.
jksoft 1:48f6e08a3ac2 85 *
jksoft 1:48f6e08a3ac2 86 * @note This function can be called multiple times and also for an unopened channel.
jksoft 1:48f6e08a3ac2 87 *
jksoft 1:48f6e08a3ac2 88 * @retval NRF_SUCCESS Operation success.
jksoft 1:48f6e08a3ac2 89 */
jksoft 1:48f6e08a3ac2 90 uint32_t hci_slip_close(void);
jksoft 1:48f6e08a3ac2 91
jksoft 1:48f6e08a3ac2 92 /**@brief Function for writing a packet with SLIP encoding. Packet transmission is confirmed when
jksoft 1:48f6e08a3ac2 93 * the HCI_SLIP_TX_DONE event is received by the function caller.
jksoft 1:48f6e08a3ac2 94 *
jksoft 1:48f6e08a3ac2 95 * @param[in] p_buffer Pointer to the packet to transmit.
jksoft 1:48f6e08a3ac2 96 * @param[in] length Packet length, in bytes.
jksoft 1:48f6e08a3ac2 97 *
jksoft 1:48f6e08a3ac2 98 * @retval NRF_SUCCESS Operation success. Packet was encoded and added to the
jksoft 1:48f6e08a3ac2 99 * transmission queue and an event will be sent upon transmission
jksoft 1:48f6e08a3ac2 100 * completion.
jksoft 1:48f6e08a3ac2 101 * @retval NRF_ERROR_NO_MEM Operation failure. Transmission queue is full and packet was not
jksoft 1:48f6e08a3ac2 102 * added to the transmission queue. Application shall wait for
jksoft 1:48f6e08a3ac2 103 * the \ref HCI_SLIP_TX_DONE event. After HCI_SLIP_TX_DONE this
jksoft 1:48f6e08a3ac2 104 * function can be executed for transmission of next packet.
jksoft 1:48f6e08a3ac2 105 * @retval NRF_ERROR_INVALID_ADDR If a NULL pointer is provided.
jksoft 1:48f6e08a3ac2 106 * @retval NRF_ERROR_INVALID_STATE Operation failure. Module is not open.
jksoft 1:48f6e08a3ac2 107 */
jksoft 1:48f6e08a3ac2 108 uint32_t hci_slip_write(const uint8_t * p_buffer, uint32_t length);
jksoft 1:48f6e08a3ac2 109
jksoft 1:48f6e08a3ac2 110 /**@brief Function for registering a receive buffer. The receive buffer will be used for storage of
jksoft 1:48f6e08a3ac2 111 * received and SLIP decoded data.
jksoft 1:48f6e08a3ac2 112 * No data can be received by the SLIP layer until a receive buffer has been registered.
jksoft 1:48f6e08a3ac2 113 *
jksoft 1:48f6e08a3ac2 114 * @note The lifetime of the buffer must be valid during complete reception of data. A static
jksoft 1:48f6e08a3ac2 115 * buffer is recommended.
jksoft 1:48f6e08a3ac2 116 *
jksoft 1:48f6e08a3ac2 117 * @warning Multiple registration requests will overwrite any existing registration.
jksoft 1:48f6e08a3ac2 118 *
jksoft 1:48f6e08a3ac2 119 * @param[in] p_buffer Pointer to receive buffer. The received and SLIP decoded packet
jksoft 1:48f6e08a3ac2 120 * will be placed in this buffer.
jksoft 1:48f6e08a3ac2 121 * @param[in] length Buffer length, in bytes.
jksoft 1:48f6e08a3ac2 122 *
jksoft 1:48f6e08a3ac2 123 * @retval NRF_SUCCESS Operation success.
jksoft 1:48f6e08a3ac2 124 */
jksoft 1:48f6e08a3ac2 125 uint32_t hci_slip_rx_buffer_register(uint8_t * p_buffer, uint32_t length);
jksoft 1:48f6e08a3ac2 126
jksoft 1:48f6e08a3ac2 127 #endif // HCI_SLIP_H__
jksoft 1:48f6e08a3ac2 128
jksoft 1:48f6e08a3ac2 129 /** @} */