#pragma once

#include <Arduino.h>
#include <Bytes.h>
#include <stdarg.h>

#ifndef RNS_DEBUG_INSTRUMENTATION
#define RNS_DEBUG_INSTRUMENTATION 1
#endif

#ifndef RNS_DEBUG_VERBOSE
#define RNS_DEBUG_VERBOSE 0
#endif

class DebugStats {
public:
  static void set_board(const String& board);
  static void set_role(const char* role);
  static const char* board();
  static const char* role();

  static uint32_t crc32(const uint8_t* data, size_t len);
  static String edge_hex(const uint8_t* data, size_t len, bool first);
  static uint32_t bytes_crc32(const RNS::Bytes& bytes);
  static String bytes_first4(const RNS::Bytes& bytes);
  static String bytes_last4(const RNS::Bytes& bytes);

  static bool should_log_packet(uint32_t seq);
  static void note_failure();

  static void logf(const char* format, ...);
  static void vlogf(const char* format, va_list args);
  static void println(const char* line);
  static void print_mem(const char* event = "periodic");
  static void maybe_print_periodic();
};
