Skip to content

Commit 1f3c574

Browse files
rlubosIvanSanchez
authored andcommitted
Update Thread DFU logging (NordicSemiconductor#112)
* Improve Thread DFU logging * Add progress bar to Thread multicast DFU operation
1 parent b878829 commit 1f3c574

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

nordicsemi/__main__.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,11 @@ def int_as_text_to_int(value):
132132
raise NordicSemiException('%s is not a valid integer' % value)
133133

134134
def pause():
135-
try:
136-
raw_input()
137-
except (KeyboardInterrupt, EOFError):
138-
pass
135+
while True:
136+
try:
137+
raw_input()
138+
except (KeyboardInterrupt, EOFError):
139+
break
139140

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

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

nordicsemi/thread/dfu_server.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ def _handle_image_request(self, request):
190190

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

193-
194193
self._update_progress_bar(request.remote.addr,
195194
self.clients[request.remote],
196195
block_num,
@@ -262,13 +261,23 @@ def _upload(self, remote, bitmap):
262261

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

264+
total_block_count = _block_count(len(resource.data), ThreadDfuServer.BLOCK_SZX)
265+
266+
self._update_progress_bar(remote.addr,
267+
self.clients[remote],
268+
num,
269+
total_block_count)
270+
265271
self._send_block(remote,
266272
resource.path,
267273
num,
268274
more,
269275
ThreadDfuServer.BLOCK_SZX,
270276
payload)
271277

278+
if (self.clients[remote].last_block is None) or (self.clients[remote].last_block < num):
279+
self.clients[remote].last_block = num
280+
272281
self.bmp_received_event.clear()
273282
if len(bitmap):
274283
if (num % ThreadDfuServer.SPBLK_SIZE == 0) or (((num + 1) % ThreadDfuServer.SPBLK_SIZE) == 0):
@@ -354,6 +363,8 @@ def _multicast_upload(self, remote, num_of_requests):
354363
self.missing_blocks.extend(_make_bitmap(self.init_resource))
355364
self.missing_blocks.extend(_make_bitmap(self.image_resource))
356365

366+
self.clients[remote] = ThreadDfuClient()
367+
357368
self._send_trigger(remote, num_of_requests)
358369
self.trig_done_event.wait()
359370

nordicsemi/thread/tncp.py

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def add_ip_address(self, ipaddr):
170170
logger.debug("Added")
171171

172172
def print_addresses(self):
173+
logger.info("NCP Thread IPv6 addresses:")
173174
for addr in self._wpan.get_ipaddrs():
174175
logger.info(unicode(addr))
175176

0 commit comments

Comments
 (0)