Skip to content

Commit db9c92f

Browse files
morgendagenwiba-nordic
authored andcommitted
zigbee: fix error when using VERSION file in Zigbee project
Allow tweaks in APPLICATION_VERSION_STRING, e.g. 1.0.0+3. Signed-off-by: Peder Toftegaard Olsen <[email protected]> Co-authored-by: Wille Backman <[email protected]> (cherry picked from commit faf7537)
1 parent 2e4733d commit db9c92f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Thread
285285
Zigbee
286286
------
287287

288-
|no_changes_yet_note|
288+
* Fixed the :file:`zb_add_ota_header.py` script not being able to handle an ``APPLICATION_VERSION_STRING`` which includes a tweak, such as ``1.0.0+3``.
289289

290290
Wi-Fi
291291
-----

scripts/bootloader/zb_add_ota_header.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import argparse
88
import os
9+
import re
910
import struct
1011

1112
OTA_HEADER_FILE_ID = 0x0BEEF11E
@@ -140,11 +141,11 @@ def __add_optional_fields(self, fields_length, field_control_bit_mask, fields_fo
140141

141142
def convert_version_string_to_int(s):
142143
"""Convert from semver string "1.2.3", to integer 1020003"""
143-
numbers = s.split('.')
144-
if len(numbers) != 3:
145-
raise ValueError('application-version-string parameter must be on the format x.y.z')
144+
match = re.match(r'^([0-9]+)\.([0-9]+)\.([0-9])(?:\+[0-9]+)?$', s)
145+
if match is None:
146+
raise ValueError('application-version-string parameter must be on the format x.y.z or x.y.z+t')
146147
js = [0x100*0x10000, 0x10000, 1]
147-
return sum([js[i] * int(numbers[i]) for i in range(3)])
148+
return sum([js[i] * int(match.group(i+1)) for i in range(3)])
148149

149150
def hex2int(x):
150151
"""Convert hex to int."""

0 commit comments

Comments
 (0)