|
11 | 11 |
|
12 | 12 | This library provides support functionality for building a complete [Cyphal](https://opencyphal.org/) application in combination with [107-Arduino-Cyphal](https://github.com/107-systems/107-Arduino-Cyphal). |
13 | 13 |
|
14 | | -**Features:** |
15 | | -* API for obtaining a unique 64-bit ID. |
16 | | -* API for permanent register storage and retrieval. |
17 | | - |
18 | 14 | <p align="center"> |
19 | 15 | <a href="https://github.com/107-systems/l3xz"><img src="https://raw.githubusercontent.com/107-systems/.github/main/logo/l3xz-logo-memento-mori-github.png" width="30%"></a> |
20 | 16 | <a href="https://github.com/107-systems/viper"><img src="https://github.com/107-systems/.github/raw/main/logo/viper.jpg" width="30%"></a> |
21 | 17 | </p> |
22 | 18 |
|
23 | 19 | This library works for |
24 | 20 | * [arduino-pico](https://github.com/earlephilhower/arduino-pico): [`Raspberry Pi Pico`](https://www.raspberrypi.org/products/raspberry-pi-pico), `Adafruit Feather RP2040`, ... :heavy_check_mark: |
| 21 | + |
| 22 | +**Features:** |
| 23 | +* API for obtaining a **unique 64-bit ID**. |
| 24 | +```C++ |
| 25 | +auto /* std::array<uint8_t, 16> */ const UNIQUE_ID = cyphal::support::UniqueId::instance().value(); |
| 26 | +``` |
| 27 | +* API for **persistent register storage and retrieval**. |
| 28 | +```C++ |
| 29 | +/* Declaration of key/value storage. */ |
| 30 | +cyphal::support::platform::storage::littlefs::KeyValueStorage kv_storage(filesystem); |
| 31 | + |
| 32 | +/* Load persistently stored registers from a non-volatile memory (EEPROM, flash, etc.). */ |
| 33 | +if (auto const opt_err = cyphal::support::load(kv_storage, *node_registry); opt_err.has_value()) |
| 34 | +{ |
| 35 | + Serial.print("load failed with error code "); |
| 36 | + Serial.println(static_cast<int>(opt_err.value())); |
| 37 | +} |
| 38 | + |
| 39 | +/* Store persistent registers to a non-volatile memory (EEPROM, flash, etc.). */ |
| 40 | +if (auto const opt_err = cyphal::support::save(kv_storage, *node_registry); opt_err.has_value()) |
| 41 | +{ |
| 42 | + Serial.print("save failed with error code "); |
| 43 | + Serial.println(static_cast<int>(opt_err.value())); |
| 44 | +} |
| 45 | +``` |
0 commit comments