uint32_t conn_mw_ble_gap_ppcp_get(uint8_t const * const p_rx_buf, uint32_t rx_buf_len, uint8_t * const p_tx_buf, uint32_t * const p_tx_buf_len) { SER_ASSERT_NOT_NULL(p_rx_buf); SER_ASSERT_NOT_NULL(p_tx_buf); SER_ASSERT_NOT_NULL(p_tx_buf_len); ble_gap_conn_params_t conn_params; ble_gap_conn_params_t * p_conn_params = &conn_params; uint32_t err_code = NRF_SUCCESS; uint32_t sd_err_code; err_code = ble_gap_ppcp_get_req_dec(p_rx_buf, rx_buf_len, &p_conn_params); SER_ASSERT(err_code == NRF_SUCCESS, err_code); sd_err_code = sd_ble_gap_ppcp_get(p_conn_params); err_code = ble_gap_ppcp_get_rsp_enc(sd_err_code, p_tx_buf, p_tx_buf_len, p_conn_params); SER_ASSERT(err_code == NRF_SUCCESS, err_code); return err_code; }
uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init) { uint32_t err_code; m_conn_params_config = *p_init; m_change_param = false; if (p_init->p_conn_params != NULL) { m_preferred_conn_params = *p_init->p_conn_params; // Set the connection params in stack err_code = sd_ble_gap_ppcp_set(&m_preferred_conn_params); if (err_code != NRF_SUCCESS) { return err_code; } } else { // Fetch the connection params from stack err_code = sd_ble_gap_ppcp_get(&m_preferred_conn_params); if (err_code != NRF_SUCCESS) { return err_code; } } m_conn_handle = BLE_CONN_HANDLE_INVALID; m_update_count = 0; return app_timer_create(&m_conn_params_timer_id, APP_TIMER_MODE_SINGLE_SHOT, update_timeout_handler); }
ble_error_t nRF5xGap::getPreferredConnectionParams(ConnectionParams_t *params) { ASSERT_INT(NRF_SUCCESS, sd_ble_gap_ppcp_get(reinterpret_cast<ble_gap_conn_params_t *>(params)), BLE_ERROR_PARAM_OUT_OF_RANGE); return BLE_ERROR_NONE; }
/**@brief Function for decoding a command packet with RPC_SD_BLE_GAP_PPCP_GET opcode. * * This function will decode the command, call the BLE Stack API, and also send command response * to the peer through the the transport layer. * * @param[in] p_command The encoded structure that needs to be decoded and passed on * to the BLE Stack API. * @param[in] command_len The length of the encoded command read from transport layer. * * @retval NRF_SUCCESS If the decoding of the command was successful, the SoftDevice * API was called, and the command response was sent to peer, * otherwise an error code. * @retval NRF_ERROR_INVALID_LENGTH If the content length of the packet is not conforming to the * codec specification. */ static uint32_t gap_ppcp_get_handle(uint8_t * p_command, uint32_t command_len) { uint32_t err_code; ble_gap_conn_params_t conn_params; uint8_t resp_data[sizeof(ble_gap_conn_params_t)]; uint8_t encode_index = 0; uint32_t index = 0; // Pointer to the connection parameters result buffer. ble_gap_conn_params_t * p_conn_params = &conn_params; // If length field is not present. if (p_command[index++] == RPC_BLE_FIELD_NOT_PRESENT) { p_conn_params = NULL; } RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GAP_PPCP_GET); err_code = sd_ble_gap_ppcp_get(p_conn_params); if (err_code == NRF_SUCCESS) { encode_index += uint16_encode(p_conn_params->min_conn_interval, &resp_data[encode_index]); encode_index += uint16_encode(p_conn_params->max_conn_interval, &resp_data[encode_index]); encode_index += uint16_encode(p_conn_params->slave_latency , &resp_data[encode_index]); encode_index += uint16_encode(p_conn_params->conn_sup_timeout , &resp_data[encode_index]); return ble_rpc_cmd_resp_data_send(SD_BLE_GAP_PPCP_GET, err_code, resp_data, encode_index); } else { return ble_rpc_cmd_resp_send(SD_BLE_GAP_PPCP_GET, err_code); } }