def METHOD_NAME(infile, opcodes, convert_to_camel_case):
    commands = []
    with open (infile, 'rt') as fin:
        params = []
        for line in fin:
            parts = re.match('.*@param\s*(\w*)\s*', line)
            if parts and len(parts.groups()) == 1:
                param = parts.groups()[0]
                if convert_to_camel_case:
                    param = camel_case_var(param)
                else:
                    param = param.lower()
                params.append(param)
                continue
            declaration = re.match('const\s+hci_cmd_t\s+(\w+)[\s=]+', line)
            if declaration:
                command_name = declaration.groups()[0]
                # drop _cmd suffix for daemon commands
                if command_name.endswith('_cmd'):
                    command_name = command_name[:-len('_cmd')]
                if convert_to_camel_case:
                    command_name = camel_case(command_name)
                else:
                    command_name = command_name.lower()
                continue
            # HCI_OPCODE or DAEMON_OPCODE definition
            definition = re.match('\s*(HCI_OPCODE_\w+|DAEMON_OPCODE_\w+)\s*,\s\\"(\w*)\\".*', line)
            if definition:
                (opcode, format) = definition.groups()
                if len(params) != len(format):
                    params = []
                    arg_counter = 1
                    for f in format:
                        arg_name = 'arg%u' % arg_counter
                        params.append(arg_name)
                        arg_counter += 1
                (ogf, ocf) = opcodes[opcode]
                commands.append((command_name, ogf, ocf, format, params))
                params = []
                continue
    return commands