Patched version of nrf51822 FOTA compatible driver, with GPTIO disabled, as it clashed with the mbed definitions...

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ble_conn_params.h Source File

ble_conn_params.h

Go to the documentation of this file.
00001 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is property of Nordic Semiconductor ASA.
00004  * Terms and conditions of usage are described in detail in NORDIC
00005  * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
00006  *
00007  * Licensees are granted free, non-transferable use of the information. NO
00008  * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
00009  * the file.
00010  *
00011  */
00012 
00013 /** @file
00014  *
00015  * @defgroup ble_sdk_lib_conn_params Connection Parameters Negotiation
00016  * @{
00017  * @ingroup ble_sdk_lib
00018  * @brief Module for initiating and executing a connection parameters negotiation procedure.
00019  */
00020 
00021 #ifndef BLE_CONN_PARAMS_H__
00022 #define BLE_CONN_PARAMS_H__
00023 
00024 #include <stdint.h>
00025 #include "ble.h"
00026 #include "ble_srv_common.h "
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 /**@brief Connection Parameters Module event type. */
00033 typedef enum
00034 {
00035     BLE_CONN_PARAMS_EVT_FAILED   ,                                  /**< Negotiation procedure failed. */
00036     BLE_CONN_PARAMS_EVT_SUCCEEDED                                   /**< Negotiation procedure succeeded. */
00037 } ble_conn_params_evt_type_t;
00038 
00039 /**@brief Connection Parameters Module event. */
00040 typedef struct
00041 {
00042     ble_conn_params_evt_type_t evt_type;                            /**< Type of event. */
00043 } ble_conn_params_evt_t;
00044 
00045 /**@brief Connection Parameters Module event handler type. */
00046 typedef void (*ble_conn_params_evt_handler_t) (ble_conn_params_evt_t * p_evt);
00047 
00048 /**@brief Connection Parameters Module init structure. This contains all options and data needed for
00049  *        initialization of the connection parameters negotiation module. */
00050 typedef struct
00051 {
00052     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. */
00053     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). */
00054     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. */
00055     uint8_t                       max_conn_params_update_count;     /**< Number of attempts before giving up the negotiation. */
00056     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. */
00057     bool                          disconnect_on_fail;               /**< Set to TRUE if a failed connection parameters update shall cause an automatic disconnection, set to FALSE otherwise. */
00058     ble_conn_params_evt_handler_t evt_handler;                      /**< Event handler to be called for handling events in the Connection Parameters. */
00059     ble_srv_error_handler_t       error_handler;                    /**< Function to be called in case of an error. */
00060 } ble_conn_params_init_t;
00061 
00062 
00063 /**@brief Function for initializing the Connection Parameters module.
00064  *
00065  * @note If the negotiation procedure should be triggered when notification/indication of
00066  *       any characteristic is enabled by the peer, then this function must be called after
00067  *       having initialized the services.
00068  *
00069  * @param[in]   p_init  This contains information needed to initialize this module.
00070  *
00071  * @return      NRF_SUCCESS on successful initialization, otherwise an error code.
00072  */
00073 uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init);
00074 
00075 /**@brief Function for stopping the Connection Parameters module.
00076  *
00077  * @details This function is intended to be used by the application to clean up the connection
00078  *          parameters update module. This will stop the connection parameters update timer if
00079  *          running, thereby preventing any impending connection parameters update procedure. This
00080  *          function must be called by the application when it needs to clean itself up (for
00081  *          example, before disabling the bluetooth SoftDevice) so that an unwanted timer expiry
00082  *          event can be avoided.
00083  *
00084  * @return      NRF_SUCCESS on successful initialization, otherwise an error code.
00085  */
00086 uint32_t ble_conn_params_stop(void);
00087 
00088 /**@brief Function for changing the current connection parameters to a new set.
00089  *
00090  *  @details Use this function to change the connection parameters to a new set of parameter
00091  *       (ie different from the ones given at init of the module).
00092  *       This function is usefull for scenario where most of the time the application
00093  *       needs a relatively big connection interval, and just sometimes, for a temporary
00094  *       period requires shorter connection interval, for example to transfer a higher
00095  *       amount of data.
00096  *       If the given parameters does not match the current connection's parameters
00097  *       this function initiates a new negotiation.
00098  *
00099  * @param[in]   new_params  This contains the new connections parameters to setup.
00100  *
00101  * @return      NRF_SUCCESS on successful initialization, otherwise an error code.
00102  */
00103 uint32_t ble_conn_params_change_conn_params(ble_gap_conn_params_t *new_params);
00104 
00105 /**@brief Function for handling the Application's BLE Stack events.
00106  *
00107  * @details Handles all events from the BLE stack that are of interest to this module.
00108  *
00109  * @param[in]   p_ble_evt  The event received from the BLE stack.
00110  */
00111 void ble_conn_params_on_ble_evt(ble_evt_t * p_ble_evt);
00112 
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116 
00117 #endif // BLE_CONN_PARAMS_H__
00118 
00119 /** @} */