#ifndef HIDDEN_TX_SCANNER_H
#define HIDDEN_TX_SCANNER_H

// ============================================================================
// hidden_tx_scanner.h — Whitehat continuous-carrier / hidden-camera scanner
// (ADDITIVE, reuses existing spectrum capture, no new radio duty cycle).
//
// Legitimate physical basis (different from the passive-listener/LO-leak
// idea already confirmed not viable): a hidden analog or low-cost digital
// video transmitter is an ACTIVE, continuously-transmitting device -- it
// keeps a near-constant carrier on one frequency, unlike legitimate WiFi/
// BLE traffic, which is packetized and bursty even under heavy load (real
// APs still have idle gaps between frames). This tracks, per frequency
// bin, how many CONSECUTIVE seconds occupancy has stayed above a high
// threshold -- a sustained, unbroken run is the anomalous signature a
// continuous carrier produces that ordinary packetized traffic does not.
//
// Reuses capture_rf_spectrum()'s existing 128-bin 2.4GHz spectrum (already
// computed every main-loop cycle for the drone_classifier) -- adds pure
// analysis, no additional radio scanning.
//
// HONEST LIMITATIONS:
//   - 2.4GHz only. Many cheap "spy cameras" and analog FPV-style video
//     transmitters use 5.8GHz, which this sensor's hardware cannot reach
//     at all (same hard frequency-range wall as the earlier TSCM finding).
//   - A genuinely busy, sustained WiFi flow (e.g. a long video call or
//     large file transfer occupying one channel continuously) can also
//     trigger this -- it is a real anomaly signal, not a confirmed camera
//     identification. Report findings as "investigate this," not "camera
//     found here."
//   - A digital WiFi-based camera (most modern cheap ones) transmits
//     ordinary 802.11 traffic and does NOT necessarily look anomalous by
//     this specific signature -- this catches continuous-carrier analog/
//     low-cost video links specifically, not all hidden cameras.
// ============================================================================

#include <cstdint>
#include <cstddef>

void hidden_tx_scanner_init();

// Feed the current spectrum snapshot. Call once per main-loop cycle,
// right after capture_rf_spectrum() populates it. bins must have
// SPECTRUM_BINS (128) entries, same format as the drone_classifier input
// (log-scale RSSI proxy, 0=noise floor, 1=max signal).
void hidden_tx_scanner_observe(const float* bins, size_t n_bins);

struct HiddenTxFinding {
    float    freq_mhz;
    uint32_t sustained_seconds;   // how long this bin has stayed above threshold
    float    occupancy;           // current bin value
};

struct HiddenTxStats {
    uint16_t active_suspects;     // bins currently past the sustained-duration flag
    uint32_t longest_sustained_seconds;
};

void hidden_tx_scanner_get_stats(HiddenTxStats* out);

// Snapshot currently-flagged bins. Returns the number written (<= max).
size_t hidden_tx_scanner_list_findings(HiddenTxFinding* out, size_t max);

#endif // HIDDEN_TX_SCANNER_H
