Loading system/gd/rust/linux/client/src/command_handler.rs +21 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,7 @@ fn build_commands() -> HashMap<String, CommandOption> { String::from("advertise <on|off|ext>"), String::from("advertise set-interval <ms>"), String::from("advertise set-scan-rsp <enable|disable>"), String::from("advertise set-raw-data <raw-adv-data> <adv-id>"), ], description: String::from("Advertising utilities."), function_pointer: CommandHandler::cmd_advertise, Loading Loading @@ -1256,6 +1257,26 @@ impl CommandHandler { context.gatt_dbus.as_mut().unwrap().set_advertising_parameters(adv_id, params); } } "set-raw-data" => { let data = hex::decode(get_arg(args, 1)?).or(Err("Failed parsing data"))?; let adv_id = String::from(get_arg(args, 2)?) .parse::<i32>() .or(Err("Failed parsing adv_id"))?; let mut context = self.context.lock().unwrap(); if context .adv_sets .iter() .find(|(_, s)| s.adv_id.map_or(false, |id| id == adv_id)) .is_none() { return Err("Failed to find advertising set".into()); } print_info!("Setting advertising data for {}", adv_id); context.gatt_dbus.as_mut().unwrap().set_raw_adv_data(adv_id, data); } _ => return Err(CommandError::InvalidArgs), } Loading system/gd/rust/linux/client/src/dbus_iface.rs +5 −0 Original line number Diff line number Diff line Loading @@ -1071,6 +1071,11 @@ impl IBluetoothGatt for BluetoothGattDBus { dbus_generated!() } #[dbus_method("SetRawAdvertisingData")] fn set_raw_adv_data(&mut self, advertiser_id: i32, data: Vec<u8>) { dbus_generated!() } #[dbus_method("SetScanResponseData")] fn set_scan_response_data(&mut self, advertiser_id: i32, data: AdvertiseData) { dbus_generated!() Loading system/gd/rust/linux/service/src/iface_bluetooth_gatt.rs +5 −0 Original line number Diff line number Diff line Loading @@ -565,6 +565,11 @@ impl IBluetoothGatt for IBluetoothGattDBus { dbus_generated!() } #[dbus_method("SetRawAdvertisingData")] fn set_raw_adv_data(&mut self, advertiser_id: i32, data: Vec<u8>) { dbus_generated!() } #[dbus_method("SetScanResponseData")] fn set_scan_response_data(&mut self, advertiser_id: i32, data: AdvertiseData) { dbus_generated!() Loading system/gd/rust/linux/stack/src/bluetooth_gatt.rs +17 −0 Original line number Diff line number Diff line Loading @@ -352,6 +352,9 @@ pub trait IBluetoothGatt { /// Updates advertisement data of the advertising set. fn set_advertising_data(&mut self, advertiser_id: i32, data: AdvertiseData); /// Set the advertisement data of the advertising set. fn set_raw_adv_data(&mut self, advertiser_id: i32, data: Vec<u8>); /// Updates scan response of the advertising set. fn set_scan_response_data(&mut self, advertiser_id: i32, data: AdvertiseData); Loading Loading @@ -1504,6 +1507,20 @@ impl IBluetoothGatt for BluetoothGatt { } } fn set_raw_adv_data(&mut self, advertiser_id: i32, data: Vec<u8>) { if self.advertisers.suspend_mode() != SuspendMode::Normal { return; } if let Some(s) = self.advertisers.get_by_advertiser_id(advertiser_id) { self.gatt.as_ref().unwrap().lock().unwrap().advertiser.set_data( s.adv_id(), false, data, ); } } fn set_scan_response_data(&mut self, advertiser_id: i32, data: AdvertiseData) { if self.advertisers.suspend_mode() != SuspendMode::Normal { return; Loading Loading
system/gd/rust/linux/client/src/command_handler.rs +21 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,7 @@ fn build_commands() -> HashMap<String, CommandOption> { String::from("advertise <on|off|ext>"), String::from("advertise set-interval <ms>"), String::from("advertise set-scan-rsp <enable|disable>"), String::from("advertise set-raw-data <raw-adv-data> <adv-id>"), ], description: String::from("Advertising utilities."), function_pointer: CommandHandler::cmd_advertise, Loading Loading @@ -1256,6 +1257,26 @@ impl CommandHandler { context.gatt_dbus.as_mut().unwrap().set_advertising_parameters(adv_id, params); } } "set-raw-data" => { let data = hex::decode(get_arg(args, 1)?).or(Err("Failed parsing data"))?; let adv_id = String::from(get_arg(args, 2)?) .parse::<i32>() .or(Err("Failed parsing adv_id"))?; let mut context = self.context.lock().unwrap(); if context .adv_sets .iter() .find(|(_, s)| s.adv_id.map_or(false, |id| id == adv_id)) .is_none() { return Err("Failed to find advertising set".into()); } print_info!("Setting advertising data for {}", adv_id); context.gatt_dbus.as_mut().unwrap().set_raw_adv_data(adv_id, data); } _ => return Err(CommandError::InvalidArgs), } Loading
system/gd/rust/linux/client/src/dbus_iface.rs +5 −0 Original line number Diff line number Diff line Loading @@ -1071,6 +1071,11 @@ impl IBluetoothGatt for BluetoothGattDBus { dbus_generated!() } #[dbus_method("SetRawAdvertisingData")] fn set_raw_adv_data(&mut self, advertiser_id: i32, data: Vec<u8>) { dbus_generated!() } #[dbus_method("SetScanResponseData")] fn set_scan_response_data(&mut self, advertiser_id: i32, data: AdvertiseData) { dbus_generated!() Loading
system/gd/rust/linux/service/src/iface_bluetooth_gatt.rs +5 −0 Original line number Diff line number Diff line Loading @@ -565,6 +565,11 @@ impl IBluetoothGatt for IBluetoothGattDBus { dbus_generated!() } #[dbus_method("SetRawAdvertisingData")] fn set_raw_adv_data(&mut self, advertiser_id: i32, data: Vec<u8>) { dbus_generated!() } #[dbus_method("SetScanResponseData")] fn set_scan_response_data(&mut self, advertiser_id: i32, data: AdvertiseData) { dbus_generated!() Loading
system/gd/rust/linux/stack/src/bluetooth_gatt.rs +17 −0 Original line number Diff line number Diff line Loading @@ -352,6 +352,9 @@ pub trait IBluetoothGatt { /// Updates advertisement data of the advertising set. fn set_advertising_data(&mut self, advertiser_id: i32, data: AdvertiseData); /// Set the advertisement data of the advertising set. fn set_raw_adv_data(&mut self, advertiser_id: i32, data: Vec<u8>); /// Updates scan response of the advertising set. fn set_scan_response_data(&mut self, advertiser_id: i32, data: AdvertiseData); Loading Loading @@ -1504,6 +1507,20 @@ impl IBluetoothGatt for BluetoothGatt { } } fn set_raw_adv_data(&mut self, advertiser_id: i32, data: Vec<u8>) { if self.advertisers.suspend_mode() != SuspendMode::Normal { return; } if let Some(s) = self.advertisers.get_by_advertiser_id(advertiser_id) { self.gatt.as_ref().unwrap().lock().unwrap().advertiser.set_data( s.adv_id(), false, data, ); } } fn set_scan_response_data(&mut self, advertiser_id: i32, data: AdvertiseData) { if self.advertisers.suspend_mode() != SuspendMode::Normal { return; Loading