Skip to content
  • Andy Green's avatar
    lecp: add CBOR stream parser LECP like JSON LEJP · dcaa0013
    Andy Green authored
    This provides very memory-efficient CBOR stream parsing
    and writing.
    
    The parser  converts pieces of CBOR into callbacks that define
    the structure and collate string and blobs into buffer chunks
    for extensible and easy access.
    
    It is fragementation-safe and does not need all the CBOR in
    the same place at one time, chunks of CBOR are parsed and
    discarded as provided.
    
    It does not allocate and just needs a few hundred bytes of
    stack for even huge CBOR objects.  Huge strings and blobs
    are handled without needing memory to hold them atomically.
    
    Includes ./minimal-examples/api-tests/api-test-lecp that
    unit tests it against 82 official example CBORs and
    26 additional test vectors from COSE (just checking the CBOR
    parsing).
    
    The writing apis allow printf style semantics with a variety
    of CBOR-aware %-formats.  The apis write into a context that
    manages output buffer usage, if the output buffer fills,
    then the apis return with an AGAIN code that lets you issue
    and reset the output buffer and repeat the api all to issue
    more output.  The subsequent calls can occur much later or
    from a different function context, so this is perfect for
    WRITEABLE-mediated output from the network parts of lws.
    
    See ./READMEs/README.cbor-lecp.md
    dcaa0013
This project is licensed under the Apache License 2.0. Learn more