#pragma once

#define MY_LIBRARY_EXPORTS
#ifdef _WIN32 // Windows 平台
#ifdef MY_LIBRARY_EXPORTS // 如果正在构建库
#define ex_declare __declspec(dllexport) // 导出符号
#else
#define ex_declare __declspec(dllimport) // 导入符号
#endif
#else // 对于 Linux 和其他 Unix-like 系统
#define ex_declare __attribute__((visibility("default"))) // 导出符号
#endif
#include <cstdint>
#include "./error_callback.h"
#include "./device_uhd_c.h"

extern "C" {
    ex_declare void adsb_close();
    ex_declare std::size_t adsb_read(char* buf, std::size_t len);

    // IQ 数据接口
    typedef void (*iq_cbk_t)(void* phandle, void* pdata, uint64_t length);
    typedef int (*adsb_set_iq_cbk_t)(iq_cbk_t recv_cbk, void* pusr);
    typedef int (*adsb_set_less_30Mhz_ddc_param_t)(uint64_t cf_hz, uint64_t sf_hz, uint64_t bw_hz, int8_t sw);
    typedef int (*adsb_set_less_30Mhz_fft_param_t)(uint64_t fftWin, uint64_t fftLen, int fftPeriod_ms, int8_t sw);
    ex_declare int adsb_set_iq_cbk(iq_cbk_t recv_cbk, void* pusr);
    ex_declare int adsb_set_less_30Mhz_ddc_param(uint64_t cf_hz, uint64_t sf_hz, uint64_t bw_hz, int8_t sw);
    ex_declare int adsb_set_less_30Mhz_fft_param(uint64_t fftWin, uint64_t fftLen, int fftPeriod_ms, int8_t sw);




    int32_t ex_declare init_adsb9002(void **phandle, adsb_msg_cbk_t cbk, void *pusr);
    int32_t ex_declare free_adsb9002(void **phandle);
    int ex_declare set_iq_cbk(void *phandle, iq_cbk_t recv_cbk, void *pusr);
    int ex_declare set_less_30Mhz_ddc_param(void *phandle, uint64_t cf_hz, uint64_t sf_hz, uint64_t bw_hz, int8_t sw);
    int ex_declare set_less_30Mhz_fft_param(void *phandle, int fftWin, int fftLen, int fftPeriod_ms, int8_t sw);






    using init_adsb9002_ptr_t = int32_t (*)(void **phandle, adsb_msg_cbk_t cbk, void *pusr);
    using free_adsb9002_ptr_t = int32_t (*)(void **phandle);
    using set_iq_cbk_ptr_t = int (*)(void *phandle, iq_cbk_t recv_cbk, void *pusr);
    using set_less_30Mhz_ddc_param_ptr_t = int (*)(void *phandle, uint64_t cf_hz, uint64_t sf_hz, uint64_t bw_hz, int8_t sw);
    using set_less_30Mhz_fft_param_ptr_t = int (*)(void *phandle, int fftWin, int fftLen, int fftPeriod_ms, int8_t sw);
}

