forked from mirror/joycontrol
Make device pairable before trying to pair to switch
This commit is contained in:
@@ -47,6 +47,13 @@ class HidDevice:
|
||||
"""
|
||||
self.properties.Set(self.adapter.dbus_interface, 'Discoverable', boolean)
|
||||
|
||||
def pairable(self, boolean=True):
|
||||
"""
|
||||
Make adapter pairable
|
||||
"""
|
||||
self.properties.Set(self.adapter.dbus_interface, 'Pairable', boolean)
|
||||
|
||||
|
||||
async def set_class(self, cls='0x002508'):
|
||||
"""
|
||||
Sets Bluetooth device class. Requires hciconfig system command.
|
||||
|
||||
@@ -75,6 +75,7 @@ async def create_hid_server(protocol_factory, ctl_psm=17, itr_psm=19, device_id=
|
||||
itr_sock.listen(1)
|
||||
|
||||
hid.powered(True)
|
||||
hid.pairable(True)
|
||||
# setting bluetooth adapter name and class to the device we wish to emulate
|
||||
await hid.set_name(protocol.controller.device_name())
|
||||
await hid.set_class()
|
||||
@@ -100,6 +101,7 @@ async def create_hid_server(protocol_factory, ctl_psm=17, itr_psm=19, device_id=
|
||||
|
||||
# stop advertising
|
||||
hid.discoverable(False)
|
||||
hid.pairable(False)
|
||||
|
||||
else:
|
||||
# Reconnection to reconnect_bt_addr
|
||||
|
||||
Reference in New Issue
Block a user