/* parser.h */
#ifndef PARSER_H
#define PARSER_H

#include <stdint.h>
#include <stdbool.h>

/* Platform-dependent function pointer set */
typedef struct {
    void (*log)(const char *fmt, ...);
    void (*tx_bin)(const uint8_t *buf, uint16_t len);
    bool crc_check;  
} dr_platform_if_t;


#define DR_MAX_DATA 128  /* Max data length after TAG */

typedef struct {
    char    tag[5];               /* "sta?" etc 4 chars + '\0' */
    uint8_t data[DR_MAX_DATA];    /* Raw data after TAG */
    uint8_t data_len;             /* Length of data[] */
} ParsedCmd;

typedef int (*cmd_handler_t)(const ParsedCmd *cmd);

typedef struct {
    char tag[5];                  /* "sta?" */
    bool enabled;                 /* false = handler won't be called */
    cmd_handler_t handler;        /* 1=success, 0=fail */
} CmdEntry;

/* Global interface & log flag */
extern dr_platform_if_t g_plat;
extern bool g_log_enable;

/* Main parser entry point */
int dr_cmd_parser(const uint8_t *buf, uint8_t len);

#endif /* PARSER_H */

