Skip to content

Pepeunit Framework

Links to library repositories

INFO

Each library is a client Framework for working with Pepeunit.

The goal of the Framework is to simplify development of new Units by providing:

  • core functionality for integration with Pepeunit
  • utilities for managing the application main loop

Feature set

  1. Built‑in MQTT client:
  2. Built‑in REST client:
  3. Receiving and correctly handling standard Pepeunit MQTT commands
  4. Sending and generating Unit state
  5. Functionality for working with schema.json:
    • dynamic updates
    • search across all four topic types
    • search topics by UnitNode.uuid or by full physical topic name
  6. Functionality for working with env.json:
    • dynamic updates
    • obtaining Unit.uuid from the token
    • accessing any variable as an attribute of a settings class
  7. Logging functionality:
    • 5 log levels: debug, info, warning, error, critical
    • sending logs over MQTT
    • saving logs to log.json
    • ability to clear logs
  8. Setting a custom update handler for the Unit
  9. Setting an Input MQTT message handler
  10. Setting an Output MQTT message handler
  11. Ability to choose multiple update strategies
  12. aes-gcm-256 encryption with 16/24/32‑byte keys (for manual use)
  13. Main application loop control:
    • start
    • stop
    • dynamic handler changes

log.json

INFO

The Unit "black box" – stores the last N log entries regardless of network state.

Logs are stored in ndjson format, where each line separated by \n is a JSON object:

ndjson
{"create_datetime":"2025-11-12T19:43:53Z","level":"Info","text":"MQTT connected successfully"}
{"create_datetime":"2025-11-12T19:44:37Z","level":"Info","text":"MQTT client connected successfully"}
{"create_datetime":"2025-11-12T22:00:10Z","level":"Info","text":"Get base MQTT command: update/pepeunit"}
{"create_datetime":"2025-11-12T22:00:10Z","level":"Warning","text":"COMPILED_FIRMWARE_LINK is missing in update payload"}
{"create_datetime":"2025-11-12T23:00:10Z","level":"Info","text":"Get base MQTT command: update/pepeunit"}
{"create_datetime":"2025-11-12T23:00:10Z","level":"Warning","text":"COMPILED_FIRMWARE_LINK is missing in update payload"}
{"create_datetime":"2025-11-12T23:08:50Z","level":"Info","text":"Get base MQTT command: update/pepeunit"}
{"create_datetime":"2025-11-12T23:08:50Z","level":"Warning","text":"COMPILED_FIRMWARE_LINK is missing in update payload"}
{"create_datetime":"2025-11-12T23:25:41Z","level":"Info","text":"MQTT client connected successfully"}
{"create_datetime":"2025-11-12T23:25:41Z","level":"Info","text":"Connected to MQTT Broker"}
{"create_datetime":"2025-11-12T23:25:42Z","level":"Info","text":"Success subscribed to 4 topics"}

The buffer capacity is controlled by the PU_MAX_LOG_LENGTH environment variable; new entries are appended at the end of the file, and old entries are removed from the beginning once their index from the end exceeds PU_MAX_LOG_LENGTH.

You can access this file physically (via device ports) or via the log_sync command.