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

99 lines
2.1 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,
}port_type_m;
typedef enum
2025-09-22 14:32:55 +08:00
{
MESSAGE_IDLE = 0,
MESSAGE_OTA,
}message_status_m;
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中
}protocol_status_t;
2025-09-02 14:20:28 +08:00
typedef struct
{
protocol_port_t port;
protocol_type_m pro_type;
port_type_m port_type;
mavlink_device_t mavlink_device;
msp_port_t msp;
protocol_status_t protocol_status;
2025-09-22 14:32:55 +08:00
uint16_t analysis_sussess_count; //数据解析成功次数
message_status_m message_status;
2025-09-02 14:20:28 +08:00
}protocol_t;
/**
* @brief
*
* @param port_type 使
* @param port
*/
void Protocol_init(port_type_m port_type, void* port);
/**
* @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
*/
void protocol_set_message_status(message_status_m status);
/**
* @brief
*
* @retval
*/
protocol_status_t get_protocol_status(void);
2025-09-22 14:32:55 +08:00
2025-09-02 14:20:28 +08:00
#endif