示例#1
0
    def perform_dfu_fwreboot(self, update_animation):
        fwreboot(self.dev, self.pid)
        self.dev.close()

        WAIT_TIME_MAX = 60
        CHECK_PERIOD = 0.5
        start_time = time.time()

        # Wait until device turns off
        while self.dev is not None:
            self.dev.close()
            self.dev = open_device(self.type)
            time.sleep(CHECK_PERIOD)

        while self.dev is None:
            update_animation()
            self.dev = open_device(self.type)
            if time.time() - start_time > WAIT_TIME_MAX:
                break
            time.sleep(CHECK_PERIOD)

        if self.dev is not None:
            print('DFU completed')
        else:
            print('Cannot connect to device after reboot')
        return self.dev is not None
示例#2
0
def configurator():
    logging.basicConfig(level=logging.ERROR)
    logging.info('Configuration channel for nRF52 Desktop')

    args = parse_arguments()

    dev = open_device(args.device_type)
    if not dev:
        return

    configurator.ALLOWED_COMMANDS[args.command](dev, args)
示例#3
0
def configurator():
    logging.basicConfig(level=logging.ERROR)
    logging.info('Configuration channel for nRF52 Desktop')

    args = parse_arguments()

    dev = open_device(args.device_type)
    if not dev:
        return

    if args.command == 'dfu':
        perform_dfu(dev, args)
    elif args.command == 'fwinfo':
        perform_fwinfo(dev, args)
    elif args.command == 'fwreboot':
        perform_fwreboot(dev, args)
    elif args.command == 'config':
        perform_config(dev, args)
示例#4
0
 def perform_fwreboot(self):
     fwreboot(self.dev, self.pid)
     self.dev.close()
     time.sleep(FWREBOOT_TIME)
     self.dev = open_device(self.device)
示例#5
0
 def __init__(self, device_type):
     self.type = device_type
     self.pid = get_device_pid(device_type)
     self.dev = open_device(device_type)