Skip to content

Commit

Permalink
Merge pull request #196 from HaoboGu/fix/peripheral_conn_param
Browse files Browse the repository at this point in the history
Set conn param from central, not peripheral
  • Loading branch information
HaoboGu authored Dec 17, 2024
2 parents 8de5e87 + 0e34713 commit d4e4786
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
6 changes: 6 additions & 0 deletions rmk/src/split/nrf/central.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ pub(crate) async fn run_ble_client(
loop {
let addrs = &[&Address::new(AddressType::RandomStatic, addr)];
let mut config: central::ConnectConfig<'_> = central::ConnectConfig::default();
config.conn_params = nrf_softdevice::raw::ble_gap_conn_params_t {
min_conn_interval: 6,
max_conn_interval: 6,
slave_latency: 99,
conn_sup_timeout: 500, // timeout: 5s
};
config.scan_config.whitelist = Some(addrs);
let conn = loop {
if let Ok(_) =
Expand Down
18 changes: 5 additions & 13 deletions rmk/src/split/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,12 @@ pub(crate) async fn initialize_nrf_ble_split_peripheral_and_run<
spawner: Spawner,
) -> ! {
use defmt::info;
use embassy_futures::{join::join, select::select3};
use embassy_futures::select::select3;
use nrf_softdevice::ble::gatt_server;

use crate::{
ble::nrf::set_conn_params,
split::nrf::peripheral::{
BleSplitPeripheralDriver, BleSplitPeripheralServer, BleSplitPeripheralServerEvent,
SplitBleServiceEvent,
},
use crate::split::nrf::peripheral::{
BleSplitPeripheralDriver, BleSplitPeripheralServer, BleSplitPeripheralServerEvent,
SplitBleServiceEvent,
};

let ble_config = Config {
Expand Down Expand Up @@ -250,12 +247,7 @@ pub(crate) async fn initialize_nrf_ble_split_peripheral_and_run<
let mut peripheral = SplitPeripheral::new(BleSplitPeripheralDriver::new(&server, &conn));
let peripheral_fut = peripheral.run();
let matrix_fut = matrix.scan();
select3(
matrix_fut,
join(server_fut, set_conn_params(&conn)),
peripheral_fut,
)
.await;
select3(matrix_fut, server_fut, peripheral_fut).await;
}
}

Expand Down

0 comments on commit d4e4786

Please sign in to comment.