Skip to content

Commit

Permalink
fix status_list map encoding in CWT examples
Browse files Browse the repository at this point in the history
  • Loading branch information
c2bo committed Sep 12, 2024
1 parent e432edd commit ffce058
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def statusListEncoding1Bit():

def statusListEncoding1BitCBOR():
status_list = exampleStatusList1Bit()
encoded = status_list.encodeAsCBOR()
encoded = status_list.encodeAsCBORRaw()
hex_encoded = encoded.hex()
text = "byte_array = [{}, {}] \nencoded:\n{}".format(
hex(status_list.list[0]), hex(status_list.list[1]), util.printText(hex_encoded)
Expand All @@ -85,7 +85,7 @@ def statusListEncoding2Bit():

def statusListEncoding2BitCBOR():
status_list = exampleStatusList2Bit()
encoded = status_list.encodeAsCBOR()
encoded = status_list.encodeAsCBORRaw()
hex_encoded = encoded.hex()
text = "byte_array = [{}, {}, {}] \nencoded:\n{}".format(
hex(status_list.list[0]),
Expand Down
4 changes: 4 additions & 0 deletions src/status_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def encodeAsCBOR(self) -> Dict:
"bits": self.bits,
"lst": encoded_list,
}
return object

def encodeAsCBORRaw(self) -> Dict:
object = self.encodeAsCBOR()
return dumps(object)

def decode(self, input: str):
Expand Down

0 comments on commit ffce058

Please sign in to comment.