75 lines
1.9 KiB
C
75 lines
1.9 KiB
C
/*
|
||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||
*
|
||
* SPDX-License-Identifier: Apache-2.0
|
||
*
|
||
* Change Logs:
|
||
* Date Author Notes
|
||
* 2023-04-21 murmur the first version
|
||
*/
|
||
#ifndef APPLICATIONS_TTMSG_TTMSG_H_
|
||
#define APPLICATIONS_TTMSG_TTMSG_H_
|
||
|
||
#include <rtthread.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
|
||
#include <stdint.h>
|
||
#include <string.h>
|
||
#include <dfs_file.h>
|
||
|
||
#define FRAME_DATA_LEN_MAX 180
|
||
|
||
typedef enum{
|
||
//
|
||
|
||
//加密,低2位
|
||
CRY_NONE=0,
|
||
CRY_AES,
|
||
CRY_RSA,
|
||
|
||
//压缩,次高2位
|
||
COMP_NONE=(0<<2),
|
||
COMP_QUICK_LZ=(1<<2),//压缩率中等,demo约1/0.62,资源占用少
|
||
COMP_LZMA=(2<<2),//压缩率可能最高,样例报错还未定位,猜测是内存不足
|
||
|
||
//数据类型子类,随CTRL_MODE不同而不同,共3位8种
|
||
MODE_0=(0<<4),
|
||
MODE_1=(1<<4),
|
||
//数据类型,最高位
|
||
CTRL_MODE=(0<<7),
|
||
DATA_MODE=(1<<7),
|
||
|
||
//
|
||
|
||
}fopt_e;
|
||
|
||
#pragma pack(1)
|
||
typedef struct{
|
||
//帧头
|
||
//格式是TT厂家确定的,厂家不变则不会变,13字节
|
||
rt_uint8_t fstart[4];//
|
||
rt_uint8_t fnum[2] ;
|
||
rt_uint8_t fbak[2] ;
|
||
rt_uint8_t ftype[2] ;//固定位0x7021
|
||
rt_uint8_t fdlen[2] ;//总数据长度,从ccid开始计算
|
||
rt_uint8_t fcrc[1] ;//
|
||
|
||
//数据体,部分自定义
|
||
//目标终端前4字节必须为CCID,厂家定义
|
||
rt_uint8_t ftccid[4] ;//
|
||
|
||
//自定义数据,格式如下
|
||
rt_uint8_t findex[6] ;//唯一ID号,索引号:年月日时分秒+1字节随机码 年取后两位(2023即23),随机码为防止RTC复位后时间错乱
|
||
rt_uint8_t fcfg[1] ;//数据类型 |压缩方式|加密方式
|
||
rt_uint8_t fcurpiece[1];//当前分片数
|
||
rt_uint8_t fallpiece[1];//总分片数
|
||
rt_uint8_t fdata[];//当前分片数据,为待发数据
|
||
|
||
}MSG;
|
||
|
||
rt_uint8_t packMsg(rt_uint8_t *din, rt_uint8_t len, rt_uint8_t *id, rt_uint8_t flag, rt_uint8_t *dout);
|
||
|
||
|
||
#endif /* APPLICATIONS_TTMSG_TTMSG_H_ */
|