diff --git a/examples/ble_central/ble_app_gatts/main.c b/examples/ble_central/ble_app_gatts/main.c index 7d5022d..34e769c 100644 --- a/examples/ble_central/ble_app_gatts/main.c +++ b/examples/ble_central/ble_app_gatts/main.c @@ -85,10 +85,10 @@ #define APP_SOC_OBSERVER_PRIO 1 /**< Applications' SoC observer priority. You shouldn't need to modify this value. */ #define SEC_PARAM_BOND 1 /**< Perform bonding. */ -#define SEC_PARAM_MITM 0 /**< Man In The Middle protection not required. */ +#define SEC_PARAM_MITM 1 /**< Man In The Middle protection not required. */ #define SEC_PARAM_LESC 0 /**< LE Secure Connections not enabled. */ #define SEC_PARAM_KEYPRESS 0 /**< Keypress notifications not enabled. */ -#define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE /**< No I/O capabilities. */ +#define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_KEYBOARD_ONLY /**< No I/O capabilities. */ #define SEC_PARAM_OOB 0 /**< Out Of Band data not available. */ #define SEC_PARAM_MIN_KEY_SIZE 7 /**< Minimum encryption key size. */ #define SEC_PARAM_MAX_KEY_SIZE 16 /**< Maximum encryption key size. */ @@ -293,6 +293,19 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); APP_ERROR_CHECK(err_code); } break; + + case BLE_GAP_EVT_AUTH_KEY_REQUEST: + { + + NRF_LOG_DEBUG("GAP Passkey request."); + uint8_t passkey[] = "000000"; + if (p_gap_evt->params.auth_key_request.key_type == BLE_GAP_AUTH_KEY_TYPE_PASSKEY) + { + err_code = sd_ble_gap_auth_key_reply(p_gap_evt->conn_handle, BLE_GAP_AUTH_KEY_TYPE_PASSKEY, passkey); + APP_ERROR_CHECK(err_code); + } + + } break; default: break; diff --git a/examples/ble_central/ble_app_gatts/pca10040/s132/config/sdk_config.h b/examples/ble_central/ble_app_gatts/pca10040/s132/config/sdk_config.h index c48d10b..96949d4 100644 --- a/examples/ble_central/ble_app_gatts/pca10040/s132/config/sdk_config.h +++ b/examples/ble_central/ble_app_gatts/pca10040/s132/config/sdk_config.h @@ -7434,7 +7434,7 @@ // NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend //========================================================== #ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 0 +#define NRF_LOG_BACKEND_RTT_ENABLED 1 #endif // NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. // Size of the buffer is a trade-off between RAM usage and processing. @@ -7467,7 +7467,7 @@ // NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend //========================================================== #ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 1 +#define NRF_LOG_BACKEND_UART_ENABLED 0 #endif // NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin #ifndef NRF_LOG_BACKEND_UART_TX_PIN diff --git a/examples/ble_peripheral/ble_app_gatts_c/main.c b/examples/ble_peripheral/ble_app_gatts_c/main.c index ebd2823..74a8a9c 100644 --- a/examples/ble_peripheral/ble_app_gatts_c/main.c +++ b/examples/ble_peripheral/ble_app_gatts_c/main.c @@ -147,6 +147,7 @@ static void gap_params_init(void) ret_code_t err_code; ble_gap_conn_params_t gap_conn_params; ble_gap_conn_sec_mode_t sec_mode; + ble_opt_t ble_opt; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); @@ -164,6 +165,11 @@ static void gap_params_init(void) err_code = sd_ble_gap_ppcp_set(&gap_conn_params); APP_ERROR_CHECK(err_code); + + ble_opt.gap_opt.passkey.p_passkey = "000000"; + + err_code = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &ble_opt); + APP_ERROR_CHECK(err_code); } diff --git a/examples/ble_peripheral/ble_app_gatts_c/pca10040/s132/config/sdk_config.h b/examples/ble_peripheral/ble_app_gatts_c/pca10040/s132/config/sdk_config.h index 93b1b15..efe405d 100644 --- a/examples/ble_peripheral/ble_app_gatts_c/pca10040/s132/config/sdk_config.h +++ b/examples/ble_peripheral/ble_app_gatts_c/pca10040/s132/config/sdk_config.h @@ -90,7 +90,7 @@ // <4=> BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY #ifndef SEC_PARAM_IO_CAPABILITIES -#define SEC_PARAM_IO_CAPABILITIES 3 +#define SEC_PARAM_IO_CAPABILITIES 0 #endif // SEC_PARAM_MAX_KEY_SIZE - Maximum encryption key size in octets between SEC_PARAM_MIN_KEY_SIZE and 16. <0-16> @@ -111,7 +111,7 @@ #ifndef SEC_PARAM_MITM -#define SEC_PARAM_MITM 0 +#define SEC_PARAM_MITM 1 #endif // SEC_PARAM_OOB - Out Of Band data not available or not @@ -7419,7 +7419,7 @@ // NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend //========================================================== #ifndef NRF_LOG_BACKEND_RTT_ENABLED -#define NRF_LOG_BACKEND_RTT_ENABLED 0 +#define NRF_LOG_BACKEND_RTT_ENABLED 1 #endif // NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. // Size of the buffer is a trade-off between RAM usage and processing. @@ -7452,7 +7452,7 @@ // NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend //========================================================== #ifndef NRF_LOG_BACKEND_UART_ENABLED -#define NRF_LOG_BACKEND_UART_ENABLED 1 +#define NRF_LOG_BACKEND_UART_ENABLED 0 #endif // NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin #ifndef NRF_LOG_BACKEND_UART_TX_PIN