diff --git a/crates/rns-interface/src/ble_peer.rs b/crates/rns-interface/src/ble_peer.rs index 2e53593..382edee 100644 --- a/crates/rns-interface/src/ble_peer.rs +++ b/crates/rns-interface/src/ble_peer.rs @@ -433,8 +433,6 @@ pub struct BlePeerConfig { /// 16-byte Reticulum identity hash for this node. pub identity_hash: Vec, pub mode: InterfaceMode, - /// Prefer lower-duty BLE advertising when the platform exposes that knob. - pub low_power_advertising: bool, } impl BlePeerConfig { @@ -443,25 +441,10 @@ impl BlePeerConfig { name: name.to_string(), identity_hash, mode: InterfaceMode::Full, - low_power_advertising: false, } } } -#[cfg(any(target_os = "android", test))] -const ANDROID_ADVERTISE_MODE_BALANCED: i32 = 1; -#[cfg(any(target_os = "android", test))] -const ANDROID_ADVERTISE_MODE_LOW_LATENCY: i32 = 2; - -#[cfg(any(target_os = "android", test))] -fn android_advertise_mode(low_power_advertising: bool) -> i32 { - if low_power_advertising { - ANDROID_ADVERTISE_MODE_BALANCED - } else { - ANDROID_ADVERTISE_MODE_LOW_LATENCY - } -} - const FRAGMENT_HEADER_LEN: usize = 5; #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -1118,10 +1101,7 @@ pub fn init_android_jvm(vm: jni::JavaVM) { android_peripheral::init_jvm(vm); } -pub async fn start_peripheral( - _identity_hash: &[u8], - _low_power_advertising: bool, -) -> Result<(), String> { +pub async fn start_peripheral(_identity_hash: &[u8]) -> Result<(), String> { #[cfg(any(target_os = "ios", target_os = "macos"))] { return apple_peripheral::start_advertising(_identity_hash).await; @@ -1129,7 +1109,7 @@ pub async fn start_peripheral( #[cfg(target_os = "android")] { - return android_peripheral::start_advertising(_identity_hash, _low_power_advertising).await; + return android_peripheral::start_advertising(_identity_hash).await; } #[cfg(target_os = "linux")] @@ -2795,10 +2775,7 @@ mod android_peripheral { Ok(jni::objects::JClass::from(cls)) } - pub async fn start_advertising( - identity_hash: &[u8], - low_power_advertising: bool, - ) -> Result<(), String> { + pub async fn start_advertising(identity_hash: &[u8]) -> Result<(), String> { // Set up inbound channel for GATT server write callbacks (see INBOUND_TX docs) let (tx, rx) = tokio::sync::mpsc::channel::<(String, Vec)>(INBOUND_CAPACITY); let _ = INBOUND_TX.set(tx); @@ -2843,15 +2820,13 @@ mod android_peripheral { return Err("BluetoothLeAdvertiser unavailable (multi-adv not supported?)".into()); } - // Build AdvertiseSettings. Keep TX power high for range; the - // optional low-power mode only changes the advertising interval. + // Build AdvertiseSettings let settings_cls = env.find_class("android/bluetooth/le/AdvertiseSettings$Builder") .map_err(|e| format!("{e}"))?; let builder = env.new_object(settings_cls, "()V", &[]).map_err(|e| format!("{e}"))?; - let advertise_mode = super::android_advertise_mode(low_power_advertising); env.call_method(builder, "setAdvertiseMode", "(I)Landroid/bluetooth/le/AdvertiseSettings$Builder;", - &[JValue::Int(advertise_mode)]).ok(); // 1=BALANCED, 2=LOW_LATENCY + &[JValue::Int(1)]).ok(); // BALANCED jni_clear(env); env.call_method(builder, "setTxPowerLevel", "(I)Landroid/bluetooth/le/AdvertiseSettings$Builder;", @@ -2910,11 +2885,7 @@ mod android_peripheral { let _ = ADVERTISER_REF.set(env.new_global_ref(advertiser).map_err(|e| format!("{e}"))?); let _ = CALLBACK_REF.set(callback_ref); - tracing::info!( - low_power_advertising, - advertise_mode, - "Android BLE Peripheral: advertising started" - ); + tracing::info!("Android BLE Peripheral: advertising started"); Ok(()) }) }).await.map_err(|e| format!("{e}"))? @@ -4739,7 +4710,7 @@ pub async fn spawn_ble_peer_interface( mark_running(); // Start peripheral (GATT server + advertising) - if let Err(e) = start_peripheral(&config.identity_hash, config.low_power_advertising).await { + if let Err(e) = start_peripheral(&config.identity_hash).await { tracing::warn!(name = %name, error = %e, "BLE Peripheral start failed, running Central-only"); } @@ -6172,19 +6143,6 @@ mod tests { assert_eq!(cfg.name, "mesh0"); assert_eq!(cfg.identity_hash.len(), 16); assert_eq!(cfg.mode, InterfaceMode::Full); - assert!(!cfg.low_power_advertising); - } - - #[test] - fn test_android_advertising_mode_defaults_to_low_latency() { - assert_eq!( - android_advertise_mode(false), - ANDROID_ADVERTISE_MODE_LOW_LATENCY - ); - assert_eq!( - android_advertise_mode(true), - ANDROID_ADVERTISE_MODE_BALANCED - ); } // ── BlePeer struct serialization ── diff --git a/crates/rns-runtime/src/reticulum.rs b/crates/rns-runtime/src/reticulum.rs index d79c137..87fe2bf 100644 --- a/crates/rns-runtime/src/reticulum.rs +++ b/crates/rns-runtime/src/reticulum.rs @@ -2912,13 +2912,11 @@ pub async fn spawn_ble_peer_runtime( event_tx: Option>, foreground_wake: std::sync::Arc, seed_identities: Vec, - low_power_advertising: bool, ) -> Result { let id = handle .id_gen .fetch_add(1, std::sync::atomic::Ordering::SeqCst); - let mut config = rns_interface::ble_peer::BlePeerConfig::new(name, identity_hash); - config.low_power_advertising = low_power_advertising; + let config = rns_interface::ble_peer::BlePeerConfig::new(name, identity_hash); // Install before start so initial scan/connect events aren't dropped. if let Some(tx) = event_tx {