iOSのBLEコントローラアプリ「RCBController」とmbed HRM1017を接続し、RCサーボモータを操作するテストプログラムです。

Dependencies:   BLE_API_Native_IRC Servo mbed

Fork of BLE_RCBController by Junichi Katsu

  • 古いBLEライブラリを使っているのでプラットフォームは”Nordic nRF51822”を選択してください。
  • ライブラリ類はUpdateしないでください。コンパイルエラーになります。

うまく接続できない時は、iPhone/iPadのBluetoothをOFF->ONしてキャッシュをクリアしてみてください。

/media/uploads/robo8080/img_1560.jpg

Committer:
jksoft
Date:
Thu Jul 10 14:21:52 2014 +0000
Revision:
0:8c643bfe55b7
??

Who changed what in which revision?

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