Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c8f4484 authored by John Lai's avatar John Lai Committed by Automerger Merge Worker
Browse files

Merge "Floss: Add GATT client command to read charateristic by uuid" am: 0f0a23a7

parents cd303577 0f0a23a7
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -189,6 +189,9 @@ fn build_commands() -> HashMap<String, CommandOption> {
                    "gatt write-characteristic <address> <handle> <NoRsp|Write|Prepare> <value>",
                ),
                String::from("gatt read-characteristic <address> <handle>"),
                String::from(
                    "gatt read-characteristic-by-uuid <address> <uuid> <start_handle> <end_handle>",
                ),
                String::from("gatt register-notification <address> <handle> <enable|disable>"),
                String::from("gatt register-server"),
            ],
@@ -1066,6 +1069,33 @@ impl CommandHandler {
                    .unwrap()
                    .read_characteristic(client_id, addr, handle, auth_req);
            }
            "read-characteristic-by-uuid" => {
                let addr = String::from(get_arg(args, 1)?);
                let uuid = String::from(get_arg(args, 2)?);
                let start_handle = String::from(get_arg(args, 3)?)
                    .parse::<i32>()
                    .or(Err("Failed to parse start handle"))?;
                let end_handle = String::from(get_arg(args, 4)?)
                    .parse::<i32>()
                    .or(Err("Failed to parse end handle"))?;

                let client_id = self
                    .lock_context()
                    .gatt_client_context
                    .client_id
                    .ok_or("GATT client is not yet registered.")?;

                let auth_req = self.lock_context().gatt_client_context.get_auth_req().into();

                self.lock_context().gatt_dbus.as_ref().unwrap().read_using_characteristic_uuid(
                    client_id,
                    addr,
                    uuid,
                    start_handle,
                    end_handle,
                    auth_req,
                );
            }
            "register-notification" => {
                let addr = String::from(get_arg(args, 1)?);
                let handle = String::from(get_arg(args, 2)?)