Hi all,
when I insert ble_nus into mesh_gatt . I realized there are two pulse functions with the same function:
void ble_nus_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)
{
if ((p_context == NULL) || (p_ble_evt == NULL))
{
return;
}
ble_nus_t * p_nus = (ble_nus_t *)p_context;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
on_connect(p_nus, p_ble_evt);
break;
case BLE_GATTS_EVT_WRITE:
on_write(p_nus, p_ble_evt);
break;
case BLE_GATTS_EVT_HVN_TX_COMPLETE:
on_hvx_tx_complete(p_nus, p_ble_evt);
break;
default:
// No implementation needed.
break;
}
}
and
void mesh_gatt_on_ble_evt(const ble_evt_t * p_ble_evt, void * p_context)
{
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
connect_evt_handle(p_ble_evt);
break;
case BLE_GAP_EVT_DISCONNECTED:
disconnect_evt_handle(p_ble_evt);
break;
case BLE_GATTS_EVT_WRITE:
write_evt_handle(p_ble_evt);
break;
case BLE_GATTS_EVT_HVN_TX_COMPLETE:
tx_complete_handle(p_ble_evt->evt.gatts_evt.conn_handle);
break;
/* TODO: The following events should be handled by an SDK module/the application. */
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
{
uint32_t err_code = sd_ble_gatts_service_changed(p_ble_evt->evt.gatts_evt.conn_handle,
m_gatt.handles.service,
m_gatt.handles.service);
/* Those errors can be expected when sending trying to send Service Changed indication
* if the CCCD is not set to indicate. Thus set the returning error code to success. */
NRF_MESH_ASSERT((err_code == NRF_SUCCESS) ||
(err_code == BLE_ERROR_INVALID_CONN_HANDLE) ||
(err_code == NRF_ERROR_INVALID_STATE) ||
(err_code == NRF_ERROR_BUSY));
NRF_MESH_ERROR_CHECK(sd_ble_gatts_sys_attr_set(p_ble_evt->evt.gatts_evt.conn_handle, NULL, 0, 0));
break;
}
case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
{
ble_gap_data_length_params_t dl_params;
memset(&dl_params, BLE_GAP_DATA_LENGTH_AUTO, sizeof(dl_params));
NRF_MESH_ERROR_CHECK(sd_ble_gap_data_length_update(p_ble_evt->evt.gap_evt.conn_handle,
&dl_params,
NULL));
break;
}
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
NRF_MESH_ERROR_CHECK(sd_ble_gap_sec_params_reply(p_ble_evt->evt.gap_evt.conn_handle,
BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
NULL,
NULL));
break;
case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
{
ble_gap_phys_t const phys =
{
.rx_phys = BLE_GAP_PHY_AUTO,
.tx_phys = BLE_GAP_PHY_AUTO,
};
NRF_MESH_ERROR_CHECK(sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys));
break;
}
case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
exchange_mtu_req_handle(p_ble_evt);
break;
case BLE_GATTS_EVT_SC_CONFIRM:
break;
default:
break;
}
}
if they let them coexist , when I use nrf_connect connect and use mesh_app connect , It jump to 2 function , and I only want , if I connect to nus , it jump to ble_nus_on_ble_evt , If I connect to proxy , It jump to mesh_gatt_on_ble_evt . Is this feasible? Can you give me advice ? Thank !!!