iOSのBLEコントローラアプリ「RCBController」と接続し、コントローラの操作を取得するサンプルプログラムです。 mbed HRM1017で動作を確認しています。 2014.08.20時点でのBLEライブラリに対応しました。
Fork of BLE_RCBController by
HRM1017/nordic/nrf-sdk/ble/ble_conn_params.h@4:ebda47d22091, 2014-08-20 (annotated)
- Committer:
- jksoft
- Date:
- Wed Aug 20 13:41:01 2014 +0000
- Revision:
- 4:ebda47d22091
- Parent:
- nRF51822/nordic/nrf-sdk/ble/ble_conn_params.h@1:48f6e08a3ac2
?????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 1:48f6e08a3ac2 | 1 | /* Copyright (c) 2012 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 ble_sdk_lib_conn_params Connection Parameters Negotiation |
jksoft | 1:48f6e08a3ac2 | 16 | * @{ |
jksoft | 1:48f6e08a3ac2 | 17 | * @ingroup ble_sdk_lib |
jksoft | 1:48f6e08a3ac2 | 18 | * @brief Module for initiating and executing a connection parameters negotiation procedure. |
jksoft | 1:48f6e08a3ac2 | 19 | */ |
jksoft | 1:48f6e08a3ac2 | 20 | |
jksoft | 1:48f6e08a3ac2 | 21 | #ifndef BLE_CONN_PARAMS_H__ |
jksoft | 1:48f6e08a3ac2 | 22 | #define BLE_CONN_PARAMS_H__ |
jksoft | 1:48f6e08a3ac2 | 23 | |
jksoft | 1:48f6e08a3ac2 | 24 | #include <stdint.h> |
jksoft | 1:48f6e08a3ac2 | 25 | #include "ble.h" |
jksoft | 1:48f6e08a3ac2 | 26 | #include "ble_srv_common.h" |
jksoft | 1:48f6e08a3ac2 | 27 | |
jksoft | 1:48f6e08a3ac2 | 28 | #ifdef __cplusplus |
jksoft | 1:48f6e08a3ac2 | 29 | extern "C" { |
jksoft | 1:48f6e08a3ac2 | 30 | #endif // #ifdef __cplusplus |
jksoft | 1:48f6e08a3ac2 | 31 | |
jksoft | 1:48f6e08a3ac2 | 32 | /**@brief Connection Parameters Module event type. */ |
jksoft | 1:48f6e08a3ac2 | 33 | typedef enum |
jksoft | 1:48f6e08a3ac2 | 34 | { |
jksoft | 1:48f6e08a3ac2 | 35 | BLE_CONN_PARAMS_EVT_FAILED , /**< Negotiation procedure failed. */ |
jksoft | 1:48f6e08a3ac2 | 36 | BLE_CONN_PARAMS_EVT_SUCCEEDED /**< Negotiation procedure succeeded. */ |
jksoft | 1:48f6e08a3ac2 | 37 | } ble_conn_params_evt_type_t; |
jksoft | 1:48f6e08a3ac2 | 38 | |
jksoft | 1:48f6e08a3ac2 | 39 | /**@brief Connection Parameters Module event. */ |
jksoft | 1:48f6e08a3ac2 | 40 | typedef struct |
jksoft | 1:48f6e08a3ac2 | 41 | { |
jksoft | 1:48f6e08a3ac2 | 42 | ble_conn_params_evt_type_t evt_type; /**< Type of event. */ |
jksoft | 1:48f6e08a3ac2 | 43 | } ble_conn_params_evt_t; |
jksoft | 1:48f6e08a3ac2 | 44 | |
jksoft | 1:48f6e08a3ac2 | 45 | /**@brief Connection Parameters Module event handler type. */ |
jksoft | 1:48f6e08a3ac2 | 46 | typedef void (*ble_conn_params_evt_handler_t) (ble_conn_params_evt_t * p_evt); |
jksoft | 1:48f6e08a3ac2 | 47 | |
jksoft | 1:48f6e08a3ac2 | 48 | /**@brief Connection Parameters Module init structure. This contains all options and data needed for |
jksoft | 1:48f6e08a3ac2 | 49 | * initialization of the connection parameters negotiation module. */ |
jksoft | 1:48f6e08a3ac2 | 50 | typedef struct |
jksoft | 1:48f6e08a3ac2 | 51 | { |
jksoft | 1:48f6e08a3ac2 | 52 | ble_gap_conn_params_t * p_conn_params; /**< Pointer to the connection parameters desired by the application. When calling ble_conn_params_init, if this parameter is set to NULL, the connection parameters will be fetched from host. */ |
jksoft | 1:48f6e08a3ac2 | 53 | uint32_t first_conn_params_update_delay; /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (in number of timer ticks). */ |
jksoft | 1:48f6e08a3ac2 | 54 | uint32_t next_conn_params_update_delay; /**< Time between each call to sd_ble_gap_conn_param_update after the first (in number of timer ticks). Recommended value 30 seconds as per BLUETOOTH SPECIFICATION Version 4.0. */ |
jksoft | 1:48f6e08a3ac2 | 55 | uint8_t max_conn_params_update_count; /**< Number of attempts before giving up the negotiation. */ |
jksoft | 1:48f6e08a3ac2 | 56 | uint16_t start_on_notify_cccd_handle; /**< If procedure is to be started when notification is started, set this to the handle of the corresponding CCCD. Set to BLE_GATT_HANDLE_INVALID if procedure is to be started on connect event. */ |
jksoft | 1:48f6e08a3ac2 | 57 | bool disconnect_on_fail; /**< Set to TRUE if a failed connection parameters update shall cause an automatic disconnection, set to FALSE otherwise. */ |
jksoft | 1:48f6e08a3ac2 | 58 | ble_conn_params_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Connection Parameters. */ |
jksoft | 1:48f6e08a3ac2 | 59 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
jksoft | 1:48f6e08a3ac2 | 60 | } ble_conn_params_init_t; |
jksoft | 1:48f6e08a3ac2 | 61 | |
jksoft | 1:48f6e08a3ac2 | 62 | |
jksoft | 1:48f6e08a3ac2 | 63 | /**@brief Function for initializing the Connection Parameters module. |
jksoft | 1:48f6e08a3ac2 | 64 | * |
jksoft | 1:48f6e08a3ac2 | 65 | * @note If the negotiation procedure should be triggered when notification/indication of |
jksoft | 1:48f6e08a3ac2 | 66 | * any characteristic is enabled by the peer, then this function must be called after |
jksoft | 1:48f6e08a3ac2 | 67 | * having initialized the services. |
jksoft | 1:48f6e08a3ac2 | 68 | * |
jksoft | 1:48f6e08a3ac2 | 69 | * @param[in] p_init This contains information needed to initialize this module. |
jksoft | 1:48f6e08a3ac2 | 70 | * |
jksoft | 1:48f6e08a3ac2 | 71 | * @return NRF_SUCCESS on successful initialization, otherwise an error code. |
jksoft | 1:48f6e08a3ac2 | 72 | */ |
jksoft | 1:48f6e08a3ac2 | 73 | uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init); |
jksoft | 1:48f6e08a3ac2 | 74 | |
jksoft | 1:48f6e08a3ac2 | 75 | /**@brief Function for stopping the Connection Parameters module. |
jksoft | 1:48f6e08a3ac2 | 76 | * |
jksoft | 1:48f6e08a3ac2 | 77 | * @details This function is intended to be used by the application to clean up the connection |
jksoft | 1:48f6e08a3ac2 | 78 | * parameters update module. This will stop the connection parameters update timer if |
jksoft | 1:48f6e08a3ac2 | 79 | * running, thereby preventing any impending connection parameters update procedure. This |
jksoft | 1:48f6e08a3ac2 | 80 | * function must be called by the application when it needs to clean itself up (for |
jksoft | 1:48f6e08a3ac2 | 81 | * example, before disabling the bluetooth SoftDevice) so that an unwanted timer expiry |
jksoft | 1:48f6e08a3ac2 | 82 | * event can be avoided. |
jksoft | 1:48f6e08a3ac2 | 83 | * |
jksoft | 1:48f6e08a3ac2 | 84 | * @return NRF_SUCCESS on successful initialization, otherwise an error code. |
jksoft | 1:48f6e08a3ac2 | 85 | */ |
jksoft | 1:48f6e08a3ac2 | 86 | uint32_t ble_conn_params_stop(void); |
jksoft | 1:48f6e08a3ac2 | 87 | |
jksoft | 1:48f6e08a3ac2 | 88 | /**@brief Function for changing the current connection parameters to a new set. |
jksoft | 1:48f6e08a3ac2 | 89 | * |
jksoft | 1:48f6e08a3ac2 | 90 | * @details Use this function to change the connection parameters to a new set of parameter |
jksoft | 1:48f6e08a3ac2 | 91 | * (ie different from the ones given at init of the module). |
jksoft | 1:48f6e08a3ac2 | 92 | * This function is usefull for scenario where most of the time the application |
jksoft | 1:48f6e08a3ac2 | 93 | * needs a relatively big connection interval, and just sometimes, for a temporary |
jksoft | 1:48f6e08a3ac2 | 94 | * period requires shorter connection interval, for example to transfer a higher |
jksoft | 1:48f6e08a3ac2 | 95 | * amount of data. |
jksoft | 1:48f6e08a3ac2 | 96 | * If the given parameters does not match the current connection's parameters |
jksoft | 1:48f6e08a3ac2 | 97 | * this function initiates a new negotiation. |
jksoft | 1:48f6e08a3ac2 | 98 | * |
jksoft | 1:48f6e08a3ac2 | 99 | * @param[in] new_params This contains the new connections parameters to setup. |
jksoft | 1:48f6e08a3ac2 | 100 | * |
jksoft | 1:48f6e08a3ac2 | 101 | * @return NRF_SUCCESS on successful initialization, otherwise an error code. |
jksoft | 1:48f6e08a3ac2 | 102 | */ |
jksoft | 1:48f6e08a3ac2 | 103 | uint32_t ble_conn_params_change_conn_params(ble_gap_conn_params_t *new_params); |
jksoft | 1:48f6e08a3ac2 | 104 | |
jksoft | 1:48f6e08a3ac2 | 105 | /**@brief Function for handling the Application's BLE Stack events. |
jksoft | 1:48f6e08a3ac2 | 106 | * |
jksoft | 1:48f6e08a3ac2 | 107 | * @details Handles all events from the BLE stack that are of interest to this module. |
jksoft | 1:48f6e08a3ac2 | 108 | * |
jksoft | 1:48f6e08a3ac2 | 109 | * @param[in] p_ble_evt The event received from the BLE stack. |
jksoft | 1:48f6e08a3ac2 | 110 | */ |
jksoft | 1:48f6e08a3ac2 | 111 | void ble_conn_params_on_ble_evt(ble_evt_t * p_ble_evt); |
jksoft | 1:48f6e08a3ac2 | 112 | |
jksoft | 1:48f6e08a3ac2 | 113 | #endif // BLE_CONN_PARAMS_H__ |
jksoft | 1:48f6e08a3ac2 | 114 | |
jksoft | 1:48f6e08a3ac2 | 115 | /** @} */ |
jksoft | 1:48f6e08a3ac2 | 116 | |
jksoft | 1:48f6e08a3ac2 | 117 | #ifdef __cplusplus |
jksoft | 1:48f6e08a3ac2 | 118 | } |
jksoft | 1:48f6e08a3ac2 | 119 | #endif // #ifdef __cplusplus |