diff --git a/rmk/src/ble/nrf/bonder.rs b/rmk/src/ble/nrf/bonder.rs index 59b6b298..b68598cf 100644 --- a/rmk/src/ble/nrf/bonder.rs +++ b/rmk/src/ble/nrf/bonder.rs @@ -91,6 +91,10 @@ impl MultiBonder { if let Some(slot_num) = saved_slot_num_for_conn { if slot_num != current_profile { + debug!( + "Bonded device {} is not on active profile {}", + addr, current_profile + ); return false; } } diff --git a/rmk/src/ble/nrf/mod.rs b/rmk/src/ble/nrf/mod.rs index c987211c..b94fa83f 100644 --- a/rmk/src/ble/nrf/mod.rs +++ b/rmk/src/ble/nrf/mod.rs @@ -259,9 +259,11 @@ pub async fn initialize_nrf_ble_keyboard_and_run< if let Ok(Some(StorageData::ActiveBleProfile(profile))) = read_storage!(storage, &(StorageKeys::ActiveBleProfile as u32), buf) { + debug!("Loaded active profile: {}", profile); ACTIVE_PROFILE.store(profile, Ordering::SeqCst); } else { // If no saved active profile, use 0 as default + debug!("Loaded default active profile",); ACTIVE_PROFILE.store(0, Ordering::SeqCst); }; @@ -567,7 +569,9 @@ pub(crate) async fn run_dummy_keyboard< warn!("Dummy service receives") } }; - + // Even for dummy service, we need to set the connection state to true. + // So that we can receive the matrix scan result from split, which might be used for profile switching + CONNECTION_STATE.store(true, Ordering::Release); match select4(matrix_fut, keyboard_fut, storage_fut, dummy_communication).await { Either4::First(_) => (), Either4::Second(_) => (), diff --git a/rmk/src/keyboard.rs b/rmk/src/keyboard.rs index 272cd988..896dbd56 100644 --- a/rmk/src/keyboard.rs +++ b/rmk/src/keyboard.rs @@ -748,6 +748,7 @@ impl<'a, const ROW: usize, const COL: usize, const NUM_LAYER: usize> // Get user key id let id = key as u8 - KeyCode::User0 as u8; if id < 8 { + info!("Switch to profile: {}", id); // User0~7: Swtich to the specific profile BLE_PROFILE_CHANNEL .send(BleProfileAction::SwitchProfile(id)) diff --git a/rmk/src/lib.rs b/rmk/src/lib.rs index 0b6a694f..e7d889c1 100644 --- a/rmk/src/lib.rs +++ b/rmk/src/lib.rs @@ -85,7 +85,7 @@ pub(crate) static KEYBOARD_STATE: AtomicBool = AtomicBool::new(false); /// - 1: BLE /// - Other: reserved pub(crate) static CONNECTION_TYPE: AtomicU8 = AtomicU8::new(0); -/// Whethe the connection is ready. +/// Whether the connection is ready. /// After the connection is ready, the matrix starts scanning pub(crate) static CONNECTION_STATE: AtomicBool = AtomicBool::new(false); diff --git a/rmk/src/split/nrf/central.rs b/rmk/src/split/nrf/central.rs index 543addbf..10004e70 100644 --- a/rmk/src/split/nrf/central.rs +++ b/rmk/src/split/nrf/central.rs @@ -104,6 +104,8 @@ pub(crate) async fn run_ble_client( embassy_time::Timer::after_millis(200).await; }; + info!("Connected to peripheral"); + let ble_client: BleSplitCentralClient = match gatt_client::discover(&conn).await { Ok(client) => client, Err(e) => { diff --git a/rmk/src/split/peripheral.rs b/rmk/src/split/peripheral.rs index 619d971e..4e365dc6 100644 --- a/rmk/src/split/peripheral.rs +++ b/rmk/src/split/peripheral.rs @@ -150,6 +150,7 @@ impl SplitPeripheral { // Currently only handle the central state message Ok(split_message) => match split_message { SplitMessage::ConnectionState(state) => { + info!("Received connection state update: {}", state); CONNECTION_STATE.store(state, core::sync::atomic::Ordering::Release); } _ => (),