Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of nRF51822 by
ble_conn_params.h
00001 /* 00002 * Copyright (c) Nordic Semiconductor ASA 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, this 00009 * list of conditions and the following disclaimer. 00010 * 00011 * 2. Redistributions in binary form must reproduce the above copyright notice, this 00012 * list of conditions and the following disclaimer in the documentation and/or 00013 * other materials provided with the distribution. 00014 * 00015 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other 00016 * contributors to this software may be used to endorse or promote products 00017 * derived from this software without specific prior written permission. 00018 * 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00021 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00022 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00023 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 00024 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00025 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00026 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00027 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00029 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 * 00031 */ 00032 00033 /** @file 00034 * 00035 * @defgroup ble_sdk_lib_conn_params Connection Parameters Negotiation 00036 * @{ 00037 * @ingroup ble_sdk_lib 00038 * @brief Module for initiating and executing a connection parameters negotiation procedure. 00039 */ 00040 00041 #ifndef BLE_CONN_PARAMS_H__ 00042 #define BLE_CONN_PARAMS_H__ 00043 00044 #include <stdint.h> 00045 #include "ble.h" 00046 #include "ble_srv_common.h " 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 00052 /**@brief Connection Parameters Module event type. */ 00053 typedef enum 00054 { 00055 BLE_CONN_PARAMS_EVT_FAILED , /**< Negotiation procedure failed. */ 00056 BLE_CONN_PARAMS_EVT_SUCCEEDED /**< Negotiation procedure succeeded. */ 00057 } ble_conn_params_evt_type_t; 00058 00059 /**@brief Connection Parameters Module event. */ 00060 typedef struct 00061 { 00062 ble_conn_params_evt_type_t evt_type; /**< Type of event. */ 00063 } ble_conn_params_evt_t; 00064 00065 /**@brief Connection Parameters Module event handler type. */ 00066 typedef void (*ble_conn_params_evt_handler_t) (ble_conn_params_evt_t * p_evt); 00067 00068 /**@brief Connection Parameters Module init structure. This contains all options and data needed for 00069 * initialization of the connection parameters negotiation module. */ 00070 typedef struct 00071 { 00072 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. */ 00073 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). */ 00074 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. */ 00075 uint8_t max_conn_params_update_count; /**< Number of attempts before giving up the negotiation. */ 00076 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. */ 00077 bool disconnect_on_fail; /**< Set to TRUE if a failed connection parameters update shall cause an automatic disconnection, set to FALSE otherwise. */ 00078 ble_conn_params_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Connection Parameters. */ 00079 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ 00080 } ble_conn_params_init_t; 00081 00082 00083 /**@brief Function for initializing the Connection Parameters module. 00084 * 00085 * @note If the negotiation procedure should be triggered when notification/indication of 00086 * any characteristic is enabled by the peer, then this function must be called after 00087 * having initialized the services. 00088 * 00089 * @param[in] p_init This contains information needed to initialize this module. 00090 * 00091 * @return NRF_SUCCESS on successful initialization, otherwise an error code. 00092 */ 00093 uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init); 00094 00095 /**@brief Function for stopping the Connection Parameters module. 00096 * 00097 * @details This function is intended to be used by the application to clean up the connection 00098 * parameters update module. This will stop the connection parameters update timer if 00099 * running, thereby preventing any impending connection parameters update procedure. This 00100 * function must be called by the application when it needs to clean itself up (for 00101 * example, before disabling the bluetooth SoftDevice) so that an unwanted timer expiry 00102 * event can be avoided. 00103 * 00104 * @return NRF_SUCCESS on successful initialization, otherwise an error code. 00105 */ 00106 uint32_t ble_conn_params_stop(void); 00107 00108 /**@brief Function for changing the current connection parameters to a new set. 00109 * 00110 * @details Use this function to change the connection parameters to a new set of parameter 00111 * (ie different from the ones given at init of the module). 00112 * This function is usefull for scenario where most of the time the application 00113 * needs a relatively big connection interval, and just sometimes, for a temporary 00114 * period requires shorter connection interval, for example to transfer a higher 00115 * amount of data. 00116 * If the given parameters does not match the current connection's parameters 00117 * this function initiates a new negotiation. 00118 * 00119 * @param[in] new_params This contains the new connections parameters to setup. 00120 * 00121 * @return NRF_SUCCESS on successful initialization, otherwise an error code. 00122 */ 00123 uint32_t ble_conn_params_change_conn_params(ble_gap_conn_params_t *new_params); 00124 00125 /**@brief Function for handling the Application's BLE Stack events. 00126 * 00127 * @details Handles all events from the BLE stack that are of interest to this module. 00128 * 00129 * @param[in] p_ble_evt The event received from the BLE stack. 00130 */ 00131 void ble_conn_params_on_ble_evt(ble_evt_t * p_ble_evt); 00132 00133 #ifdef __cplusplus 00134 } 00135 #endif 00136 00137 #endif // BLE_CONN_PARAMS_H__ 00138 00139 /** @} */
Generated on Tue Jul 12 2022 21:00:16 by
