esp-idf/examples/protocols/cbor
2022-11-01 11:23:21 +08:00
..
main examples/cbor: keep newlib nano disabled in the example 2022-07-19 13:27:51 +05:30
CMakeLists.txt tools: Increase the minimal supported CMake version to 3.16 2022-06-01 06:35:02 +00:00
pytest_cbor.py CI: update test cases to use different environment variables 2022-07-15 01:16:35 +08:00
README.md ci: Enable esp32c6 example, test_apps, and unit tests CI build stage 2022-11-01 11:23:21 +08:00
sdkconfig.defaults examples/cbor: keep newlib nano disabled in the example 2022-07-19 13:27:51 +05:30

Supported Targets ESP32 ESP32-C2 ESP32-C3 ESP32-C6 ESP32-S2 ESP32-S3

CBOR Example

(See the README.md file in the upper level 'examples' directory for more information about examples.)

Overview

The CBOR(Concise Binary Object Representation) is a binary data serialization format which is similar to JSON but with smaller footprint. This example will illustrate how to encode and decode CBOR data using the APIs provided by tinycbor.

For detailed information about how CBOR encoding and decoding works, please refer to REF7049 or cbor.io;

How to use example

Hardware Required

This example should be able to run on any commonly available ESP32 development board.

Build and Flash

Run idf.py -p PORT flash monitor to build and flash the project.

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example Output

I (320) example: encoded buffer size 67
I (320) example: convert CBOR to JSON
[{"chip":"esp32","unicore":false,"ip":[192,168,1,100]},3.1400001049041748,"simple(99)","2019-07-10 09:00:00+0000","undefined"]
I (340) example: decode CBOR manually
Array[
  Map{
    chip
    esp32
    unicore
    false
    ip
    Array[
      192
      168
      1
      100
    ]
  }
  3.14
  simple(99)
  2019-07-10 09:00:00+0000
  undefined
]

Troubleshooting

For more API usage, please refer to tinycbor API.

(For any technical queries, please open an issue on GitHub. We will get back to you as soon as possible.)