1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
use crate::interface::class::from_bytes as class_from_bytes; use super::*; impl<'a> BlueZClient<'a> { /// This command is used to set the major and minor device class for /// BR/EDR capable controllers. /// /// This command will also implicitly disable caching of pending CoD /// and EIR updates. /// /// This command is only available for BR/EDR capable controllers /// (e.g. not for single-mode LE ones). /// /// This command can be used when the controller is not powered and /// all settings will be programmed once powered. /// /// In case the controller is powered off, Unknown will be returned /// for the class of device parameter. And after power on the new /// value will be announced via class of device changed event. pub async fn set_device_class( &mut self, controller: Controller, device_class: DeviceClass, ) -> Result<(DeviceClass, ServiceClasses)> { let mut param = BytesMut::with_capacity(2); param.put_u16_le(device_class.into()); self.exec_command( Command::SetDeviceClass, controller, Some(param.to_bytes()), |_, param| Ok(class_from_bytes(param.unwrap())), ) .await } /// This command is used to add a UUID to be published in EIR data. /// The accompanied SVC_Hint parameter is used to tell the kernel /// whether the service class bits of the Class of Device value need /// modifying due to this UUID. /// /// This command can be used when the controller is not powered and /// all settings will be programmed once powered. /// /// In case the controller is powered off, `0x000000` will be returned /// for the class of device parameter. And after power on the new /// value will be announced via class of device changed event. pub async fn add_uuid( &mut self, controller: Controller, uuid: [u8; 16], svc_hint: ServiceClasses, ) -> Result<(DeviceClass, ServiceClasses)> { let mut param = BytesMut::with_capacity(17); param.put_slice(&uuid[..]); param.put_u8((svc_hint.bits() >> 16) as u8); self.exec_command( Command::AddUUID, controller, Some(param.to_bytes()), |_, param| Ok(class_from_bytes(param.unwrap())), ) .await } /// This command is used to remove a UUID previously added using the /// Add UUID command. /// /// When the UUID parameter is an empty UUID (16 x `0x00`), then all /// previously loaded UUIDs will be removed. /// /// This command can be used when the controller is not powered and /// all settings will be programmed once powered. /// /// In case the controller is powered off, `0x000000` will be returned /// for the class of device parameter. And after power on the new /// value will be announced via class of device changed event. pub async fn remove_uuid( &mut self, controller: Controller, uuid: [u8; 16], ) -> Result<(DeviceClass, ServiceClasses)> { let mut param = BytesMut::from(&uuid[..]); self.exec_command( Command::RemoveUUID, controller, Some(param.to_bytes()), |_, param| Ok(class_from_bytes(param.unwrap())), ) .await } }