106 lines
2.9 KiB
C
106 lines
2.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 "posix/string.h"
|
||
#include <dfs_file.h>
|
||
#include <usrcfg.h>
|
||
#define FRAME_DATA_LEN_MAX (180-10-20)
|
||
#define STR_LEN_MAX 30
|
||
|
||
/*
|
||
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_FAST_LZ=(2<<2),
|
||
COMP_LZMA=(3<<2),//压缩率可能最高,样例报错还未定位,猜测是内存不足
|
||
|
||
//数据类型子类,随CTRL_MODE不同而不同,共3位8种
|
||
MODE_0=(0<<4),
|
||
MODE_1=(1<<4),
|
||
// 。。。
|
||
MODE_7=(1<<4),
|
||
//数据类型,最高位
|
||
CTRL_MODE=(0<<7),
|
||
DATA_MODE=(1<<7),
|
||
|
||
//
|
||
|
||
}fopt_e;
|
||
*/
|
||
//控制字,总两字节
|
||
//加密,低2位
|
||
#define CRY_NONE 0
|
||
#define CRY_AES 1
|
||
#define CRY_RSA 2
|
||
|
||
//压缩,次高2位
|
||
#define COMP_NONE (0<<2)
|
||
#define COMP_FAST_LZ (1<<2)//压缩率中等,demo约1/0.62,资源占用少
|
||
#define COMP_QUICK_LZ (2<<2)
|
||
#define COMP_LZMA (3<<2)//压缩率可能最高,样例报错还未定位,猜测是内存不足
|
||
|
||
//数据类型子类,随CTRL_MODE不同而不同,共3位8种
|
||
#define MODE_0 (0<<4)
|
||
#define MODE_1 (1<<4)
|
||
// 。。。
|
||
#define MODE_7 (7<<4)
|
||
|
||
//数据类型,最高位
|
||
#define CTRL_MODE (0<<7)
|
||
#define DATA_MODE (1<<7)
|
||
|
||
//#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[7] ;//唯一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 pack_File(const char *fin, rt_uint8_t flag, const rt_uint8_t (*dout)[200], rt_uint8_t *arrLen);
|
||
|
||
//rt_uint8_t packMsgs(MSG *cfg, rt_uint8_t *din, size_t len, rt_uint8_t w, rt_uint8_t (*dout)[500], rt_uint8_t *arrlen);
|
||
|
||
|
||
void pwTT_thread_entry(void *parameter);
|
||
|
||
#endif /* APPLICATIONS_TTMSG_TTMSG_H_ */
|