2023-05-11 03:33:47 +00:00
|
|
|
|
/*
|
|
|
|
|
* 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>
|
2023-05-23 06:59:35 +00:00
|
|
|
|
//#include <stdio.h>
|
|
|
|
|
//#include <stdlib.h>
|
2023-05-11 03:33:47 +00:00
|
|
|
|
|
2023-05-23 06:59:35 +00:00
|
|
|
|
//#include <stdint.h>
|
|
|
|
|
//#include <string.h>
|
|
|
|
|
//#include "posix/string.h"
|
2023-05-11 03:33:47 +00:00
|
|
|
|
#include <dfs_file.h>
|
2023-08-31 09:14:48 +00:00
|
|
|
|
#include <usrcfg.h>
|
2023-08-21 09:18:07 +00:00
|
|
|
|
#define FRAME_DATA_LEN_MAX (180-10-20)
|
2023-05-23 06:59:35 +00:00
|
|
|
|
#define STR_LEN_MAX 30
|
2023-05-11 03:33:47 +00:00
|
|
|
|
|
2023-05-23 06:59:35 +00:00
|
|
|
|
/*
|
2023-05-11 03:33:47 +00:00
|
|
|
|
typedef enum{
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//加密,低2位
|
|
|
|
|
CRY_NONE=0,
|
|
|
|
|
CRY_AES,
|
|
|
|
|
CRY_RSA,
|
|
|
|
|
|
|
|
|
|
//压缩,次高2位
|
|
|
|
|
COMP_NONE=(0<<2),
|
|
|
|
|
COMP_QUICK_LZ=(1<<2),//压缩率中等,demo约1/0.62,资源占用少
|
2023-05-18 00:58:26 +00:00
|
|
|
|
COMP_FAST_LZ=(2<<2),
|
|
|
|
|
COMP_LZMA=(3<<2),//压缩率可能最高,样例报错还未定位,猜测是内存不足
|
2023-05-11 03:33:47 +00:00
|
|
|
|
|
|
|
|
|
//数据类型子类,随CTRL_MODE不同而不同,共3位8种
|
|
|
|
|
MODE_0=(0<<4),
|
|
|
|
|
MODE_1=(1<<4),
|
2023-05-18 00:58:26 +00:00
|
|
|
|
// 。。。
|
|
|
|
|
MODE_7=(1<<4),
|
2023-05-11 03:33:47 +00:00
|
|
|
|
//数据类型,最高位
|
|
|
|
|
CTRL_MODE=(0<<7),
|
|
|
|
|
DATA_MODE=(1<<7),
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
}fopt_e;
|
2023-05-23 06:59:35 +00:00
|
|
|
|
*/
|
|
|
|
|
//控制字,总两字节
|
|
|
|
|
//加密,低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)
|
2023-05-11 03:33:47 +00:00
|
|
|
|
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] ;//
|
|
|
|
|
|
|
|
|
|
//自定义数据,格式如下
|
2023-05-18 00:58:26 +00:00
|
|
|
|
rt_uint8_t findex[7] ;//唯一ID号,索引号:年月日时分秒+1字节随机码 年取后两位(2023即23),随机码为防止RTC复位后时间错乱
|
2023-05-11 03:33:47 +00:00
|
|
|
|
rt_uint8_t fcfg[1] ;//数据类型 |压缩方式|加密方式
|
|
|
|
|
rt_uint8_t fcurpiece[1];//当前分片数
|
|
|
|
|
rt_uint8_t fallpiece[1];//总分片数
|
|
|
|
|
rt_uint8_t fdata[];//当前分片数据,为待发数据
|
|
|
|
|
|
|
|
|
|
}MSG;
|
2023-05-25 06:58:31 +00:00
|
|
|
|
rt_uint8_t pack_File(const char *fin, rt_uint8_t flag, const rt_uint8_t (*dout)[200], rt_uint8_t *arrLen);
|
2023-05-11 03:33:47 +00:00
|
|
|
|
|
2023-05-25 06:58:31 +00:00
|
|
|
|
//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);
|
2023-05-11 03:33:47 +00:00
|
|
|
|
|
|
|
|
|
|
2023-06-01 09:10:00 +00:00
|
|
|
|
void pwTT_thread_entry(void *parameter);
|
|
|
|
|
|
2023-05-11 03:33:47 +00:00
|
|
|
|
#endif /* APPLICATIONS_TTMSG_TTMSG_H_ */
|