This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can't send data after re-bonding

Hi

I'm working on nRF52832 with SDK 15.2.0.

I have a device which is based on ble_app_hrs_rscs_relay.

I added pm_handler_secure_on_connection in ble_evt_handler and set PM_HANDLER_SEC_DELAY_MS to 4000.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
uint16_t conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
uint16_t role = ble_conn_state_role(conn_handle);
// Based on the role this device plays in the connection, dispatch to the right handler.
if (role == BLE_GAP_ROLE_PERIPH || ble_evt_is_advertising_timeout(p_ble_evt))
{
pm_handler_secure_on_connection(p_ble_evt);
ble_hrs_on_ble_evt(p_ble_evt, &m_hrs);
ble_rscs_on_ble_evt(p_ble_evt, &m_rscs);
on_ble_peripheral_evt(p_ble_evt);
}
else if ((role == BLE_GAP_ROLE_CENTRAL) || (p_ble_evt->header.evt_id == BLE_GAP_EVT_ADV_REPORT))
{
ble_hrs_c_on_ble_evt(p_ble_evt, &m_hrs_c);
ble_rscs_c_on_ble_evt(p_ble_evt, &m_rscs_c);
on_ble_central_evt(p_ble_evt);
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I also set hrs_init.hrm_cccd_wr_sec/hrs_init.bsl_rd_sec/rscs_init.rsc_feature_rd_sec/rscs_init.rsc_meas_cccd_wr_sec to SEC_JUST_WORKS.

 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
hrs_init.evt_handler = NULL;
hrs_init.is_sensor_contact_supported = true;
hrs_init.p_body_sensor_location = &body_sensor_location;
// Here the sec level for the Heart Rate Service can be changed or increased.
hrs_init.hrm_cccd_wr_sec = SEC_JUST_WORKS;//SEC_OPEN;
hrs_init.bsl_rd_sec = SEC_JUST_WORKS;//SEC_OPEN;
err_code = ble_hrs_init(&m_hrs, &hrs_init);
APP_ERROR_CHECK(err_code);
// Initialize the Running Speed and Cadence Service.
memset(&rscs_init, 0, sizeof(rscs_init));
rscs_init.evt_handler = NULL;
rscs_init.feature = BLE_RSCS_FEATURE_INSTANT_STRIDE_LEN_BIT |
BLE_RSCS_FEATURE_WALKING_OR_RUNNING_STATUS_BIT;
// Here the sec level for the Running Speed and Cadence Service can be changed or increased.
rscs_init.rsc_feature_rd_sec = SEC_JUST_WORKS;//SEC_OPEN;
rscs_init.rsc_meas_cccd_wr_sec = SEC_JUST_WORKS;//SEC_OPEN;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The first time I used iphone to connect my device and everything went well.

But, when I erased my device and used iphone to connect again.

Iphone will show pairing request dialog, after I pressed "Pair" option, I can't send or receive any data from my device.

Does anyone know how to fix this issue?