"""Prints a formatted message from a Switch :param data: The bytes from the Switch message :type data: bytes """ print(format_message(data, 10, "Switch")) if __name__ == "__main__": switch_address = "7C:BB:8A:D9:91:5A" port_ctrl = 17 port_itr = 19 toggle_clean_bluez(True) bt = BlueZ(adapter_path="/org/bluez/hci0") controller = Controller(bt, PRO_CONTROLLER) # Switch sockets switch_itr = socket.socket(family=socket.AF_BLUETOOTH, type=socket.SOCK_SEQPACKET, proto=socket.BTPROTO_L2CAP) switch_ctrl = socket.socket(family=socket.AF_BLUETOOTH, type=socket.SOCK_SEQPACKET, proto=socket.BTPROTO_L2CAP) try: bt.set_alias("Pro Controller") bt.set_discoverable(True)
""" A quick script to test aspects of the BlueZ API. """ import dbus from nxbt import BlueZ, find_objects, SERVICE_NAME, ADAPTER_INTERFACE bus = dbus.SystemBus() adapters = find_objects(bus, SERVICE_NAME, ADAPTER_INTERFACE) print(adapters) bt = BlueZ(device_id=adapters[0].split("/")[-1]) # jc_MAC = "XX:XX:XX:XX:XX:XX" # res = bt.discover_devices(alias="Joy-Con (L)", timeout=10) # for key in res.keys(): # print(res[key]["Alias"], res[key]["Address"]) # print(bt.find_device_by_address(jc_MAC)) # devices = bt.discover_devices(alias="Joy-Con (L)") # print(devices.keys()) print("Address", bt.address) print("Name", bt.name) print("Alias", bt.alias) print("Pairable", bt.pairable) print("") print("Pairable Timeout", bt.pairable_timeout) bt.set_pairable_timeout(10) print("Pairable Timeout", bt.pairable_timeout)
jc_MAC = "98:B6:E9:B0:05:E7" # Specify the type of controller here controller_type = PRO_CONTROLLER if controller_type == JOYCON_L: REPLY = JCL_REPLY02 elif controller_type == JOYCON_R: REPLY = JCR_REPLY02 else: REPLY = PRO_REPLY02 port_ctrl = 17 port_itr = 19 message_buffer = [] toggle_input_plugin(False) bt = BlueZ(adapter_path="/org/bluez/hci0") controller = Controller(bt, controller_type) # Joy-Con Sockets jc_ctrl = socket.socket(family=socket.AF_BLUETOOTH, type=socket.SOCK_SEQPACKET, proto=socket.BTPROTO_L2CAP) jc_itr = socket.socket(family=socket.AF_BLUETOOTH, type=socket.SOCK_SEQPACKET, proto=socket.BTPROTO_L2CAP) # Switch sockets switch_itr = socket.socket(family=socket.AF_BLUETOOTH, type=socket.SOCK_SEQPACKET, proto=socket.BTPROTO_L2CAP)
parser = argparse.ArgumentParser(description='Proxy Joycon (R) traffic except NFC communication') parser.add_argument('--mac', required=True) parser.add_argument('--nfc-data') args = parser.parse_args() nfc_data = None if args.nfc_data is not None: with open(args.nfc_data, 'rb') as datafile: nfc_data = datafile.read() port_ctrl = 17 port_itr = 19 message_buffer = [] toggle_input_plugin(False) bt = BlueZ(adapter_path="/org/bluez/hci0") controller = Controller(bt, JOYCON_R) # Joy-Con Sockets jc_ctrl = socket.socket(family=socket.AF_BLUETOOTH, type=socket.SOCK_SEQPACKET, proto=socket.BTPROTO_L2CAP) jc_itr = socket.socket(family=socket.AF_BLUETOOTH, type=socket.SOCK_SEQPACKET, proto=socket.BTPROTO_L2CAP) # Switch sockets switch_itr = socket.socket(family=socket.AF_BLUETOOTH, type=socket.SOCK_SEQPACKET, proto=socket.BTPROTO_L2CAP)