Commit c066acf0 authored by Donald Chen's avatar Donald Chen

remove workarounds

parent 3f9cb4de
......@@ -617,11 +617,9 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
printf("Connected, connection handle 0x%04X\n", p_ble_evt->evt.gap_evt.conn_handle);
fflush(stdout);
//DSC: for some reason this evt does not always get fired, so I set in the cccd write as well
m_connection_handle = p_ble_evt->evt.gap_evt.conn_handle;
printf("Connected, connection handle 0x%04X\n", m_connection_handle);
fflush(stdout);
break;
case BLE_GAP_EVT_DISCONNECTED:
......@@ -639,7 +637,7 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
err_code = sd_ble_gatts_sys_attr_set(adapter, p_ble_evt->evt.gap_evt.conn_handle, NULL, 0, 0);
err_code = sd_ble_gatts_sys_attr_set(adapter, m_connection_handle, NULL, 0, 0);
if (err_code != NRF_SUCCESS)
{
......@@ -653,32 +651,13 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
m_heart_rate_measurement_handle.cccd_handle)
{
uint8_t write_data = p_ble_evt->evt.gatts_evt.params.write.data[0];
//DSC: set conn handle here since the connected event isn't always recieved
m_connection_handle = p_ble_evt->evt.gatts_evt.conn_handle;
m_send_notifications = write_data == BLE_GATT_HVX_NOTIFICATION;
printf("HRM CCCD write: conn_hndl %d, enabled %d\n", m_connection_handle, m_send_notifications);
fflush(stdout);
}
break;
case BLE_GAP_EVT_CONN_PARAM_UPDATE:
{
ble_gap_conn_params_t * p_cp = &p_ble_evt->evt.gap_evt.params.conn_param_update.conn_params;
printf("Connection params updated: i_min %d, i_max %d, supp_to %d, s_lat %d\n",
p_cp->min_conn_interval,
p_cp->max_conn_interval,
p_cp->conn_sup_timeout,
p_cp->slave_latency);
fflush(stdout);
}
break;
#if NRF_SD_BLE_API >= 3
case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
err_code = sd_ble_gatts_exchange_mtu_reply(adapter, p_ble_evt->evt.gap_evt.conn_handle,
err_code = sd_ble_gatts_exchange_mtu_reply(adapter, m_connection_handle,
GATT_MTU_SIZE_DEFAULT);
if (err_code != NRF_SUCCESS)
......@@ -689,45 +668,15 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
break;
#endif
#if NRF_SD_BLE_API >= 4
case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
{
ble_gap_data_length_params_t *p_params = NULL;// &p_ble_evt->evt.gap_evt.params.data_length_update_request.peer_params;
err_code = sd_ble_gap_data_length_update(adapter, p_ble_evt->evt.gap_evt.conn_handle, p_params, NULL);
printf("Data length update request. Error code: 0x%02X\n", err_code);
fflush(stdout);
}
break;
case BLE_GAP_EVT_DATA_LENGTH_UPDATE:
printf("Data length updated.\n");
fflush(stdout);
break;
case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
{
ble_gap_phys_t phys = {BLE_GAP_PHY_1MBPS,BLE_GAP_PHY_1MBPS};
err_code = sd_ble_gap_phy_update(adapter, p_ble_evt->evt.gap_evt.conn_handle, &phys);
printf("PHY update request. Error code: 0x%02X\n", err_code);
fflush(stdout);
}
break;
case BLE_GAP_EVT_PHY_UPDATE:
printf("PHY updated.\n");
fflush(stdout);
break;
#endif
#if NRF_SD_BLE_API <= 3
case BLE_EVT_TX_COMPLETE:
#else
case BLE_GATTS_EVT_HVN_TX_COMPLETE:
#endif
printf("Successfully transmitted a heart rate reading.\n");
#ifdef DEBUG
printf("Successfully transmitted a heart rate reading.");
fflush(stdout);
#endif
break;
default:
......@@ -830,6 +779,7 @@ int main(int argc, char * argv[])
{
heart_rate_measurement_send();
}
Sleep(1000);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment