Skip to content

Commit

Permalink
Merge pull request #16 from quentinlampin/bugfix-CoAP-option-value
Browse files Browse the repository at this point in the history
[Bugfix] CoAP zero-length option value
  • Loading branch information
quentinlampin authored Aug 23, 2023
2 parents 63c574b + 628302c commit 3fdbff4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion microschc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.15.1'
__version__ = '0.15.2'
5 changes: 3 additions & 2 deletions microschc/parser/protocol/coap.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ def _parse_options(buffer: Buffer) -> Tuple[List[FieldDescriptor], int]:
option_offset += 16

option_value_length = (option_length_int + option_length_extended_int) * 8
option_value: Buffer = option_bytes[option_offset: option_offset+option_value_length]
fields.append(FieldDescriptor(id=CoAPFields.OPTION_VALUE, position=option_index, value=option_value))
if option_value_length > 0:
option_value: Buffer = option_bytes[option_offset: option_offset+option_value_length]
fields.append(FieldDescriptor(id=CoAPFields.OPTION_VALUE, position=option_index, value=option_value))

option_offset += option_value_length
cursor += option_offset
Expand Down
2 changes: 1 addition & 1 deletion tests/test_microschc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_version():
assert __version__ == '0.15.1'
assert __version__ == '0.15.2'

0 comments on commit 3fdbff4

Please sign in to comment.