Skip to content

Commit 49b561d

Browse files
authored
Update note helper to support port and compact format (#85)
* Update note helper to support port and compact format Signed-off-by: Kimball Johnson <kimball@bowerham.net> * Update note add helper to support port Signed-off-by: Kimball Johnson <kimball@bowerham.net> --------- Signed-off-by: Kimball Johnson <kimball@bowerham.net>
1 parent 3c0b109 commit 49b561d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

notecard/note.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
@validate_card_object
17-
def add(card, file=None, body=None, payload=None, sync=None):
17+
def add(card, file=None, body=None, payload=None, sync=None, port=None):
1818
"""Add a Note to a Notefile.
1919
2020
Args:
@@ -23,6 +23,8 @@ def add(card, file=None, body=None, payload=None, sync=None):
2323
body (JSON object): A developer-defined tracker ID.
2424
payload (string): An optional base64-encoded string.
2525
sync (bool): Perform an immediate sync after adding.
26+
port (int): If provided, a unique number to represent a notefile.
27+
Required for Notecard LoRa.
2628
2729
Returns:
2830
string: The result of the Notecard request.
@@ -34,6 +36,8 @@ def add(card, file=None, body=None, payload=None, sync=None):
3436
req["body"] = body
3537
if payload:
3638
req["payload"] = payload
39+
if port:
40+
req["port"] = port
3741
if sync is not None:
3842
req["sync"] = sync
3943
return card.Transaction(req)
@@ -150,7 +154,7 @@ def update(card, file=None, note_id=None, body=None, payload=None):
150154

151155

152156
@validate_card_object
153-
def template(card, file=None, body=None, length=None):
157+
def template(card, file=None, body=None, length=None, port=None, compact=False):
154158
"""Create a template for new Notes in a Notefile.
155159
156160
Args:
@@ -160,6 +164,11 @@ def template(card, file=None, body=None, length=None):
160164
values as "hints" for the data type.
161165
length (int): If provided, the maximum length of a payload that
162166
can be sent in Notes for the template Notefile.
167+
port (int): If provided, a unique number to represent a notefile.
168+
Required for Notecard LoRa.
169+
compact (boolean): If true, sets the format to compact to tell the
170+
Notecard to omit this additional metadata to save on storage
171+
and bandwidth. Required for Notecard LoRa.
163172
164173
Returns:
165174
string: The result of the Notecard request.
@@ -171,4 +180,8 @@ def template(card, file=None, body=None, length=None):
171180
req["body"] = body
172181
if length:
173182
req["length"] = length
183+
if port:
184+
req["port"] = port
185+
if compact:
186+
req["format"] = "compact"
174187
return card.Transaction(req)

0 commit comments

Comments
 (0)