mcu_hi3321_watch/tjd/ble/protocol/ble_ota_server.h
2025-05-26 20:15:20 +08:00

115 lines
3.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef _USER_OTA_SERVER_H_
#define _USER_OTA_SERVER_H_
#include "sys_config.h"
#include "ble_protocol.h"
#define FILE_NAME_LENGTH_MAX (72) // 固件文件名最大长度
#define APP_WAIT_TIME_MAX 3
/********************************
*4.12.1 APP通知升级状态
**********************************/
enum
{
PackageVersionType=1,
FileLenghtType,
OtaModelType,
OtaStatusType,
BatteryThresholdType,
AppWaitTimeOutType,
OtaMTUSizeType,
};
/********************************
*4.12.2 APP 通知设备升级状态
**********************************/
enum
{
AppOtaStatusType=1,
};
/********************************
*4.2 OTA服务下面的命令ID
**********************************/
enum
{
CheckIFOtaModeID=1, //4.12.1 询问是否可以进入OTA 模式
AppNoticeOTAStatusID=2, //4.12.2 APP 通知设备升级状态
RequestOTAFileDataID=3, //4.12.3 设备根据文件信息分帧请求文件内容
ReceiveOTAFileDataID=4, //4.12.4 APP 根据设备的分帧请求返回文件内容
NoticeReceiveOTAFileSuccessID=5, //4.12.5 设备通知APP 升级包接收完
NoticeOTAUpdateTypeID=6, //4.12.6 设备回复手机文件接收完毕校验并指定由谁开启OTA 流程
DeviceOTAErrReportID=7, //4.12.7 设备端OTA 状态上报
AppCancelOTAID=8, //4.12.8 取消升级
Ota_server_max_ID
};
/********************************
*4.12.3 设备根据文件信息分帧请求文件内容
**********************************/
enum
{
OtaFileOffsetType=1,
OtaRequestDataLenType,
OtaTotalFileSizeType,
OtaReceivedFileLenType
};
/********************************
4.12.5 设备通知APP 升级包接收完
**********************************/
enum
{
OtaReceivedEndtype=1,
};
/********************************
4.12.6 设备回复手机文件接收完毕校验并指定由谁开启OTA 流程
**********************************/
enum
{
PkgValidityType=1,
WhichStartOtaType,
AppStartOtaType
};
/********************************
4.12.7 设备端OTA 状态上报
**********************************/
enum
{
OtaErrorResultype=1,
};
/********************************
4.12.8 取消升级
**********************************/
enum
{
CancelOtaType=1,
};
//ota 固件信息参数
typedef struct
{
uint32_t OtaFlieLenFromAPP; // APP发送的固件长度有可能和实际收到的固件长度不一样
uint8_t OtaFileName[FILE_NAME_LENGTH_MAX]; // 从APP端接收的固件文件名信息内容
uint8_t OtaWorkMode; // 升级模式 前台/后台
uint8_t DeviceOtaStatus; // 0可以升级 1不可以升级
uint8_t AppOtaStatus; // 0可以升级 1不可以升级
}ota_fw_info_t;
extern void ota_clear_disconnect(void);
extern void OtaCreatRestartTimer(void);
extern const p_func_t user_Ota_server_func[Ota_server_max_ID];
#endif