Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Update Thread DFU logging (#112)
Browse files Browse the repository at this point in the history
* Improve Thread DFU logging

* Add progress bar to Thread multicast DFU operation
  • Loading branch information
rlubos authored and IvanSanchez committed Dec 4, 2017
1 parent b878829 commit 1f3c574
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
12 changes: 7 additions & 5 deletions nordicsemi/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ def int_as_text_to_int(value):
raise NordicSemiException('%s is not a valid integer' % value)

def pause():
try:
raw_input()
except (KeyboardInterrupt, EOFError):
pass
while True:
try:
raw_input()
except (KeyboardInterrupt, EOFError):
break

class BasedIntOrNoneParamType(click.ParamType):
name = 'Integer'
Expand Down Expand Up @@ -944,9 +945,10 @@ def thread(package, port, address, server_port, panid, channel, jlink_snr, flash

transport.open()
# Delay DFU trigger until NCP promotes to a router (6 seconds by default)
click.echo("Waiting for NCP to promote to a router...")
time.sleep(6.0)
dfu.trigger(address, 3)
click.echo("Press <ENTER> to terminate")
click.echo("Thread DFU server is running... Press <Ctrl + C> to stop.")
pause()
click.echo("Terminating")

Expand Down
13 changes: 12 additions & 1 deletion nordicsemi/thread/dfu_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ def _handle_image_request(self, request):

total_block_count = _block_count(len(self.image_resource.data), block_szx)


self._update_progress_bar(request.remote.addr,
self.clients[request.remote],
block_num,
Expand Down Expand Up @@ -262,13 +261,23 @@ def _upload(self, remote, bitmap):

logger.debug("Uploading resource {} block {} to {}".format(resource.path, num, remote.addr))

total_block_count = _block_count(len(resource.data), ThreadDfuServer.BLOCK_SZX)

self._update_progress_bar(remote.addr,
self.clients[remote],
num,
total_block_count)

self._send_block(remote,
resource.path,
num,
more,
ThreadDfuServer.BLOCK_SZX,
payload)

if (self.clients[remote].last_block is None) or (self.clients[remote].last_block < num):
self.clients[remote].last_block = num

self.bmp_received_event.clear()
if len(bitmap):
if (num % ThreadDfuServer.SPBLK_SIZE == 0) or (((num + 1) % ThreadDfuServer.SPBLK_SIZE) == 0):
Expand Down Expand Up @@ -354,6 +363,8 @@ def _multicast_upload(self, remote, num_of_requests):
self.missing_blocks.extend(_make_bitmap(self.init_resource))
self.missing_blocks.extend(_make_bitmap(self.image_resource))

self.clients[remote] = ThreadDfuClient()

self._send_trigger(remote, num_of_requests)
self.trig_done_event.wait()

Expand Down
1 change: 1 addition & 0 deletions nordicsemi/thread/tncp.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def add_ip_address(self, ipaddr):
logger.debug("Added")

def print_addresses(self):
logger.info("NCP Thread IPv6 addresses:")
for addr in self._wpan.get_ipaddrs():
logger.info(unicode(addr))

Expand Down

0 comments on commit 1f3c574

Please sign in to comment.