Exemplo n.º 1
0
async def do_set_password(**kwargs):
    password = kwargs.get("password")
    if password is None:
        raise ValueError("No password provided")

    async with bbl.BlueBerryClient(**kwargs) as bbc:
        await bbc.set_password(password)
Exemplo n.º 2
0
async def do_dfu(address, package, boot, **kwargs):
    # hack to include nordicsemi sources without modifications 
    this_dir = abspath(dirname(__file__))
    sys.path.insert(0, this_dir)

    from bblogger.dfu import device_firmware_upgrade, app_to_dfu_address, scan_dfu_devices

    if kwargs.get("scan"):
        scan_dfu_devices()
        return

    if address is None:
        raise ValueError("No address given")

    no_app = kwargs.get("no_app")
    if no_app:
        app_addr = None
        dfu_addr = address
    else:
        app_addr = address

        logger.info("Entering DFU from app ...")
        async with bbl.BlueBerryClient(address=app_addr, **kwargs) as bbc:
            d = await bbc.enter_dfu() 

        # must be after enter_dfu()
        dfu_addr = await app_to_dfu_address(app_addr)

    if boot is None and package is None:
        raise ValueError("No package given")

    if boot == "app":
        raise NotImplementedError("TODO boot app reset abort")

    if boot == "bl":
        return

    logger.debug("dfu_addr:{}, app_addr:{}".format(app_addr, dfu_addr))
    logger.info("DFU ...")
    await device_firmware_upgrade(dfu_addr=dfu_addr, package=package)
Exemplo n.º 3
0
async def do_fetch(**kwargs):
    async with bbl.BlueBerryClient(**kwargs) as bbc:
        await bbc.fetch(ofile=kwargs.get("outfile"), **kwargs)
Exemplo n.º 4
0
async def do_device_info(**kwargs):
    async with bbl.BlueBerryClient(**kwargs) as bbc:
        await bbc.device_info(**kwargs)
Exemplo n.º 5
0
async def do_config_write(**kwargs):
    async with bbl.BlueBerryClient(**kwargs) as bbc:
        await bbc.config_write(**kwargs)
Exemplo n.º 6
0
async def do_config_read(**kwargs):
    async with bbl.BlueBerryClient(**kwargs) as bbc:
        conf = await bbc.config_read(**kwargs)
Exemplo n.º 7
0
async def do_blink(**kwargs):
    n = kwargs.get("num", 0)
    async with bbl.BlueBerryClient(**kwargs) as bbc:
        await bbc.blink(n)