テスト用
Fork of nRF51822 by
nordic/nrf-sdk/ble/ble_conn_params.h@69:936d81c963fe, 2014-09-26 (annotated)
- Committer:
- Rohit Grover
- Date:
- Fri Sep 26 14:46:19 2014 +0100
- Revision:
- 69:936d81c963fe
- Parent:
- 65:98215c4f3a25
Release 0.2.1
=============
Features
~~~~~~~~
- Turn on the service-changed characteristic by default.
Bugfixes
~~~~~~~~
- Raised the maximum number of supported characteristics/descriptors to 24
(was 10 previously). We're beginning to find services like Device-
Information with several characteristics populated.
Compatibility
~~~~~~~~~~~~~
Works with 0.2.0 of BLE_API.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 0:eff01767de02 | 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. |
bogdanm | 0:eff01767de02 | 2 | * |
bogdanm | 0:eff01767de02 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
bogdanm | 0:eff01767de02 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
bogdanm | 0:eff01767de02 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
bogdanm | 0:eff01767de02 | 6 | * |
bogdanm | 0:eff01767de02 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
bogdanm | 0:eff01767de02 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
bogdanm | 0:eff01767de02 | 9 | * the file. |
bogdanm | 0:eff01767de02 | 10 | * |
bogdanm | 0:eff01767de02 | 11 | */ |
bogdanm | 0:eff01767de02 | 12 | |
bogdanm | 0:eff01767de02 | 13 | /** @file |
bogdanm | 0:eff01767de02 | 14 | * |
bogdanm | 0:eff01767de02 | 15 | * @defgroup ble_sdk_lib_conn_params Connection Parameters Negotiation |
bogdanm | 0:eff01767de02 | 16 | * @{ |
bogdanm | 0:eff01767de02 | 17 | * @ingroup ble_sdk_lib |
bogdanm | 0:eff01767de02 | 18 | * @brief Module for initiating and executing a connection parameters negotiation procedure. |
bogdanm | 0:eff01767de02 | 19 | */ |
bogdanm | 0:eff01767de02 | 20 | |
bogdanm | 0:eff01767de02 | 21 | #ifndef BLE_CONN_PARAMS_H__ |
bogdanm | 0:eff01767de02 | 22 | #define BLE_CONN_PARAMS_H__ |
bogdanm | 0:eff01767de02 | 23 | |
bogdanm | 0:eff01767de02 | 24 | #include <stdint.h> |
bogdanm | 0:eff01767de02 | 25 | #include "ble.h" |
bogdanm | 0:eff01767de02 | 26 | #include "ble_srv_common.h" |
bogdanm | 0:eff01767de02 | 27 | |
Rohit Grover |
45:3c4df37ed83e | 28 | #ifdef __cplusplus |
Rohit Grover |
45:3c4df37ed83e | 29 | extern "C" { |
Rohit Grover |
45:3c4df37ed83e | 30 | #endif // #ifdef __cplusplus |
Rohit Grover |
45:3c4df37ed83e | 31 | |
bogdanm | 0:eff01767de02 | 32 | /**@brief Connection Parameters Module event type. */ |
bogdanm | 0:eff01767de02 | 33 | typedef enum |
bogdanm | 0:eff01767de02 | 34 | { |
bogdanm | 0:eff01767de02 | 35 | BLE_CONN_PARAMS_EVT_FAILED , /**< Negotiation procedure failed. */ |
bogdanm | 0:eff01767de02 | 36 | BLE_CONN_PARAMS_EVT_SUCCEEDED /**< Negotiation procedure succeeded. */ |
bogdanm | 0:eff01767de02 | 37 | } ble_conn_params_evt_type_t; |
bogdanm | 0:eff01767de02 | 38 | |
bogdanm | 0:eff01767de02 | 39 | /**@brief Connection Parameters Module event. */ |
bogdanm | 0:eff01767de02 | 40 | typedef struct |
bogdanm | 0:eff01767de02 | 41 | { |
bogdanm | 0:eff01767de02 | 42 | ble_conn_params_evt_type_t evt_type; /**< Type of event. */ |
bogdanm | 0:eff01767de02 | 43 | } ble_conn_params_evt_t; |
bogdanm | 0:eff01767de02 | 44 | |
bogdanm | 0:eff01767de02 | 45 | /**@brief Connection Parameters Module event handler type. */ |
bogdanm | 0:eff01767de02 | 46 | typedef void (*ble_conn_params_evt_handler_t) (ble_conn_params_evt_t * p_evt); |
bogdanm | 0:eff01767de02 | 47 | |
bogdanm | 0:eff01767de02 | 48 | /**@brief Connection Parameters Module init structure. This contains all options and data needed for |
bogdanm | 0:eff01767de02 | 49 | * initialization of the connection parameters negotiation module. */ |
bogdanm | 0:eff01767de02 | 50 | typedef struct |
bogdanm | 0:eff01767de02 | 51 | { |
bogdanm | 0:eff01767de02 | 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. */ |
bogdanm | 0:eff01767de02 | 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). */ |
bogdanm | 0:eff01767de02 | 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. */ |
bogdanm | 0:eff01767de02 | 55 | uint8_t max_conn_params_update_count; /**< Number of attempts before giving up the negotiation. */ |
bogdanm | 0:eff01767de02 | 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. */ |
bogdanm | 0:eff01767de02 | 57 | bool disconnect_on_fail; /**< Set to TRUE if a failed connection parameters update shall cause an automatic disconnection, set to FALSE otherwise. */ |
Rohit Grover |
37:c29c330d942c | 58 | ble_conn_params_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Connection Parameters. */ |
bogdanm | 0:eff01767de02 | 59 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
bogdanm | 0:eff01767de02 | 60 | } ble_conn_params_init_t; |
bogdanm | 0:eff01767de02 | 61 | |
bogdanm | 0:eff01767de02 | 62 | |
bogdanm | 0:eff01767de02 | 63 | /**@brief Function for initializing the Connection Parameters module. |
bogdanm | 0:eff01767de02 | 64 | * |
Rohit Grover |
65:98215c4f3a25 | 65 | * @note If the negotiation procedure should be triggered when notification/indication of |
bogdanm | 0:eff01767de02 | 66 | * any characteristic is enabled by the peer, then this function must be called after |
bogdanm | 0:eff01767de02 | 67 | * having initialized the services. |
bogdanm | 0:eff01767de02 | 68 | * |
bogdanm | 0:eff01767de02 | 69 | * @param[in] p_init This contains information needed to initialize this module. |
bogdanm | 0:eff01767de02 | 70 | * |
bogdanm | 0:eff01767de02 | 71 | * @return NRF_SUCCESS on successful initialization, otherwise an error code. |
bogdanm | 0:eff01767de02 | 72 | */ |
bogdanm | 0:eff01767de02 | 73 | uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init); |
bogdanm | 0:eff01767de02 | 74 | |
bogdanm | 0:eff01767de02 | 75 | /**@brief Function for stopping the Connection Parameters module. |
bogdanm | 0:eff01767de02 | 76 | * |
bogdanm | 0:eff01767de02 | 77 | * @details This function is intended to be used by the application to clean up the connection |
bogdanm | 0:eff01767de02 | 78 | * parameters update module. This will stop the connection parameters update timer if |
bogdanm | 0:eff01767de02 | 79 | * running, thereby preventing any impending connection parameters update procedure. This |
bogdanm | 0:eff01767de02 | 80 | * function must be called by the application when it needs to clean itself up (for |
bogdanm | 0:eff01767de02 | 81 | * example, before disabling the bluetooth SoftDevice) so that an unwanted timer expiry |
bogdanm | 0:eff01767de02 | 82 | * event can be avoided. |
bogdanm | 0:eff01767de02 | 83 | * |
bogdanm | 0:eff01767de02 | 84 | * @return NRF_SUCCESS on successful initialization, otherwise an error code. |
bogdanm | 0:eff01767de02 | 85 | */ |
bogdanm | 0:eff01767de02 | 86 | uint32_t ble_conn_params_stop(void); |
bogdanm | 0:eff01767de02 | 87 | |
bogdanm | 0:eff01767de02 | 88 | /**@brief Function for changing the current connection parameters to a new set. |
bogdanm | 0:eff01767de02 | 89 | * |
Rohit Grover |
65:98215c4f3a25 | 90 | * @details Use this function to change the connection parameters to a new set of parameter |
bogdanm | 0:eff01767de02 | 91 | * (ie different from the ones given at init of the module). |
bogdanm | 0:eff01767de02 | 92 | * This function is usefull for scenario where most of the time the application |
bogdanm | 0:eff01767de02 | 93 | * needs a relatively big connection interval, and just sometimes, for a temporary |
bogdanm | 0:eff01767de02 | 94 | * period requires shorter connection interval, for example to transfer a higher |
bogdanm | 0:eff01767de02 | 95 | * amount of data. |
bogdanm | 0:eff01767de02 | 96 | * If the given parameters does not match the current connection's parameters |
bogdanm | 0:eff01767de02 | 97 | * this function initiates a new negotiation. |
bogdanm | 0:eff01767de02 | 98 | * |
bogdanm | 0:eff01767de02 | 99 | * @param[in] new_params This contains the new connections parameters to setup. |
bogdanm | 0:eff01767de02 | 100 | * |
bogdanm | 0:eff01767de02 | 101 | * @return NRF_SUCCESS on successful initialization, otherwise an error code. |
bogdanm | 0:eff01767de02 | 102 | */ |
bogdanm | 0:eff01767de02 | 103 | uint32_t ble_conn_params_change_conn_params(ble_gap_conn_params_t *new_params); |
bogdanm | 0:eff01767de02 | 104 | |
bogdanm | 0:eff01767de02 | 105 | /**@brief Function for handling the Application's BLE Stack events. |
bogdanm | 0:eff01767de02 | 106 | * |
bogdanm | 0:eff01767de02 | 107 | * @details Handles all events from the BLE stack that are of interest to this module. |
bogdanm | 0:eff01767de02 | 108 | * |
bogdanm | 0:eff01767de02 | 109 | * @param[in] p_ble_evt The event received from the BLE stack. |
bogdanm | 0:eff01767de02 | 110 | */ |
bogdanm | 0:eff01767de02 | 111 | void ble_conn_params_on_ble_evt(ble_evt_t * p_ble_evt); |
bogdanm | 0:eff01767de02 | 112 | |
bogdanm | 0:eff01767de02 | 113 | #endif // BLE_CONN_PARAMS_H__ |
bogdanm | 0:eff01767de02 | 114 | |
bogdanm | 0:eff01767de02 | 115 | /** @} */ |
Rohit Grover |
45:3c4df37ed83e | 116 | |
Rohit Grover |
45:3c4df37ed83e | 117 | #ifdef __cplusplus |
Rohit Grover |
45:3c4df37ed83e | 118 | } |
Rohit Grover |
45:3c4df37ed83e | 119 | #endif // #ifdef __cplusplus |