Exemplo n.º 1
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit ')
    parser.add_argument('-f',
                        action='store',
                        required=True,
                        dest='file',
                        help='HomeKit pairing data file')
    parser.add_argument('-a',
                        action='store',
                        required=True,
                        dest='alias',
                        help='alias for the pairing')
    parser.add_argument('-c',
                        action='store',
                        required=True,
                        dest='connection',
                        choices=['BLE', 'IP'],
                        help='connection type for the pairing')
    parser.add_argument('-k',
                        action='store',
                        required=True,
                        dest='key',
                        help='long term public key for the pairing')
    parser.add_argument('-i',
                        action='store',
                        required=True,
                        dest='id',
                        help='accessory ID for the pairing')
    parser.add_argument('-m',
                        action='store',
                        required=False,
                        dest='mac',
                        help='accessory MAC for the pairing')
    add_log_arguments(parser)
    return parser.parse_args()
Exemplo n.º 2
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit remove pairing app')
    parser.add_argument('-f',
                        action='store',
                        required=True,
                        dest='file',
                        help='File with the pairing data')
    parser.add_argument('-a',
                        action='store',
                        required=True,
                        dest='alias',
                        help='alias for the accessory')
    parser.add_argument('-i',
                        action='store',
                        required=False,
                        dest='pairingId',
                        help='the pairing that should be removed')
    parser.add_argument(
        '--adapter',
        action='store',
        dest='adapter',
        default='hci0',
        help='the bluetooth adapter to be used (defaults to hci0)')
    add_log_arguments(parser)
    return parser.parse_args()
Exemplo n.º 3
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit debug proxy')
    parser.add_argument(
        '-c',
        '--client-data',
        action='store',
        required=True,
        dest='client_data',
        default='./client.json',
        help='JSON file with the pairing data for the accessory')
    parser.add_argument('-a',
                        '--alias',
                        action='store',
                        required=True,
                        dest='alias',
                        help='alias for the pairing')
    parser.add_argument(
        '-s',
        '--server-data',
        action='store',
        required=True,
        dest='server_data',
        default='./server.json',
        help='JSON file with the accessory data to the controller')
    parser.add_argument(
        '-C',
        '--code',
        action='store',
        required=False,
        dest='code',
        help='Reference to a python module with filter functions')
    add_log_arguments(parser, 'INFO')
    return parser.parse_args()
Exemplo n.º 4
0
def setup_args_parser():
    parser = argparse.ArgumentParser(
        description='HomeKit BLE discover app - '
        'list all HomeKit Bluetooth LE devices in range')
    parser.add_argument('-t',
                        action='store',
                        required=False,
                        dest='timeout',
                        type=int,
                        default=10,
                        help='Number of seconds to wait (defaults to 10)')
    parser.add_argument(
        '--adapter',
        action='store',
        dest='adapter',
        default='hci0',
        help='the bluetooth adapter to be used (defaults to hci0)')
    parser.add_argument(
        '-u',
        action='store_true',
        required=False,
        dest='unpaired_only',
        help=
        'If activated, this option will show only unpaired HomeKit BLE Devices'
    )
    add_log_arguments(parser)
    return parser.parse_args()
Exemplo n.º 5
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit IP discover app -'
                                                 ' list all HomeKit devices on the same IP network')
    parser.add_argument('-t', action='store', required=False, dest='timeout', type=int, default=10,
                        help='Number of seconds to wait')
    add_log_arguments(parser)
    return parser.parse_args()
Exemplo n.º 6
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit identify app - performs identify on given HomeKit device')

    parser.add_argument('--adapter', action='store', dest='adapter', default='hci0',
                        help='the bluetooth adapter to be used (defaults to hci0)')

    group = parser.add_argument_group('Identify unpaired IP', 'use this option to identify an UNPAIRED IP accessory.')
    group.add_argument('-d', action='store', dest='device', help='accessory pairing id')

    group = parser.add_argument_group('Identify unpaired BLE', 'use this option to identify an UNPAIRED BLE accessory.')
    group.add_argument('-m', action='store', dest='mac', help='accessory mac address')

    group = parser.add_argument_group('Identify paired', 'use this option to identify an PAIRED accessory.')
    group.add_argument('-f', action='store', dest='file', help='File with the pairing data')
    group.add_argument('-a', action='store', dest='alias', help='alias for the pairing')
    add_log_arguments(parser)

    parsed_args = parser.parse_args()

    if parsed_args.device and parsed_args.mac is None and parsed_args.file is None and parsed_args.alias is None:
        # unpaired IP
        return parsed_args
    if parsed_args.mac and parsed_args.device is None and parsed_args.file is None and parsed_args.alias is None:
        # unpaired BLE
        return parsed_args
    elif parsed_args.device is None and parsed_args.mac is None and parsed_args.file and parsed_args.alias:
        # paired
        return parsed_args
    else:
        parser.print_help()
        sys.exit(-1)
