Skip to content

Commit 661efa4

Browse files
iabdalkaderdpgeorge
authored andcommitted
senml: Use the updated cbor2 API.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
1 parent 8ee876d commit 661efa4

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

micropython/senml/examples/basic_cbor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
from senml import *
2828
import time
29-
from cbor2 import decoder
29+
import cbor2
3030

3131
pack = SenmlPack("device_name")
3232

@@ -38,5 +38,5 @@
3838
cbor_val = pack.to_cbor()
3939
print(cbor_val)
4040
print(cbor_val.hex())
41-
print(decoder.loads(cbor_val)) # convert to string again so we can print it.
41+
print(cbor2.loads(cbor_val)) # convert to string again so we can print it.
4242
time.sleep(1)

micropython/senml/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
metadata(
22
description="SenML serialisation for MicroPython.",
3-
version="0.1.0",
3+
version="0.1.1",
44
pypi_publish="micropython-senml",
55
)
66

micropython/senml/senml/senml_pack.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
from senml.senml_record import SenmlRecord
2828
from senml.senml_base import SenmlBase
2929
import json
30-
from cbor2 import encoder
31-
from cbor2 import decoder
30+
import cbor2
3231

3332

3433
class SenmlPackIterator:
@@ -278,7 +277,7 @@ def from_cbor(self, data):
278277
:param data: a byte array.
279278
:return: None
280279
"""
281-
records = decoder.loads(data) # load the raw senml data
280+
records = cbor2.loads(data) # load the raw senml data
282281
naming_map = {
283282
"bn": -2,
284283
"bt": -3,
@@ -320,7 +319,7 @@ def to_cbor(self):
320319
}
321320
converted = []
322321
self._build_rec_dict(naming_map, converted)
323-
return encoder.dumps(converted)
322+
return cbor2.dumps(converted)
324323

325324
def add(self, item):
326325
"""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy