| 262 | } |
| 263 | |
| 264 | pub async fn discover_services(&mut self) -> Result<&[GattDeviceService]> { |
| 265 | let winrt_error = |e| Error::Other(format!("{:?}", e).into()); |
| 266 | let service_result = self.get_gatt_services(BluetoothCacheMode::Cached).await?; |
| 267 | let status = service_result.Status().map_err(winrt_error)?; |
| 268 | if status == GattCommunicationStatus::Success { |
| 269 | // We need to convert the IVectorView to a Vec, because IVectorView is not Send and so |
| 270 | // can't be help past the await point below. |
| 271 | let services: Vec<_> = service_result |
| 272 | .Services() |
| 273 | .map_err(winrt_error)? |
| 274 | .into_iter() |
| 275 | .collect(); |
| 276 | self.services = services; |
| 277 | debug!("services {:?}", self.services.len()); |
| 278 | } |
| 279 | Ok(self.services.as_slice()) |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | impl Drop for BLEDevice { |