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

How to disable indications inside central coming from the peripheral without disconnecting? I am using nRF52832.

In my current project, I am receiving multiple indications from peripheral device. After 25 indications, I need to pause the indications or disable the indications. I am using Soft Device S132. Is there any way?

I am using following code: 

static ret_code_t cccd_configure(uint16_t conn_handle, uint16_t cccd_handle, uint16_t hvx_type) {
  tx_message_t *p_msg;
  p_msg = &m_tx_buffer[m_tx_insert_index++];
  m_tx_insert_index &= TX_BUFFER_MASK;

  p_msg->req.write_req.gattc_params.handle = cccd_handle;
  p_msg->req.write_req.gattc_params.len = WRITE_MESSAGE_LENGTH;
  p_msg->req.write_req.gattc_params.p_value = p_msg->req.write_req.gattc_value;
  p_msg->req.write_req.gattc_params.offset = 0;
  p_msg->req.write_req.gattc_params.write_op = BLE_GATT_OP_WRITE_REQ;
  p_msg->req.write_req.gattc_value[0] = LSB_16(hvx_type);
  p_msg->req.write_req.gattc_value[1] = MSB_16(hvx_type);
  p_msg->conn_handle = conn_handle;
  p_msg->type = WRITE_REQ;

  tx_buffer_process();
  return NRF_SUCCESS;
}

ret_code_t ble_apg_c_indication_disable(ble_apg_c_t *p_ble_apg_c, uint16_t uuid_value) {
  VERIFY_PARAM_NOT_NULL(p_ble_apg_c);

  uint16_t cccd_handle = get_cccd_handle_to_indicate(p_ble_apg_c, uuid_value);
  if ((p_ble_apg_c->conn_handle == BLE_CONN_HANDLE_INVALID) || (cccd_handle == BLE_GATT_HANDLE_INVALID))
    return NRF_ERROR_INVALID_STATE;

  return cccd_configure(p_ble_apg_c->conn_handle, cccd_handle, 0);
}

Parents Reply
  • ret_code_t ble_apg_c_indication_enable(ble_apg_c_t *p_ble_apg_c, uint16_t uuid_value) {
      VERIFY_PARAM_NOT_NULL(p_ble_apg_c);
    
      uint16_t cccd_handle = get_cccd_handle_to_indicate(p_ble_apg_c, uuid_value);
      if ((p_ble_apg_c->conn_handle == BLE_CONN_HANDLE_INVALID) || (cccd_handle == BLE_GATT_HANDLE_INVALID))
        return NRF_ERROR_INVALID_STATE;
    
      return cccd_configure(p_ble_apg_c->conn_handle, cccd_handle, BLE_GATT_HVX_INDICATION);
    }

Children
No Data
Related