Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.

Dependents:   nRF51822 nRF51822

Committer:
vcoubard
Date:
Thu Apr 07 17:37:40 2016 +0100
Revision:
19:47192cb9def7
Parent:
10:233fefd8162b
Child:
20:a90c48eb1d30
Synchronized with git rev 9251259f
Author: Liyou Zhou
Copy over coresponding files from nordic-sdk 9.0.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 19:47192cb9def7 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
vcoubard 19:47192cb9def7 2 *
vcoubard 19:47192cb9def7 3 * The information contained herein is property of Nordic Semiconductor ASA.
vcoubard 19:47192cb9def7 4 * Terms and conditions of usage are described in detail in NORDIC
vcoubard 19:47192cb9def7 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
vcoubard 19:47192cb9def7 6 *
vcoubard 19:47192cb9def7 7 * Licensees are granted free, non-transferable use of the information. NO
vcoubard 19:47192cb9def7 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
vcoubard 19:47192cb9def7 9 * the file.
vcoubard 19:47192cb9def7 10 *
Vincent Coubard 0:f2542974c862 11 */
Vincent Coubard 0:f2542974c862 12
Vincent Coubard 0:f2542974c862 13 /** @file
Vincent Coubard 0:f2542974c862 14 *
Vincent Coubard 0:f2542974c862 15 * @defgroup ble_sdk_lib_conn_params Connection Parameters Negotiation
Vincent Coubard 0:f2542974c862 16 * @{
Vincent Coubard 0:f2542974c862 17 * @ingroup ble_sdk_lib
Vincent Coubard 0:f2542974c862 18 * @brief Module for initiating and executing a connection parameters negotiation procedure.
Vincent Coubard 0:f2542974c862 19 */
Vincent Coubard 0:f2542974c862 20
Vincent Coubard 0:f2542974c862 21 #ifndef BLE_CONN_PARAMS_H__
Vincent Coubard 0:f2542974c862 22 #define BLE_CONN_PARAMS_H__
Vincent Coubard 0:f2542974c862 23
Vincent Coubard 0:f2542974c862 24 #include <stdint.h>
Vincent Coubard 0:f2542974c862 25 #include "ble.h"
Vincent Coubard 0:f2542974c862 26 #include "ble_srv_common.h"
Vincent Coubard 0:f2542974c862 27
Vincent Coubard 0:f2542974c862 28 /**@brief Connection Parameters Module event type. */
Vincent Coubard 0:f2542974c862 29 typedef enum
Vincent Coubard 0:f2542974c862 30 {
Vincent Coubard 0:f2542974c862 31 BLE_CONN_PARAMS_EVT_FAILED , /**< Negotiation procedure failed. */
Vincent Coubard 0:f2542974c862 32 BLE_CONN_PARAMS_EVT_SUCCEEDED /**< Negotiation procedure succeeded. */
Vincent Coubard 0:f2542974c862 33 } ble_conn_params_evt_type_t;
Vincent Coubard 0:f2542974c862 34
Vincent Coubard 0:f2542974c862 35 /**@brief Connection Parameters Module event. */
Vincent Coubard 0:f2542974c862 36 typedef struct
Vincent Coubard 0:f2542974c862 37 {
Vincent Coubard 0:f2542974c862 38 ble_conn_params_evt_type_t evt_type; /**< Type of event. */
Vincent Coubard 0:f2542974c862 39 } ble_conn_params_evt_t;
Vincent Coubard 0:f2542974c862 40
Vincent Coubard 0:f2542974c862 41 /**@brief Connection Parameters Module event handler type. */
Vincent Coubard 0:f2542974c862 42 typedef void (*ble_conn_params_evt_handler_t) (ble_conn_params_evt_t * p_evt);
Vincent Coubard 0:f2542974c862 43
Vincent Coubard 0:f2542974c862 44 /**@brief Connection Parameters Module init structure. This contains all options and data needed for
Vincent Coubard 0:f2542974c862 45 * initialization of the connection parameters negotiation module. */
Vincent Coubard 0:f2542974c862 46 typedef struct
Vincent Coubard 0:f2542974c862 47 {
Vincent Coubard 0:f2542974c862 48 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. */
Vincent Coubard 0:f2542974c862 49 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). */
Vincent Coubard 0:f2542974c862 50 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. */
Vincent Coubard 0:f2542974c862 51 uint8_t max_conn_params_update_count; /**< Number of attempts before giving up the negotiation. */
Vincent Coubard 0:f2542974c862 52 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. */
Vincent Coubard 0:f2542974c862 53 bool disconnect_on_fail; /**< Set to TRUE if a failed connection parameters update shall cause an automatic disconnection, set to FALSE otherwise. */
Vincent Coubard 0:f2542974c862 54 ble_conn_params_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Connection Parameters. */
Vincent Coubard 0:f2542974c862 55 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
Vincent Coubard 0:f2542974c862 56 } ble_conn_params_init_t;
Vincent Coubard 0:f2542974c862 57
Vincent Coubard 0:f2542974c862 58
Vincent Coubard 0:f2542974c862 59 /**@brief Function for initializing the Connection Parameters module.
Vincent Coubard 0:f2542974c862 60 *
vcoubard 1:ebc0e0ef0a11 61 * @note If the negotiation procedure should be triggered when notification/indication of
Vincent Coubard 0:f2542974c862 62 * any characteristic is enabled by the peer, then this function must be called after
Vincent Coubard 0:f2542974c862 63 * having initialized the services.
Vincent Coubard 0:f2542974c862 64 *
Vincent Coubard 0:f2542974c862 65 * @param[in] p_init This contains information needed to initialize this module.
Vincent Coubard 0:f2542974c862 66 *
Vincent Coubard 0:f2542974c862 67 * @return NRF_SUCCESS on successful initialization, otherwise an error code.
Vincent Coubard 0:f2542974c862 68 */
Vincent Coubard 0:f2542974c862 69 uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init);
Vincent Coubard 0:f2542974c862 70
Vincent Coubard 0:f2542974c862 71 /**@brief Function for stopping the Connection Parameters module.
Vincent Coubard 0:f2542974c862 72 *
Vincent Coubard 0:f2542974c862 73 * @details This function is intended to be used by the application to clean up the connection
Vincent Coubard 0:f2542974c862 74 * parameters update module. This will stop the connection parameters update timer if
Vincent Coubard 0:f2542974c862 75 * running, thereby preventing any impending connection parameters update procedure. This
Vincent Coubard 0:f2542974c862 76 * function must be called by the application when it needs to clean itself up (for
Vincent Coubard 0:f2542974c862 77 * example, before disabling the bluetooth SoftDevice) so that an unwanted timer expiry
Vincent Coubard 0:f2542974c862 78 * event can be avoided.
Vincent Coubard 0:f2542974c862 79 *
Vincent Coubard 0:f2542974c862 80 * @return NRF_SUCCESS on successful initialization, otherwise an error code.
Vincent Coubard 0:f2542974c862 81 */
Vincent Coubard 0:f2542974c862 82 uint32_t ble_conn_params_stop(void);
Vincent Coubard 0:f2542974c862 83
Vincent Coubard 0:f2542974c862 84 /**@brief Function for changing the current connection parameters to a new set.
Vincent Coubard 0:f2542974c862 85 *
vcoubard 1:ebc0e0ef0a11 86 * @details Use this function to change the connection parameters to a new set of parameter
Vincent Coubard 0:f2542974c862 87 * (ie different from the ones given at init of the module).
Vincent Coubard 0:f2542974c862 88 * This function is usefull for scenario where most of the time the application
Vincent Coubard 0:f2542974c862 89 * needs a relatively big connection interval, and just sometimes, for a temporary
Vincent Coubard 0:f2542974c862 90 * period requires shorter connection interval, for example to transfer a higher
Vincent Coubard 0:f2542974c862 91 * amount of data.
Vincent Coubard 0:f2542974c862 92 * If the given parameters does not match the current connection's parameters
Vincent Coubard 0:f2542974c862 93 * this function initiates a new negotiation.
Vincent Coubard 0:f2542974c862 94 *
Vincent Coubard 0:f2542974c862 95 * @param[in] new_params This contains the new connections parameters to setup.
Vincent Coubard 0:f2542974c862 96 *
Vincent Coubard 0:f2542974c862 97 * @return NRF_SUCCESS on successful initialization, otherwise an error code.
Vincent Coubard 0:f2542974c862 98 */
Vincent Coubard 0:f2542974c862 99 uint32_t ble_conn_params_change_conn_params(ble_gap_conn_params_t *new_params);
Vincent Coubard 0:f2542974c862 100
Vincent Coubard 0:f2542974c862 101 /**@brief Function for handling the Application's BLE Stack events.
Vincent Coubard 0:f2542974c862 102 *
Vincent Coubard 0:f2542974c862 103 * @details Handles all events from the BLE stack that are of interest to this module.
Vincent Coubard 0:f2542974c862 104 *
Vincent Coubard 0:f2542974c862 105 * @param[in] p_ble_evt The event received from the BLE stack.
Vincent Coubard 0:f2542974c862 106 */
Vincent Coubard 0:f2542974c862 107 void ble_conn_params_on_ble_evt(ble_evt_t * p_ble_evt);
Vincent Coubard 0:f2542974c862 108
Vincent Coubard 0:f2542974c862 109 #endif // BLE_CONN_PARAMS_H__
Vincent Coubard 0:f2542974c862 110
vcoubard 1:ebc0e0ef0a11 111 /** @} */