Exemplo n.º 7
0
def setup_args_parser():
    parser = argparse.ArgumentParser(
        description=
        'HomeKit get_characteristic - retrieve values of characteristics '
        'and other information from paired HomeKit accessories.')
    parser.add_argument('-f',
                        action='store',
                        required=True,
                        dest='file',
                        help='File with the pairing data')
    parser.add_argument('-a',
                        action='store',
                        required=True,
                        dest='alias',
                        help='alias for the pairing')
    parser.add_argument(
        '-c',
        action='append',
        required=True,
        dest='characteristics',
        help=
        'Read characteristics, multiple characteristics can be given by repeating the option'
    )
    parser.add_argument(
        '-m',
        action='store_true',
        required=False,
        dest='meta',
        help='read out the meta data for the characteristics as well')
    parser.add_argument(
        '-p',
        action='store_true',
        required=False,
        dest='perms',
        help='read out the permissions for the characteristics as well')
    parser.add_argument(
        '-t',
        action='store_true',
        required=False,
        dest='type',
        help='read out the types for the characteristics as well')
    parser.add_argument(
        '-e',
        action='store_true',
        required=False,
        dest='events',
        help='read out the events for the characteristics as well')
    parser.add_argument(
        '--adapter',
        action='store',
        dest='adapter',
        default='hci0',
        help='the bluetooth adapter to be used (defaults to hci0)')
    add_log_arguments(parser)
    return parser.parse_args()
Exemplo n.º 8
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit BLE pairing app')
    parser.add_argument('-m', action='store', required=True, dest='mac',
                        help='HomeKit Device MAC (use discover to get it)')
    parser.add_argument('-p', action='store', required=False, dest='pin', help='HomeKit configuration code')
    parser.add_argument('-f', action='store', required=True, dest='file', help='HomeKit pairing data file')
    parser.add_argument('-a', action='store', required=True, dest='alias', help='alias for the pairing')
    parser.add_argument('--adapter', action='store', dest='adapter', default='hci0',
                        help='the bluetooth adapter to be used (defaults to hci0)')
    add_log_arguments(parser)
    return parser.parse_args()
Exemplo n.º 9
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit get accessories app')
    parser.add_argument('-f', action='store', required=True, dest='file', help='File with the pairing data')
    parser.add_argument('-a', action='store', required=True, dest='alias', help='alias for the pairing')
    parser.add_argument('-o', action='store', dest='output', default='compact', choices=['json', 'compact'],
                        help='Specify output format')
    parser.add_argument('--adapter', action='store', dest='adapter', default='hci0',
                        help='the bluetooth adapter to be used (defaults to hci0)')
    parser.add_argument('-d', action='store_true', required=False, dest='decode',
                        help='If set, try to find a decoder for each characteristic and show the decoded value')
    add_log_arguments(parser)
    return parser.parse_args()
def setup_args_parser():
    parser = argparse.ArgumentParser(
        description='HomeKit generate pairing data app')
    parser.add_argument('-f',
                        action='store',
                        required=True,
                        dest='file',
                        help='HomeKit pairing data file')
    parser.add_argument('-a',
                        action='store',
                        required=True,
                        dest='alias',
                        help='alias for the pairing')
    add_log_arguments(parser)
    return parser.parse_args()
Exemplo n.º 11
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit put_characteristic app - change values of characteristics '
                                                 'on paired HomeKit accessories.')
    parser.add_argument('-f', action='store', required=True, dest='file', help='File with the pairing data')
    parser.add_argument('-a', action='store', required=True, dest='alias', help='alias for the pairing')
    parser.add_argument('-c', action='append', required=False, dest='characteristics', nargs=2,
                        help='Use `aid.iid value` to change the value. Repeat to change multiple characteristics. '
                             'If the value starts with `@` it is interpreted as a file')
    parser.add_argument('--adapter', action='store', dest='adapter', default='hci0',
                        help='the bluetooth adapter to be used (defaults to hci0)')
    add_log_arguments(parser)

    args = parser.parse_args()
    if 'characteristics' not in args or not args.characteristics:
        parser.print_help()
        sys.exit(-1)
    return args
