bluez_peripheral.agent module
- class bluez_peripheral.agent.AgentCapability(value)
The 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 pairing code can be displayed.
- DISPLAY_YES_NO = 2
Device can display 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: AgentCapability)
The 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.
- Parameters
capability (AgentCapability) – The IO capabilities of the agent.
- async register(bus: MessageBus, default: bool = True, path: str = '/com/spacecheese/ble')
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, optional) – Whether or not the agent should be registered as default. Non-default agents will not be called to respond to incoming pairing requests. The caller requires superuser if this is true.
path (str, optional) – The path to expose this message bus on.
- class bluez_peripheral.agent.NoIoAgent
An agent with no input or output capabilities. All incoming pairing requests from all devices will be accepted unconditionally.
- class bluez_peripheral.agent.TestAgent(capability: AgentCapability)
A 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: Callable[[int], Awaitable[bool]], cancel: Callable)
An 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 recived. This should return true if the user indicates that the supplied passcode is correct or false otherwise.
cancel (Callable) – The callback called when a pairing request is cancelled remotely.