@@ -299,3 +299,75 @@ def location_track(card, start=None, heartbeat=None, hours=None, sync=None, stop
299299 if file :
300300 req ["file" ] = file
301301 return card .Transaction (req )
302+
303+
304+ @validate_card_object
305+ def binary (card , delete = None ):
306+ """View the status of the binary storage area of the Notecard and optionally clear data.
307+
308+ Args:
309+ card (Notecard): The current Notecard object.
310+ delete (bool): Set to True to clear the COBS area on the Notecard and reset all related arguments.
311+
312+ Returns:
313+ dict: The result of the Notecard request containing binary storage information including:
314+ "cobs": The size of COBS-encoded data stored in the reserved area
315+ "connected": Returns True if the Notecard is connected to the network
316+ "err": If present, a string describing the error that occurred during transmission
317+ "length": The length of the binary data
318+ "max": Available storage space
319+ "status": MD5 checksum of unencoded buffer
320+ """
321+ req = {"req" : "card.binary" }
322+ if delete is not None :
323+ req ["delete" ] = delete
324+ return card .Transaction (req )
325+
326+
327+ @validate_card_object
328+ def binary_get (card , cobs = None , offset = None , length = None ):
329+ """Retrieve binary data stored in the binary storage area of the Notecard.
330+
331+ Args:
332+ card (Notecard): The current Notecard object.
333+ cobs (int): The size of the COBS-encoded data you are expecting to be returned (in bytes).
334+ offset (int): Used along with length, the number of bytes to offset the binary payload from 0 when retrieving binary data.
335+ length (int): Used along with offset, the number of bytes to retrieve from the binary storage area.
336+
337+ Returns:
338+ dict: The result of the Notecard request. The response returns the JSON-formatted response object, then the binary data.
339+ "status": The MD5 checksum of the data returned, after it has been decoded
340+ "err": If present, a string describing the error that occurred during transmission
341+ """
342+ req = {"req" : "card.binary.get" }
343+ if cobs :
344+ req ["cobs" ] = cobs
345+ if offset is not None :
346+ req ["offset" ] = offset
347+ if length :
348+ req ["length" ] = length
349+ return card .Transaction (req )
350+
351+
352+ @validate_card_object
353+ def binary_put (card , offset = None , cobs = None , status = None ):
354+ """Add binary data to the binary storage area of the Notecard.
355+
356+ Args:
357+ card (Notecard): The current Notecard object.
358+ offset (int): The number of bytes to offset the binary payload from 0 when appending the binary data to the binary storage area.
359+ cobs (int): The size of the COBS-encoded data (in bytes).
360+ status (string): The MD5 checksum of the data, before it has been encoded.
361+
362+ Returns:
363+ dict: The result of the Notecard request. The Notecard expects to receive binary data immediately following the usage of this API command.
364+ "err": If present, a string describing the error that occurred during transmission
365+ """
366+ req = {"req" : "card.binary.put" }
367+ if offset is not None :
368+ req ["offset" ] = offset
369+ if cobs :
370+ req ["cobs" ] = cobs
371+ if status :
372+ req ["status" ] = status
373+ return card .Transaction (req )
0 commit comments