Exemplo n.º 12
0
def setup_args_parser():
    parser = argparse.ArgumentParser(
        description=
        'HomeKit get_events app - listens to events from accessories')
    parser.add_argument('-f',
                        action='store',
                        required=True,
                        dest='file',
                        help='File with the pairing data')
    parser.add_argument('-a',
                        action='store',
                        required=True,
                        dest='alias',
                        help='alias for the pairing')
    parser.add_argument(
        '-c',
        action='append',
        required=True,
        dest='characteristics',
        help=
        'Use aid.iid value to change the value. Repeat to change multiple characteristics.'
    )
    parser.add_argument('-e',
                        action='store',
                        required=False,
                        dest='eventCount',
                        help='max number of events before end',
                        default=-1,
                        type=int)
    parser.add_argument('-s',
                        action='store',
                        required=False,
                        dest='secondsCount',
                        default=-1,
                        type=int,
                        help='max number of seconds before end')
    parser.add_argument(
        '--adapter',
        action='store',
        dest='adapter',
        default='hci0',
        help='the bluetooth adapter to be used (defaults to hci0)')
    add_log_arguments(parser)
    return parser.parse_args()
Exemplo n.º 13
0
def setup_args_parser():
    """
    Setup the parser for the CLI parameters and perform the parsing.

    :return: an instance of argparse.Namespace containing the parsed parameters
    """
    parser = argparse.ArgumentParser(description='HomeKit generate pairing data app')
    parser.add_argument('-f', action='store', required=True, dest='file', help='HomeKit pairing data file')
    parser.add_argument('-a', action='store', required=True, dest='alias', help='alias for the pairing')
    parser.add_argument('-i', action='store', required=True, dest='pairing_id',
                        help='the device identification of the other controller')
    parser.add_argument('-k', action='store', required=True, dest='key',
                        help='the public key of the other controller')
    parser.add_argument('-p', action='store', required=True, dest='permission', choices=['User', 'Admin'],
                        help='the privilege of the other controller')
    parser.add_argument('--adapter', action='store', dest='adapter', default='hci0',
                        help='the bluetooth adapter to be used (defaults to hci0)')
    add_log_arguments(parser)
    return parser.parse_args()
Exemplo n.º 14
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit list pairings app')
    parser.add_argument('-f',
                        action='store',
                        required=True,
                        dest='file',
                        help='File with the pairing data')
    parser.add_argument('-a',
                        action='store',
                        required=True,
                        dest='alias',
                        help='alias for the pairing')
    parser.add_argument(
        '--adapter',
        action='store',
        dest='adapter',
        default='hci0',
        help='the bluetooth adapter to be used (defaults to hci0)')
    add_log_arguments(parser)
    return parser.parse_args()
Exemplo n.º 15
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit debug mitm')
    parser.add_argument('-c',
                        '--client-data',
                        action='store',
                        required=True,
                        dest='client_data',
                        default='./client.json')
    parser.add_argument('-a',
                        '--alias',
                        action='store',
                        required=True,
                        dest='alias',
                        help='alias for the pairing')
    parser.add_argument('-s',
                        '--server-data',
                        action='store',
                        required=True,
                        dest='server_data',
                        default='./server.json')
    add_log_arguments(parser, 'INFO')
    return parser.parse_args()
Exemplo n.º 16
0
def setup_args_parser():
    parser = argparse.ArgumentParser(description='HomeKit IP pairing app')
    parser.add_argument('-d',
                        action='store',
                        required=True,
                        dest='device',
                        help='HomeKit Device ID (use discover to get it)')
    parser.add_argument('-p',
                        action='store',
                        required=False,
                        dest='pin',
                        help='HomeKit configuration code')
    parser.add_argument('-f',
                        action='store',
                        required=True,
                        dest='file',
                        help='HomeKit pairing data file')
    parser.add_argument('-a',
                        action='store',
                        required=True,
                        dest='alias',
                        help='alias for the pairing')
    add_log_arguments(parser)
    return parser.parse_args()