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