@@ -94,6 +94,9 @@ enum BLE_GAP_SVCS
94
94
SD_BLE_GAP_CONN_SEC_GET = BLE_GAP_SVC_BASE + 28 , /**< Obtain connection security level. */
95
95
SD_BLE_GAP_PHY_UPDATE = BLE_GAP_SVC_BASE + 33 , /**< Initiate or respond to a PHY Update Procedure. */
96
96
SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET = BLE_GAP_SVC_BASE + 36 , /**< Get the next connection event counter. */
97
+ SD_BLE_GAP_RSSI_GET = BLE_GAP_SVC_BASE + 38 , /**< Get the last RSSI sample. */
98
+ SD_BLE_GAP_RSSI_START = BLE_GAP_SVC_BASE + 39 , /**< Start reporting of changes in RSSI. */
99
+ SD_BLE_GAP_RSSI_STOP = BLE_GAP_SVC_BASE + 40 , /**< Stop reporting of changes in RSSI. */
97
100
};
98
101
99
102
/**@brief GAP Event IDs.
@@ -113,6 +116,7 @@ enum BLE_GAP_EVTS
113
116
BLE_GAP_EVT_AUTH_STATUS = BLE_GAP_EVT_BASE + 9 , /**< Authentication procedure completed with status. \n See @ref ble_gap_evt_auth_status_t. */
114
117
BLE_GAP_EVT_CONN_SEC_UPDATE = BLE_GAP_EVT_BASE + 10 , /**< Connection security updated. \n See @ref ble_gap_evt_conn_sec_update_t. */
115
118
BLE_GAP_EVT_TIMEOUT = BLE_GAP_EVT_BASE + 11 , /**< Timeout expired. \n See @ref ble_gap_evt_timeout_t. */
119
+ BLE_GAP_EVT_RSSI_CHANGED = BLE_GAP_EVT_BASE + 12 , /**< RSSI report. \n See @ref ble_gap_evt_rssi_changed_t. */
116
120
BLE_GAP_EVT_SCAN_REQ_REPORT = BLE_GAP_EVT_BASE + 16 , /**< Scan request report. \n See @ref ble_gap_evt_scan_req_report_t. */
117
121
BLE_GAP_EVT_PHY_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 17 , /**< PHY Update Request. \n Reply with @ref sd_ble_gap_phy_update. \n See @ref ble_gap_evt_phy_update_request_t. */
118
122
BLE_GAP_EVT_PHY_UPDATE = BLE_GAP_EVT_BASE + 18 , /**< PHY Update Procedure is complete. \n See @ref ble_gap_evt_phy_update_t. */
@@ -409,7 +413,6 @@ enum BLE_GAP_TX_POWER_ROLES
409
413
410
414
/**@} */
411
415
412
-
413
416
/**@defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits
414
417
* @{
415
418
*/
@@ -434,6 +437,9 @@ enum BLE_GAP_TX_POWER_ROLES
434
437
/**@} */
435
438
436
439
440
+ /**@brief Disable RSSI events for connections */
441
+ #define BLE_GAP_RSSI_THRESHOLD_INVALID 0xFF
442
+
437
443
/**@defgroup BLE_GAP_PHYS GAP PHYs
438
444
* @{ */
439
445
#define BLE_GAP_PHY_AUTO 0x00 /**< Automatic PHY selection. Refer @ref sd_ble_gap_phy_update for more information.*/
@@ -1008,6 +1014,14 @@ typedef struct
1008
1014
} ble_gap_evt_timeout_t ;
1009
1015
1010
1016
1017
+ /**@brief Event structure for @ref BLE_GAP_EVT_RSSI_CHANGED. */
1018
+ typedef struct
1019
+ {
1020
+ int8_t rssi ; /**< Received Signal Strength Indication in dBm.
1021
+ @note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement. */
1022
+ uint8_t ch_index ; /**< Data Channel Index on which the Signal Strength is measured (0-36). */
1023
+ } ble_gap_evt_rssi_changed_t ;
1024
+
1011
1025
/**@brief Event structure for @ref BLE_GAP_EVT_ADV_SET_TERMINATED */
1012
1026
typedef struct
1013
1027
{
@@ -1045,6 +1059,7 @@ typedef struct
1045
1059
ble_gap_evt_auth_status_t auth_status ; /**< Authentication Status Event Parameters. */
1046
1060
ble_gap_evt_conn_sec_update_t conn_sec_update ; /**< Connection Security Update Event Parameters. */
1047
1061
ble_gap_evt_timeout_t timeout ; /**< Timeout Event Parameters. */
1062
+ ble_gap_evt_rssi_changed_t rssi_changed ; /**< RSSI Event Parameters. */
1048
1063
ble_gap_evt_adv_set_terminated_t adv_set_terminated ; /**< Advertising Set Terminated Event Parameters. */
1049
1064
ble_gap_evt_scan_req_report_t scan_req_report ; /**< Scan Request Report Parameters. */
1050
1065
ble_gap_evt_phy_update_request_t phy_update_request ; /**< PHY Update Request Event Parameters. */
@@ -1554,7 +1569,6 @@ SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(uint8_t adv_handle));
1554
1569
*/
1555
1570
SVCALL (SD_BLE_GAP_CONN_PARAM_UPDATE , uint32_t , sd_ble_gap_conn_param_update (uint16_t conn_handle , ble_gap_conn_params_t const * p_conn_params ));
1556
1571
1557
-
1558
1572
/**@brief Disconnect (GAP Link Termination).
1559
1573
*
1560
1574
* @details This call initiates the disconnection procedure, and its completion will be communicated to the application
@@ -1943,6 +1957,73 @@ SVCALL(SD_BLE_GAP_SEC_INFO_REPLY, uint32_t, sd_ble_gap_sec_info_reply(uint16_t c
1943
1957
SVCALL (SD_BLE_GAP_CONN_SEC_GET , uint32_t , sd_ble_gap_conn_sec_get (uint16_t conn_handle , ble_gap_conn_sec_t * p_conn_sec ));
1944
1958
1945
1959
1960
+ /**@brief Start reporting the received signal strength to the application.
1961
+ *
1962
+ * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called.
1963
+ *
1964
+ * @events
1965
+ * @event{@ref BLE_GAP_EVT_RSSI_CHANGED, New RSSI data available. How often the event is generated is
1966
+ * dependent on the settings of the <code>threshold_dbm</code>
1967
+ * and <code>skip_count</code> input parameters.}
1968
+ * @endevents
1969
+ *
1970
+ * @mscs
1971
+ * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
1972
+ * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC}
1973
+ * @endmscs
1974
+ *
1975
+ * @param[in] conn_handle Connection handle.
1976
+ * @param[in] threshold_dbm Minimum change in dBm before triggering the @ref BLE_GAP_EVT_RSSI_CHANGED event. Events are disabled if threshold_dbm equals @ref BLE_GAP_RSSI_THRESHOLD_INVALID.
1977
+ * @param[in] skip_count Number of RSSI samples with a change of threshold_dbm or more before sending a new @ref BLE_GAP_EVT_RSSI_CHANGED event.
1978
+ *
1979
+ * @retval ::NRF_SUCCESS Successfully activated RSSI reporting.
1980
+ * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is already ongoing.
1981
+ * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
1982
+ */
1983
+ SVCALL (SD_BLE_GAP_RSSI_START , uint32_t , sd_ble_gap_rssi_start (uint16_t conn_handle , uint8_t threshold_dbm , uint8_t skip_count ));
1984
+
1985
+
1986
+ /**@brief Stop reporting the received signal strength.
1987
+ *
1988
+ * @note An RSSI change detected before the call but not yet received by the application
1989
+ * may be reported after @ref sd_ble_gap_rssi_stop has been called.
1990
+ *
1991
+ * @mscs
1992
+ * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
1993
+ * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC}
1994
+ * @endmscs
1995
+ *
1996
+ * @param[in] conn_handle Connection handle.
1997
+ *
1998
+ * @retval ::NRF_SUCCESS Successfully deactivated RSSI reporting.
1999
+ * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing.
2000
+ * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
2001
+ */
2002
+ SVCALL (SD_BLE_GAP_RSSI_STOP , uint32_t , sd_ble_gap_rssi_stop (uint16_t conn_handle ));
2003
+
2004
+
2005
+ /**@brief Get the received signal strength for the last connection event.
2006
+ *
2007
+ * @ref sd_ble_gap_rssi_start must be called to start reporting RSSI before using this function. @ref NRF_ERROR_NOT_FOUND
2008
+ * will be returned until RSSI was sampled for the first time after calling @ref sd_ble_gap_rssi_start.
2009
+ * @note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement.
2010
+ * @mscs
2011
+ * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
2012
+ * @endmscs
2013
+ *
2014
+ * @param[in] conn_handle Connection handle.
2015
+ * @param[out] p_rssi Pointer to the location where the RSSI measurement shall be stored.
2016
+ * @param[out] p_ch_index Pointer to the location where Channel Index for the RSSI measurement shall be stored.
2017
+ *
2018
+ * @retval ::NRF_SUCCESS Successfully read the RSSI.
2019
+ * @retval ::NRF_ERROR_NOT_FOUND No sample is available.
2020
+ * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
2021
+ * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
2022
+ * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing.
2023
+ */
2024
+ SVCALL (SD_BLE_GAP_RSSI_GET , uint32_t , sd_ble_gap_rssi_get (uint16_t conn_handle , int8_t * p_rssi , uint8_t * p_ch_index ));
2025
+
2026
+
1946
2027
/**@brief Initiate or respond to a PHY Update Procedure
1947
2028
*
1948
2029
* @details This function is used to initiate or respond to a PHY Update Procedure. It will always
0 commit comments