Files
ESPC3-wireless/app/drivers/sertrf/protocol/p_protocol.h

107 lines
2.3 KiB
C
Raw Normal View History

2025-09-02 14:20:28 +08:00
#pragma once
#ifndef PROJECT_H
#define PROJECT_H
#include "../device.h"
#include "mavlink_control.h"
#include "MSP.h"
typedef struct
{
int* uart_fd;
sb_data_port_t* data_port;
}protocol_port_t;
typedef enum
{
PROTOCOL_IDLE,
PROTOCOL_MSP,
PROTOCOL_MAVLINK,
}protocol_type_m;
typedef enum
{
PORT_LINUX_UART = 0,
PORT_LINUX_SBDATA,
2025-10-27 18:51:14 +08:00
}port_type_e;
typedef enum
2025-09-22 14:32:55 +08:00
{
MESSAGE_IDLE = 0,
MESSAGE_OTA,
2025-10-27 18:51:14 +08:00
MESSAGE_FC_ISP,
}message_status_e;
2025-09-22 14:32:55 +08:00
typedef enum
{
PROTOCOL_STATUS_OK = 0,
PROTOCOL_STATUS_NO_DATA, //没有收到数据,或者数据小于一定量
PROTOCOL_STATUS_TYPE_IDLE, //协议类型未知
PROTOCOL_STATUS_ANALYSIS_ERROR, //长时间解析失败
2025-09-22 14:32:55 +08:00
PROTOCOL_STATUS_IN_OTA, //OTA中
2025-10-27 18:51:14 +08:00
}protocol_status_e;
2025-09-02 14:20:28 +08:00
typedef struct
{
protocol_port_t port;
protocol_type_m pro_type;
2025-10-27 18:51:14 +08:00
port_type_e port_type;
2025-09-02 14:20:28 +08:00
mavlink_device_t mavlink_device;
msp_port_t msp;
2025-10-27 18:51:14 +08:00
protocol_status_e protocol_status;
2025-09-22 14:32:55 +08:00
uint16_t analysis_sussess_count; //数据解析成功次数
2025-10-27 18:51:14 +08:00
message_status_e message_status;
mavlink_message_t message;
2025-09-02 14:20:28 +08:00
}protocol_t;
/**
* @brief
*
* @param port_type 使
* @param port
*/
2025-10-27 18:51:14 +08:00
void Protocol_init(port_type_e port_type, void* port);
2025-09-02 14:20:28 +08:00
/**
* @brief
*
* @retval
*/
int Protocol_search();
/**
* @brief 使使
*/
void Protocol_loop(void* arg);
/**
* @brief
*
* @param data
* @param size
* @retval
*/
int Protocol_buf_search(void* data, uint32_t size);
/**
* @brief
*
* @param data
* @param size
*/
void Protocol_buf_decode(void* data, uint32_t size);
2025-09-22 14:32:55 +08:00
/**
* @brief
*
* @param status
*/
2025-10-27 18:51:14 +08:00
void protocol_set_message_status(message_status_e status);
/**
* @brief
*
* @retval
*/
2025-10-27 18:51:14 +08:00
protocol_status_e get_protocol_status(void);
2025-09-22 14:32:55 +08:00
/**
* @brief
*
*/
int fc_reboot(void);
2025-09-02 14:20:28 +08:00
#endif