registerAgent method
Future<void>
registerAgent(
- BlueZAgent agent, {
- DBusObjectPath? path,
- dynamic capability = BlueZAgentCapability.keyboardDisplay,
Registers an agent handler.
A D-Bus object will be registered on path
, which the user must choose to not collide with any other path on the D-Bus client that was passed in the BlueZClient constructor.
Implementation
Future<void> registerAgent(BlueZAgent agent,
{DBusObjectPath? path,
var capability = BlueZAgentCapability.keyboardDisplay}) async {
if (_agent != null) {
throw 'Agent already registered';
}
var object = _objects[DBusObjectPath('/org/bluez')];
if (object == null) {
throw 'Missing /org/bluez object required for agent registration';
}
_agent = _BlueZAgentObject(
this, agent, path ?? DBusObjectPath('/org/bluez/Agent'));
await _bus.registerObject(_agent!);
var capabilityString = {
BlueZAgentCapability.displayOnly: 'DisplayOnly',
BlueZAgentCapability.displayYesNo: 'DisplayYesNo',
BlueZAgentCapability.keyboardOnly: 'KeyboardOnly',
BlueZAgentCapability.noInputNoOutput: 'NoInputNoOutput',
BlueZAgentCapability.keyboardDisplay: 'KeyboardDisplay',
}[capability] ??
'';
await object.callMethod('org.bluez.AgentManager1', 'RegisterAgent',
[_agent!.path, DBusString(capabilityString)],
replySignature: DBusSignature(''));
}