From ffce058bbdbe35446433c1493a814c0e9a81b0a2 Mon Sep 17 00:00:00 2001 From: Christian Bormann Date: Thu, 12 Sep 2024 18:11:27 +0200 Subject: [PATCH] fix status_list map encoding in CWT examples --- src/main.py | 4 ++-- src/status_list.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index 63219ea..1ce0e8a 100644 --- a/src/main.py +++ b/src/main.py @@ -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) @@ -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]), diff --git a/src/status_list.py b/src/status_list.py index 51313e9..7c3e48f 100644 --- a/src/status_list.py +++ b/src/status_list.py @@ -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):