#ifndef AD_CAN_TELEMETRY_H
#define AD_CAN_TELEMETRY_H

#include <stdint.h>

typedef enum
{
    AD_CAN_TELEMETRY_STATUS_INITIALIZED = (1UL << 0),
    AD_CAN_TELEMETRY_STATUS_STARTED = (1UL << 1),
    AD_CAN_TELEMETRY_STATUS_TX_BUSY = (1UL << 2),
    AD_CAN_TELEMETRY_STATUS_TX_DROPPED = (1UL << 3),
    AD_CAN_TELEMETRY_STATUS_ERROR = (1UL << 4)
} AD_CAN_TelemetryStatusFlag_t;

typedef struct
{
    uint8_t initialized;
    uint8_t started;
    uint8_t tx_busy;
    uint8_t reserved;
    uint32_t status_flags;
    uint32_t tx_packets;
    uint32_t tx_frames;
    uint32_t dropped_packets;
    uint32_t error_count;
    uint32_t last_error;
    uint32_t base_id;
    uint32_t last_size_bytes;
} AD_CAN_TelemetryState_t;

void AD_CAN_Telemetry_Init(void);
void AD_CAN_Telemetry_Loop(void);
uint8_t AD_CAN_Telemetry_QueuePacket(const uint8_t *data, uint16_t size);
uint8_t AD_CAN_Telemetry_IsStarted(void);
uint8_t AD_CAN_Telemetry_IsTxBusy(void);
const AD_CAN_TelemetryState_t* AD_CAN_Telemetry_GetState(void);

#endif
