Hello all, before I decided to write my own question I read the forum thoroughly. How ever no aid found to solve my problem. At first I want to make "just work" bonding(pairing) to encrypt further communication. I saw many nordic examples for this using DeviceManager+pstorage. However my RAM budget could not allow usage of this lib. I try to do this manually without saving keys in flash( at present revision). When initiate pairing from windows 8.1 the flow are next (in debug):
BLE_GAP_EVT_CONNECTED
BLE_GAP_ROLE_PERIPH (ID 3)
BLE_GAP_EVT_SEC_PARAMS_REQUEST
Sec params from host:
Bond: 1
Io_caps: 4
kdist_central: 124
kdist_periph: 219
max_key_size: 16
min_key_size: 0
mitm: 1
oob: 0
My peripheral answers:
uint32_t res=sd_ble_gap_sec_params_reply(ble_evt->evt.gap_evt.conn_handle,BLE_GAP_SEC_STATUS_SUCCESS,&m_sec_params,NULL);
where m_sec_params are:
#define SEC_PARAM_BOND 1
#define SEC_PARAM_MITM 0
#define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE
#define SEC_PARAM_OOB 0
#define SEC_PARAM_MIN_KEY_SIZE 7
#define SEC_PARAM_MAX_KEY_SIZE 16
BLE_GAP_EVT_AUTH_STATUS
Auth status: 0x88 , Src: Remote
//BLE_GAP_SEC_STATUS_UNSPECIFIED 0x88 /**< Unspecified reason. */
Disconnect from host, reason 19
//BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13
/**< Remote User Terminated Connection. */
When initiate pairing from Android the flow are next:
BLE_GAP_EVT_CONNECTED
BLE_GAP_ROLE_PERIPH (ID: 3)
BLE_GAP_EVT_SEC_PARAMS_REQUEST
Sec params from host:
Bond: 1
Io_caps: 4
kdist_central: 231
kdist_periph: 119
max_key_size: 16
min_key_size: 0
mitm: 1
oob: 0
BLE_GAP_EVT_CONN_SEC_UPDATE
BLE_GAP_EVT_AUTH_STATUS
Auth status: 00, Src: Local
//Success.
Than I have a look on examples: and found that windows 8.1 paired correctly when at BLE_GAP_EVT_SEC_PARAMS_REQUEST peripheral answers:
uint32_t res=sd_ble_gap_sec_params_reply(ble_evt->evt.gap_evt.conn_handle,BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,NULL,NULL);
Then central (windows) disconnects and reconnects. Now it is possible to work with device.
The problem is that Android do not support such trick. i.e. BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP
and show the pairing failure.
Please help to make device bondable/pairable on both win and android devices.
Or may be it would beter to show key pieces of code from DM where it made properly.
best regards.