I've been trying to implement bonding and encryption into the ble_app_uart example, and realized that the issues I've been running into were caused by the following configuration.
#define NRF_SDH_BLE_GAP_DATA_LENGTH 251 #define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
Once I changed the values to match the ble_app_gls example, I was able to see successful bonding performed.
#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 #define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 23
These are the security parameters I'm using:
#define SEC_PARAM_BOND 1 /**< Perform bonding. */ #define SEC_PARAM_MITM 1 /**< Man In The Middle protection required (applicable when display module is detected). */ #define SEC_PARAM_LESC 1 /**< LE Secure Connections enabled. */ #define SEC_PARAM_KEYPRESS 0 /**< Keypress notifications not enabled. */ #define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_DISPLAY_ONLY /**< Display 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. */
The above thread is what made me try changing the values, but I would like to get a response from Nordic on the matter. Are the lower values required when bonding + encryption is implemented?
I'm working around this limitation by sending data in 20B chunks, but I wouldn't mind going back to the larger size if possible. I'm anticipating that is a consequence of the secure connection, but just wanted to be sure.