2025-08-20 11:28:11 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "device.h"
|
2025-08-20 11:31:55 +08:00
|
|
|
#include "../led_strip/led_strip.h"
|
2025-08-28 16:04:01 +08:00
|
|
|
#include "key.h"
|
2025-09-02 14:20:56 +08:00
|
|
|
#include "protocol/p_protocol.h"
|
2025-09-09 18:16:48 +08:00
|
|
|
#include "protocol/resend_protl.h"
|
2025-10-07 17:49:20 +08:00
|
|
|
#include "protocol/stmisp.h"
|
2025-09-09 18:07:30 +08:00
|
|
|
#include "ota_u.h"
|
2025-10-20 12:15:17 +08:00
|
|
|
#include "tool.h"
|
|
|
|
|
#include "ring_buffer.h"
|
2025-09-19 14:51:49 +08:00
|
|
|
#include "../../config/app_config.h"
|
|
|
|
|
|
2025-10-14 10:23:37 +08:00
|
|
|
#define FC_ADDRESS "0x08000000"
|
2025-10-20 12:15:17 +08:00
|
|
|
#define DATA_HANDLE_BUFFER_SIZE 4096
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
DATA_HANDLE_IDLE = 0,
|
|
|
|
|
DATA_HANDLE_OTA_DATA,
|
|
|
|
|
DATA_HANDLE_OTA_DATA_END,
|
|
|
|
|
}data_handle_e;
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
data_handle_e task_state;
|
2025-10-14 10:23:37 +08:00
|
|
|
|
2025-10-20 12:15:17 +08:00
|
|
|
}sertrf_mode_status_t;
|
2025-08-20 11:28:11 +08:00
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
device_t device;
|
2025-10-20 12:15:17 +08:00
|
|
|
// 任务
|
|
|
|
|
os_thread_t embedded_thread; //处理飞控接收
|
|
|
|
|
os_thread_t pc_thread; //处理app接收
|
|
|
|
|
os_thread_t task_thread; //处理其他任务
|
|
|
|
|
os_thread_t app_thread; //处理app任务
|
|
|
|
|
os_thread_t data_handle_thread; //数据处理任务
|
|
|
|
|
|
|
|
|
|
sertrf_mode_status_t mode_status;
|
|
|
|
|
// ota
|
2025-09-09 18:07:30 +08:00
|
|
|
ota_u_t otau;
|
2025-09-15 16:48:12 +08:00
|
|
|
|
2025-10-07 17:49:20 +08:00
|
|
|
//自定义协议
|
2025-09-09 18:16:48 +08:00
|
|
|
resend_device_t resend_device;
|
|
|
|
|
SemaphoreHandle_t resend_read_mutex;
|
2025-09-15 16:48:12 +08:00
|
|
|
|
2025-10-07 17:49:20 +08:00
|
|
|
//STMISP协议
|
|
|
|
|
stmisp_device_t stmisp_device;
|
|
|
|
|
|
2025-10-20 12:15:17 +08:00
|
|
|
// 环形buff
|
|
|
|
|
RingBuffer data_handle_buffer;
|
2025-10-14 10:23:37 +08:00
|
|
|
uint32_t fc_address;
|
2025-10-23 18:39:07 +08:00
|
|
|
|
|
|
|
|
// efuse MAC 地址
|
|
|
|
|
uint8_t efuse_mac[6];
|
|
|
|
|
uint8_t efuse_mac_encrypt[6];
|
|
|
|
|
|
2025-08-20 11:28:11 +08:00
|
|
|
}sertrf_t;
|
|
|
|
|
|
2025-10-23 18:39:07 +08:00
|
|
|
typedef struct __attribute__((packed))
|
2025-09-19 14:51:49 +08:00
|
|
|
{
|
|
|
|
|
char ble_name[32];
|
|
|
|
|
char wifi_ap_ssid[32];
|
|
|
|
|
char wifi_ap_password[32];
|
|
|
|
|
char wifi_sta_ssid[32];
|
|
|
|
|
char wifi_sta_password[32];
|
2025-10-23 18:39:07 +08:00
|
|
|
uint8_t efuse_mac_encrypt[6];
|
2025-09-19 14:51:49 +08:00
|
|
|
}sertrf_stauct_t;
|
2025-08-20 11:28:11 +08:00
|
|
|
/**
|
|
|
|
|
* @brief 模块初始化
|
|
|
|
|
*/
|
|
|
|
|
void sertrf_init(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 模块启动
|
|
|
|
|
*/
|
|
|
|
|
void sertrf_start(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 模块停止
|
|
|
|
|
*/
|
|
|
|
|
void sertrf_stop(void);
|
|
|
|
|
|
2025-10-20 12:06:29 +08:00
|
|
|
/**
|
|
|
|
|
* @brief 射频模块开关
|
|
|
|
|
*/
|
|
|
|
|
void sertrf_rf_switch(uint8_t on);
|
|
|
|
|
|
2025-08-20 11:28:11 +08:00
|
|
|
/**
|
|
|
|
|
* @brief 模块数据查看
|
|
|
|
|
*/
|
|
|
|
|
void sertrf_status(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief embedded thread
|
|
|
|
|
*/
|
|
|
|
|
void embedded_thread(void* arg);
|
2025-09-09 18:07:30 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief pc thread
|
|
|
|
|
*/
|
|
|
|
|
void pc_thread(void* arg);
|
2025-09-15 16:48:12 +08:00
|
|
|
/**
|
|
|
|
|
* @brief app thread
|
|
|
|
|
*/
|
|
|
|
|
void app_thread(void* arg);
|
2025-09-04 16:01:12 +08:00
|
|
|
/**
|
|
|
|
|
* @brief task thread
|
|
|
|
|
*/
|
|
|
|
|
void task_thread(void* arg);
|
2025-10-20 12:15:17 +08:00
|
|
|
/**
|
|
|
|
|
* @brief data handle thread
|
|
|
|
|
*/
|
|
|
|
|
void data_handle_thread(void* arg);
|
|
|
|
|
|
2025-08-20 16:46:15 +08:00
|
|
|
/**
|
|
|
|
|
* @brief 根据连接状态显示不同的颜色
|
2025-08-28 16:04:01 +08:00
|
|
|
*
|
|
|
|
|
* @param connect 连接状态
|
|
|
|
|
*/
|
|
|
|
|
void pc_link_rgb_color(device_t* device);
|
2025-10-20 12:06:29 +08:00
|
|
|
|
2025-08-20 11:28:11 +08:00
|
|
|
|