Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed uuid to method #266

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions nrf-softdevice/src/ble/gatt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ 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;
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
Expand Down Expand Up @@ -275,16 +275,16 @@ async fn discover_inner<T: Client>(

/// Discover a service in the peer's GATT server and construct a Client instance
/// to use it.
pub async fn discover<T: Client>(conn: &Connection) -> Result<T, DiscoverError> {
pub async fn discover<T: Client>(uuid: &Uuid, conn: &Connection) -> Result<T, DiscoverError> {
// TODO handle drop. Probably doable gracefully (no DropBomb)

let svc = match discover_service(conn, T::uuid()).await {
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),
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;

Expand Down
Loading