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

Support for adding desired capability when registering agent #13

Closed

Conversation

hvardhanx
Copy link

@hvardhanx hvardhanx commented Dec 7, 2021

This pull request adds support to specify desired capability when registering agent through session.register_agent(agent, "KeyboardOnly");

Similar to how it is done here: https://github.com/bluez/bluez/blob/3f03ea4aebcee5166cd057047b5eb511eda90f42/test/simple-agent#L161
manager.RegisterAgent(path, capability);

@surban
Copy link
Collaborator

surban commented Dec 16, 2021

The agent's capability is automatically determined depending on the provided agent methods.

bluer/bluer/src/agent.rs

Lines 258 to 272 in 6bf2b0c

pub(crate) fn capability(&self) -> &'static str {
let keyboard = self.request_passkey.is_some() || self.request_pin_code.is_some();
let display_only = self.display_passkey.is_some() || self.display_pin_code.is_some();
let yes_no = self.request_confirmation.is_some()
|| self.request_authorization.is_some()
|| self.authorize_service.is_some();
match (keyboard, display_only, yes_no) {
(true, false, false) => "KeyboardOnly",
(false, true, false) => "DisplayOnly",
(false, _, true) => "DisplayYesNo",
(true, true, _) | (true, _, true) => "KeyboardDisplay",
(false, false, false) => "NoInputNoOutput",
}
}

Could you explain why you would need to override it in another way?

@surban surban self-requested a review December 16, 2021 13:23
@surban surban self-assigned this Dec 16, 2021
@hvardhanx
Copy link
Author

I was overriding the agent's capability because I wanted to set a static pass code which i think only appears in KeyboardOnly or KeyboardDisplay capability.

@surban
Copy link
Collaborator

surban commented Dec 16, 2021

I still don't understand. If you want to set a static pass code you can specify an agent that provides the request_pin_code function. This will set the agent capabilities to KeyboardOnly and call your function to obtain the pass code.

If you override the agent capabilities to KeyboardOnly but do not specify a function handling the request, where is the pass code supposed to come from?

@hvardhanx
Copy link
Author

I still don't understand. If you want to set a static pass code you can specify an agent that provides the request_pin_code function. This will set the agent capabilities to KeyboardOnly and call your function to obtain the pass code.

If you override the agent capabilities to KeyboardOnly but do not specify a function handling the request, where is the pass code supposed to come from?

Ahh thanks! I didn't know this 😄

@hvardhanx hvardhanx closed this Dec 21, 2021
@hvardhanx hvardhanx deleted the add/register-agent-with-capability branch December 21, 2021 08:38
otaviojr added a commit to otaviojr/bluer that referenced this pull request May 10, 2023
# This is the 1st commit message:

BLE Passive Scanning

# This is the commit message #2:

monitor

# This is the commit message bluez#3:

monitor

# This is the commit message bluez#4:

monitor

# This is the commit message bluez#5:

monitor

# This is the commit message bluez#6:

monitor

# This is the commit message bluez#7:

monitor

# This is the commit message bluez#8:

monitor

# This is the commit message bluez#9:

monitor

# This is the commit message bluez#10:

monitor

# This is the commit message bluez#11:

monitor

# This is the commit message bluez#12:

monitor

# This is the commit message bluez#13:

monitor

# This is the commit message bluez#14:

monitor

# This is the commit message bluez#15:

monitor

# This is the commit message bluez#16:

monitor

# This is the commit message bluez#17:

monitor

# This is the commit message bluez#18:

monitor

# This is the commit message bluez#19:

monitor

# This is the commit message bluez#20:

monitor

# This is the commit message bluez#21:

monitor

# This is the commit message bluez#22:

monitor

# This is the commit message bluez#23:

monitor

# This is the commit message bluez#24:

monitor

# This is the commit message bluez#25:

monitor

# This is the commit message bluez#26:

monitor

# This is the commit message bluez#27:

monitor

# This is the commit message bluez#28:

monitor

# This is the commit message bluez#29:

monitor

# This is the commit message bluez#30:

monitor

# This is the commit message bluez#31:

monitor

# This is the commit message bluez#32:

monitor

# This is the commit message bluez#33:

monitor

# This is the commit message bluez#34:

monitor

# This is the commit message bluez#35:

monitor

# This is the commit message bluez#36:

monitor

# This is the commit message bluez#37:

monitor

# This is the commit message bluez#38:

monitor

# This is the commit message bluez#39:

monitor

# This is the commit message bluez#40:

monitor

# This is the commit message bluez#41:

monitor

# This is the commit message bluez#42:

monitor

# This is the commit message bluez#43:

monitor

# This is the commit message bluez#44:

monitor

# This is the commit message bluez#45:

monitor

# This is the commit message bluez#46:

monitor

# This is the commit message bluez#47:

monitor

# This is the commit message bluez#48:

monitor

# This is the commit message bluez#49:

monitor

# This is the commit message bluez#50:

monitor

# This is the commit message bluez#51:

monitor

# This is the commit message bluez#52:

monitor

# This is the commit message bluez#53:

monitor

# This is the commit message bluez#54:

monitor

# This is the commit message bluez#55:

monitor

# This is the commit message bluez#56:

monitor

# This is the commit message bluez#57:

monitor

# This is the commit message bluez#58:

monitor

# This is the commit message bluez#59:

monitor

# This is the commit message bluez#60:

monitor

# This is the commit message bluez#61:

monitor

# This is the commit message bluez#62:

monitor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants