#pragma once

#include "device.h"
#include "../led_strip/led_strip.h"
#include "key.h"
#include "protocol/p_protocol.h"
#include "protocol/resend_protl.h"
#include "protocol/stmisp.h"
#include "ota_u.h"
#include "../../config/app_config.h"

#define FC_ADDRESS "0x08000000"

typedef struct 
{
    device_t device;
    os_thread_t embedded_thread;
    os_thread_t pc_thread;
    os_thread_t task_thread;
    os_thread_t app_thread;
    ota_u_t otau;

    //自定义协议
    resend_device_t resend_device;
    SemaphoreHandle_t resend_read_mutex;
    
    //STMISP协议
    stmisp_device_t stmisp_device;
    
    uint32_t fc_address;
}sertrf_t;

typedef struct 
{
    char ble_name[32];
    char wifi_ap_ssid[32];
    char wifi_ap_password[32];
    char wifi_sta_ssid[32];
    char wifi_sta_password[32];
}sertrf_stauct_t;
/**
 * @brief 模块初始化
*/
void sertrf_init(void);

/**
 * @brief 模块启动
*/
void sertrf_start(void);

/**
 * @brief 模块停止
*/
void sertrf_stop(void);

/**
 * @brief 射频模块开关
 */
void sertrf_rf_switch(uint8_t on);

/**
 * @brief 模块数据查看
*/
void sertrf_status(void);

/**
 * @brief embedded thread
*/
void embedded_thread(void* arg);

/**
 * @brief pc thread
*/
void pc_thread(void* arg);
/**
 * @brief app thread
 */
void app_thread(void* arg);
/**
 * @brief task thread
 */
void task_thread(void* arg);
/**
 * @brief 根据连接状态显示不同的颜色
 * 
 * @param connect 连接状态
*/
void pc_link_rgb_color(device_t* device);


