bluez_peripheral.agent module¶
- class bluez_peripheral.agent.AgentCapability(value)[source]¶
Bases:
EnumThe IO Capabilities of the local device supported by the agent. See Tables 5.5 and 5.7 of the Bluetooth Core Spec Part C.
- DISPLAY_ONLY = 1¶
Device has no input but a 6 digit pairing code can be displayed.
- DISPLAY_YES_NO = 2¶
Device can display a 6 digit pairing code and record the response to a yes/ no prompt.
- KEYBOARD_DISPLAY = 0¶
Any pairing method can be used.
- KEYBOARD_ONLY = 3¶
Device has no output but can be used to input a pairing code.
- NO_INPUT_NO_OUTPUT = 4¶
Device has no input/ output capabilities and therefore cannot support MITM protection.
- class bluez_peripheral.agent.BaseAgent(capability)[source]¶
Bases:
BaseServiceInterfaceThe abstract base agent for all bluez agents. Subclass this if one of the existing agents does not meet your requirements. Alternatively bluez supports several built in agents which can be selected using the bluetoothctl cli. Represents an org.bluez.Agent1 instance.
- Parameters:
capability (AgentCapability) – The IO capabilities of the agent.
- async register(bus, *, path=None, default=True)[source]¶
Expose this agent on the specified message bus and register it with the bluez agent manager.
- Parameters:
bus (MessageBus) – The message bus to expose the agent using.
default (bool) – Whether or not the agent should be registered as default. Non-default agents will not be called to respond to incoming pairing requests. The invoking process requires superuser if this is true.
path (str | None) – The path to expose this message bus on.
- Return type:
None
- class bluez_peripheral.agent.NoIoAgent[source]¶
Bases:
BaseAgentAn agent with no input or output capabilities. All incoming pairing requests from all devices will be accepted unconditionally.
- class bluez_peripheral.agent.TestAgent(capability)[source]¶
Bases:
BaseAgentA testing agent that invokes the debugger whenever a method is called. Use this for debugging only.
- Parameters:
capability (AgentCapability) – The IO capability of the agent.
- class bluez_peripheral.agent.YesNoAgent(request_confirmation, cancel)[source]¶
Bases:
BaseAgentAn agent that uses a callback to display a yes/ no prompt in response to an incoming pairing request.
- Parameters:
request_confirmation (Callable[[int], Awaitable[bool]]) – The callback called when a pairing request is received. This should return true if the user indicates that the supplied passcode is correct or false otherwise.
cancel (Callable[[], None]) – The callback called when a pairing request is canceled remotely.