Skip to content

Commit

Permalink
Add download firmware from repository
Browse files Browse the repository at this point in the history
  • Loading branch information
blavka committed Jun 22, 2022
1 parent cfb6a4d commit 9994686
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ chester = "hardwario.chester.cli:main"
python = ">=3.7, <4"
click = ">=8.1"
pynrfjprog = "=10.16.0"
hardwario-common = "^1.6.1"
hardwario-common = "^1.7.1"
docker = "^5.0.3"
pylink-square = "^0.12.0"
prompt-toolkit = "^3.0.28"
Expand Down
14 changes: 13 additions & 1 deletion src/hardwario/chester/cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ..console import Console
from ..utils import find_hex
from ..firmwareapi import FirmwareApi
from ..utils import find_hex, download_url


@click.group(name='app')
Expand All @@ -19,9 +20,20 @@ def cli(ctx, nrfjprog_log):
ctx.obj['prog'] = NRFJProg('app', log=nrfjprog_log)


def validate_hex_file(ctx, param, value):
# print('validate_hex_file', ctx.obj, param.name, value)
if len(value) == 32 and all(c in string.hexdigits for c in value):
return download_url(f'https://firmware.hardwario.com/chester/{value}/hex', filename=f'{value}.hex')

if os.path.exists(value):
return value

raise click.BadParameter(f'Path \'{value}\' does not exist.')


@cli.command('flash')
@click.option('--halt', is_flag=True, help='Halt program.')
@click.argument('hex_file', metavar='HEX_FILE', type=click.Path(exists=True), default=find_hex('.', no_exception=True))
@click.argument('hex_file', metavar='HEX_FILE_OR_ID', callback=validate_hex_file, default=find_hex('.', no_exception=True))
@click.pass_context
def command_flash(ctx, halt, hex_file):
'''Flash application firmware (preserves UICR area).'''
Expand Down

0 comments on commit 9994686

Please sign in to comment.