#ifndef RF_CLASSIFIER_H
#define RF_CLASSIFIER_H

#include <cstdint>
#include <cstddef>
#include "config.h"

// Result from a single classification inference
struct ClassificationResult {
    uint8_t class_label;     // ClassLabel enum value
    float   confidence;      // 0.0 - 1.0
    float   probabilities[NUM_CLASSES];
};

// Initialize TFLite-Micro runtime: load model from SPIFFS, allocate arena in PSRAM
bool classifier_init();

// Run inference on a 128-element float32 RF power spectrum.
// Returns true on success, fills result.
bool classifier_infer(const float* spectrum, ClassificationResult& result);

// Hot-swap the model in memory (called by OTA adapter after receiving new model).
// model_data must remain valid until next swap or reboot.
bool classifier_swap_model(const uint8_t* model_data, size_t model_size);

// Runtime-adjustable confidence threshold. The default value is
// CONFIDENCE_THRESHOLD from config.h. Command handler SET_THRESHOLD uses these
// to override per model_id at runtime. model_id 0 refers to the legacy
// single-model rf_classifier; higher IDs refer to multi-model slots and are
// forwarded to model_manager (currently a no-op placeholder returning true).
bool classifier_set_confidence_threshold(uint8_t model_id, float threshold);
float classifier_get_confidence_threshold(uint8_t model_id);

// Free classifier resources
void classifier_deinit();

#endif // RF_CLASSIFIER_H
