Skip to content

Unit state storage

Allows a Unit to store textual data directly in Pepeunit. This storage is well suited for the following categories of data:

  1. The last state of the Unit
  2. Cached user input data from Users
  3. Data that is large by microcontroller standards

TIP

The Unit state storage is long-term memory that the Unit can use at any time.

DANGER

The size of this storage is limited by the size of encrypted objects on a Pepeunit instance.

Sending data to the storage

To set a value, follow this algorithm:

  1. Compute the Unit uuid based on the PU_AUTH_TOKEN JWT from env.json.

  2. Convert your value or data structure into a string.

  3. Make a request. The PU_HTTP_TYPE and PU_DOMAIN variables are available inside env.json:

    bash
    curl -X 'POST' \
    'PU_HTTP_TYPE://PU_DOMAIN/pepeunit/api/v1/units/set_state_storage/{Unit.uuid}' \
    -H 'accept: */*' \
    -H 'Content-Type: application/json' \
    -d '{
    "state": "best_data_for_save_in_storage"
    }'

INFO

You can easily convert this curl request into an http request in any programming language—just pass a copy of it to an LLM.

Retrieving data from the storage

To retrieve a value, follow this algorithm:

  1. Compute the Unit uuid based on the PU_AUTH_TOKEN JWT from env.json.
  2. Make a request. The PU_HTTP_TYPE and PU_DOMAIN variables are available inside env.json:
    • PU_HTTP_TYPE://PU_DOMAIN/pepeunit/api/v1/units/get_state_storage/{Unit.uuid}
  3. Convert the string returned by Pepeunit into your data structure or value.