From a730981f4b90629ffd2ca98b98f87fc4a383d5eb Mon Sep 17 00:00:00 2001 From: Matt Allen Date: Mon, 15 Jul 2024 13:57:48 -0400 Subject: [PATCH 1/2] changed uuid to method --- nrf-softdevice/src/ble/gatt_client.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nrf-softdevice/src/ble/gatt_client.rs b/nrf-softdevice/src/ble/gatt_client.rs index e9d0cd6..5be6a0f 100644 --- a/nrf-softdevice/src/ble/gatt_client.rs +++ b/nrf-softdevice/src/ble/gatt_client.rs @@ -55,7 +55,7 @@ pub trait Client { /// Get the UUID of the GATT service. This is used by [`discover`] to search for the /// service in the GATT server. - fn uuid() -> Uuid; + fn uuid(&self) -> Uuid; /// Create a new instance in a "not-yet-discovered" state. fn new_undiscovered(conn: Connection) -> Self; @@ -278,13 +278,13 @@ async fn discover_inner( pub async fn discover(conn: &Connection) -> Result { // TODO handle drop. Probably doable gracefully (no DropBomb) - let svc = match discover_service(conn, T::uuid()).await { + let mut client = T::new_undiscovered(conn.clone()); + + let svc = match discover_service(conn, client.uuid()).await { Err(DiscoverError::Gatt(GattError::ATTERR_ATTRIBUTE_NOT_FOUND)) => Err(DiscoverError::ServiceNotFound), x => x, }?; - let mut client = T::new_undiscovered(conn.clone()); - let mut curr_handle = svc.handle_range.start_handle; let end_handle = svc.handle_range.end_handle; From c46377a8c7ea946b122bf3a252078fc4d10977a9 Mon Sep 17 00:00:00 2001 From: Matt Allen Date: Thu, 18 Jul 2024 13:31:18 -0400 Subject: [PATCH 2/2] Added uuid to discovery --- nrf-softdevice/src/ble/gatt_client.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nrf-softdevice/src/ble/gatt_client.rs b/nrf-softdevice/src/ble/gatt_client.rs index 5be6a0f..275bb8b 100644 --- a/nrf-softdevice/src/ble/gatt_client.rs +++ b/nrf-softdevice/src/ble/gatt_client.rs @@ -58,7 +58,7 @@ pub trait Client { fn uuid(&self) -> Uuid; /// Create a new instance in a "not-yet-discovered" state. - fn new_undiscovered(conn: Connection) -> Self; + fn new_undiscovered(uuid: Uuid, conn: Connection) -> Self; /// Called by [`discover`] for every discovered characteristic. Implementations must /// check if they're interested in the UUID of the characteristic, and save their @@ -275,10 +275,10 @@ async fn discover_inner( /// Discover a service in the peer's GATT server and construct a Client instance /// to use it. -pub async fn discover(conn: &Connection) -> Result { +pub async fn discover(uuid: &Uuid, conn: &Connection) -> Result { // TODO handle drop. Probably doable gracefully (no DropBomb) - let mut client = T::new_undiscovered(conn.clone()); + let mut client = T::new_undiscovered(uuid.clone(), conn.clone()); let svc = match discover_service(conn, client.uuid()).await { Err(DiscoverError::Gatt(GattError::ATTERR_ATTRIBUTE_NOT_FOUND)) => Err(DiscoverError::ServiceNotFound),