更新参数配置和更新功能

更新isInFence()
更新TT发送逻辑(待完善)
This commit is contained in:
CSSC-WORK\murmur 2023-08-01 16:27:21 +08:00
parent 7d06ab7e7b
commit 114c8ee82c
9 changed files with 324 additions and 170 deletions

View File

@ -20,8 +20,8 @@
#include <usrcfg.h>
#include <ttTR.h>
static struct rt_event sw_check; //软件条件
static struct rt_event hw_check; //硬件条件
//static struct rt_event sw_check; //软件条件
static struct rt_event chkSta; //发送条件含两部分1-超时或文件准备好2-TT满足通信条件
#define ALL_READY 1
@ -36,10 +36,10 @@ rt_sem_t cfgUpdate = RT_NULL;
rt_sem_t shuntDownTT = RT_NULL;
void TTisReady(void)
{
rt_sem_release(TTReady);
}
//void TTisReady(void)
//{
// rt_sem_release(TTReady);
//}
SYS_CFG scfg={
.sendInterval =60,
@ -79,7 +79,7 @@ static void updatecfg(void)
void sysSemInit()
{
TTReady = rt_sem_create("TTisReady", 0, RT_IPC_FLAG_PRIO);
// TTReady = rt_sem_create("TTisReady", 0, RT_IPC_FLAG_PRIO);
cfgUpdate = rt_sem_create("cfgUpdate", 0, RT_IPC_FLAG_PRIO);
shuntDownTT = rt_sem_create("shuntDNTT", 0, RT_IPC_FLAG_PRIO);
rt_sem_release(cfgUpdate); //上电更新值
@ -95,34 +95,38 @@ void sysSemInit()
static void initEvent(void)
static void sysEventInit(void)
{
/* 事 件 控 制 块 */
rt_err_t result = rt_event_init(&sw_check, "SHcheck", RT_IPC_FLAG_PRIO);
result = rt_event_init(&hw_check, "HWcheck", RT_IPC_FLAG_PRIO) | result;
rt_err_t result = rt_event_init(&chkSta, "chkSta", RT_IPC_FLAG_PRIO);
if (result != RT_EOK)
{
LOG_E("init event failed.\n");
}
}
INIT_COMPONENT_EXPORT(initEvent);
void upSWflag(void)
void sysInit(void)
{
rt_event_send(&sw_check, FILE_IS_OK);
sysSemInit();
sysEventInit();
}
void upTTflag(void)
//INIT_COMPONENT_EXPORT(sysInit);
void timerIsReady(void)
{
rt_event_send(&sw_check, TT_IS_OK);
rt_event_send(&sysInit, TIMER_IS_OUT);
}
void d_upSWflag()
void fileIsReady(void)
{
// extern struct rt_event sw_check;//软件条件
// rt_event_send(&sw_check, FILE_IS_OK);
// void upSWflag(void);
upSWflag();
rt_event_send(&sysInit, FILE_IS_OK);
}
void TTIsReady(void)
{
rt_event_send(&sysInit, TT_IS_OK);
}
void d_upSta()
{
TTIsReady();
}
@ -136,46 +140,52 @@ void checkTT()
repGetTT(); //持续更新
}
static void upSendFile_thread_entry(void)
typedef struct
{
//等待事件
extern struct rt_event hw_check; //硬件条件
char fname[60];
uint8_t index;
}FILE_INFO;
static void upSendFile_thread_entry(void *parameter)
{
FILE_INFO *f = RT_NULL;
f = (FILE_INFO *) parameter;
static rt_uint8_t d[10][200] = { };
static rt_uint8_t s[10] = { };
LOG_D("%s---%d",f->fname,f->index);
rt_uint8_t len = pack_File(f->fname, 0, d, s);
while (1)
if (len)
{
if (rt_event_recv(&hw_check, ALL_READY, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
RT_WAITING_FOREVER, RT_NULL) == RT_EOK)
LOG_D("%d pack(s) to send", f->index ? 1 : len);
for (size_t var = 0; var < len; var++)
{
//get file to be send
char *f = "2023_06_16_10_28_00_123.bin";
// char *f="1023_05_19_15_29_59_254.txt";
// pack file
rt_uint8_t len = 0;
len = pack_File(f, 0, d, s);
rt_kprintf("len is %d\n", len);
if (len)
{
for (size_t var = 0; var < len; var++)
{
sendMsg(d[var], s[var]);
}
tcpClose();
LOG_I("Done.");
if (!f->index || (var+1) == f->index)
{ //index=0 全发或者仅发index
sendMsg(d[var], s[var]);
LOG_D("send pack[%d] done.",var+1);
}
}
LOG_I("Done.");
}
}
//MSH_CMD_EXPORT(getFileData_thread_entry,tet);
static void upSendFile(void)
/**
*
* @param f
* @param index 0
*/
void upSendFile(const char *f, int index)
{
static FILE_INFO info;
memset(&info, 0, sizeof(FILE_INFO));
strcpy(info.fname, f);
info.index = index;
/* 创建 serial 线程 */
rt_thread_t thread = rt_thread_create("upSendFile", upSendFile_thread_entry, RT_NULL, 1024 * 12, 27, 10);
rt_thread_t thread = rt_thread_create("upSendFile", upSendFile_thread_entry, (void *) &info, 1024 * 12, 27, 10);
/* 创建成功则启动线程 */
if (thread != RT_NULL)
{
@ -187,53 +197,67 @@ static void upSendFile(void)
return;
}
}
void d_upSendFile(int argc, char **argv)
{
int index=0;
if (argc == 3) {
index = atoi(argv[2]);
}
upSendFile(argv[1], index);
}
/**
*
*/
void getAndSendFile()
{
int index[MAX_KEY_LEN];
char f[30][MAX_KEY_LEN];
size_t cnt = getFilesToSend(f, index);
LOG_I("%d files to be send");
for (size_t i = cnt-1; i > 0; i--)
{
upSendFile(f[i],index[i]);
}
}
static void chkAndSendFile_thread_entry()
{
static rt_err_t rst = RT_ERROR;
updatecfg();
static rt_uint8_t d[10][200] = { };
static rt_uint8_t s[10] = { };
while (1)
{
// int e;
LOG_I("等待软件就绪");
rst = rt_event_recv(&sw_check, FILE_IS_OK | TIMER_IS_OUT, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
LOG_I("等待文件就绪(或定时%d分钟超时",scfg.sendInterval);
int rst = rt_event_recv(&chkSta, FILE_IS_OK | TIMER_IS_OUT, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
RT_WAITING_FOREVER, RT_NULL);
if (rst == RT_EOK) //软件条件满足
if (rst == RT_EOK) //条件1满足
{
//检查硬件条件
LOG_I("软件就绪开始等待TT");
// continue;
checkTT();
//打包数据
LOG_I("等待TT就绪");
}
for (size_t var = 0; var < maxTTRetryCnt; var++) //轮询尝试
for (size_t var = 0; var < scfg.maxTTRetryCnt; var++) //轮询尝试
{
LOG_I("第%d次尝试。", var + 1);
// rst = rt_event_recv(&sw_check, TT_IS_OK, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, maxTTWaitTime*60*1000,
// RT_NULL);
rst = rt_sem_take(TTReady, rt_tick_from_millisecond(maxTTWaitTime * 60 * 1000));
if (rst == RT_EOK) //硬件条件满足
LOG_I("第%d/%d次尝试。", var + 1,scfg.maxTTRetryCnt);
rst = rt_event_recv(&chkSta, TT_IS_OK, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, rt_tick_from_millisecond(scfg.maxTTWaitTime*60*1000),
RT_NULL);
// rst = rt_sem_take(TTReady, rt_tick_from_millisecond(maxTTWaitTime * 60 * 1000));
if (rst == RT_EOK) //条件2满足
{
LOG_I("TT准备就绪");
rt_event_send(&hw_check, ALL_READY);
getAndSendFile();
break;
}
else if (rst == -RT_ETIMEOUT)
; //超时则重试
else if (rst == -RT_ETIMEOUT)//超时则重试
{
LOG_W("第%d次尝试中TT准备失败。", var + 1);
// pwTT_thread_entry("0");
rt_thread_mdelay(1000);
checkTT();
// checkTT();
// continue;
}
}
//continue;
//发送数据
//可能有多个待发文件,每个文件打包后为一个二维数组
@ -241,13 +265,15 @@ static void chkAndSendFile_thread_entry()
//故改为“打包-发送”轮询操作
// upSendFile();
LOG_I("----------------------------");
// LOG_I("----------------------------");
}
}
/**
*
*/
void chkAndSendFile()
{
/* 创建 serial 线程 */
@ -306,7 +332,7 @@ void d_getRemain()
arg2=rt_timer_control(tmrToPNTT, RT_TIMER_CTRL_GET_REMAIN_TIME, (void*)arg2);
LOG_D("tm=%d-%d",&arg1,&arg2);
}
static int toPN=0;
/* 定时器超时函数 */
static void timeoutFunc(void *parameter)
{
@ -446,10 +472,11 @@ void deInitTT()
#define FUNC_DEMO
#ifdef FUNC_DEMO //测试时导出命令到控制台
MSH_CMD_EXPORT(d_upSWflag,FILE_IS_OK);
MSH_CMD_EXPORT(d_upSta,FILE_IS_OK);
MSH_CMD_EXPORT(chkAndSendFile, chkAndSendFile);
MSH_CMD_EXPORT(upSendFile, upSendFile);
MSH_CMD_EXPORT(initTT,TT);
MSH_CMD_EXPORT(deInitTT,TT);
MSH_CMD_EXPORT(d_getRemain,d_getRemain);
MSH_CMD_EXPORT(d_upSendFile,d_upSendFile);
#endif

View File

@ -39,7 +39,7 @@ extern rt_sem_t cfgUpdate;
static struct rt_messagequeue upfilelist;
typedef struct
{
char msg[60];
char fname[60];
uint8_t index;
}FILE_INFO;
static uint8_t msg_pool[512] ;
@ -282,7 +282,7 @@ int setFileToSend(const char *f, int v)
int rst = ini_putl(SECTION_TO_SEND, f, v, FILE_TO_SEND);
if (!rst) {
LOG_E("add file to send error.");
clearLock();
nclearLock();
return RT_ERROR;
}
nclearLock();
@ -290,9 +290,9 @@ int setFileToSend(const char *f, int v)
}
/**
*
* @param kstr
* @param v 0
* @return
* @param kstr
* @param v 0
* @return
*/
int getFilesToSend(char (*kstr)[MAX_KEY_LEN], int *v)
{
@ -325,9 +325,9 @@ int clearFileToSend(const char *k)
static void gf()
{
int v[MAX_KEY_LEN];
char kstr[10][MAX_KEY_LEN];
char kstr[30][MAX_KEY_LEN];
size_t cnt = getFilesToSend(kstr, v);
for (size_t var = 0; var < cnt; ++var)
for (size_t var = 0; var < cnt; var++)
{
LOG_I("%s -- %d", kstr[var], v[var]);
}
@ -348,8 +348,8 @@ void addToList_thread_entry(void *parameter)
{
rt_memset(&msg, 0, sizeof(msg));
if (rt_mq_recv(&upfilelist, &msg, sizeof(msg), RT_WAITING_FOREVER) == RT_EOK) {
LOG_D("get %s",msg.msg);
setFileToSend(msg.msg,msg.index);
LOG_D("get %s",msg.fname);
setFileToSend(msg.fname,msg.index);
}
}
}
@ -358,7 +358,7 @@ void postFileInfo(const char *fin, uint8_t index)
{
// setFileToSend(fin,0);
FILE_INFO msg;
strcpy(msg.msg,fin);
strcpy(msg.fname,fin);
msg.index=index;
rt_mq_send(&upfilelist, &msg, sizeof(msg));
}

View File

@ -28,6 +28,11 @@
#define SECTION_TO_SEND "tosend"
#define SECTION_LST_FILE "lstfile"
//typedef struct
//{
// char fname[60];
// uint8_t index;
//}FILE_INFO;
int get_cfg(const char *k);
int set_cfg(const char *k, const char*v);

View File

@ -1,9 +1,9 @@
[config]
# V1.8
# V1.81
#发送间隔M以零点为基准时刻
sendInterval=60
# 最大文件大小,超过此大小则进入发送流程
maxSizePerFile=4096
maxSizePerFile=1024
# 最小等待时间S超时后进入待机模式
minSecToSleep=30
# TT最长等待激活时间M超时后重启
@ -15,13 +15,20 @@ minTTsinal=5
# TT状态检测周期数
minTTPeriCnt=2
compressType=1
# 加密方式0-不加密
encrytType=1
# 开窗时间UTC+8,持续时间H支持多组,组与组之间采用【;】为分隔符
# 开窗时间UTC+8,持续时间H以【,】为分隔符
openWindowTime=1,2,7,8
#超时定时器时间M超时后关闭TT
#超时时间M,主动开机上报数据情况下最后一次通信后开始计时超时后关闭TT
timeout=5
# 工作模式1-TT2-BD
commMode=1
# 自毁功能开关1-开启0-跟关闭
selfDesSW=0
# 位置告警功能开关1-开启0-关闭
locAlert=1;
# 定时上报位置信息间隔M
locReportInterval=5
[stats]
# 继电器开关次数影响继电器寿命10W次
swCnt=12

View File

@ -15,6 +15,8 @@
#define LOG_LVL LOG_LVL_DBG
#include <ulog.h>
extern SYS_CFG scfg;
/**
* ASCII字符形式存入log
* @param din
@ -206,31 +208,7 @@ void upSend_thread_entry(void* parameter)
RT_WEAK int upSend(uint8_t *din, size_t len)
{
LOG_D("try to upsend to TT.");
//
// uint8_t sta = 1;
// while (1 && !isTTjh()) //判断TT状态
// {
// static uint8_t trycnt = 0;
// rt_thread_mdelay(4000);
// trycnt += 1;
// if (trycnt > 3)
// {
// sta = 0; //try 3 time
// break;
// }
// }
// if (!sta) {
// //cache to file
// LOG_W("TT is not ready, try to cache %d bytes data to file.",len);
// cacheDataToFile(din, len);
//// trDataTolog(din, len, 1);
// return -RT_ERROR;
// }
//
// //此函数有打包操作,需线程操作
//// LOG_D("upsend.");
// return 0;
//
static SMSG msg;
memset(&msg, 0, sizeof(SMSG));
memcpy(msg.data,din,len);
@ -423,7 +401,7 @@ static int getAndCheckLoc(uint8_t *dout, size_t pairCnt)
memcpy(dout,loc,cnt);
return cnt;
}
int cryptLocMsg(uint8_t *din, size_t len, uint8_t *dout);
static int cryptLocMsg(uint8_t *din, size_t len, uint8_t *dout);
/**
* c回应深度数据
* @param din
@ -448,15 +426,58 @@ int reportDepth(uint8_t *din,size_t len)
upSend(dout, nlen);
}
//天通指令类型0x70 0x01
/**
*
* @param cfg
* @param len
*/
void updateSysCfg(uint8_t *cfg, size_t len)
{
LOG_I("FUNC = update SYSCFG");
// SYS_CFG ts;
memcpy(&scfg,cfg,len);
// LOG_D("--%d",ts.maxSizePerFile);
// scfg = (SYS_CFG)tmp;
}
/**
*
*/
void reportSysCfg()
{
LOG_I("FUNC = report SYSCFG");
// scfg.commMode=0xab;
// scfg.timeout=0x37;
// scfg.maxSizePerFile=2046;
uint8_t size = sizeof(scfg);
uint8_t rst[200] = { 0x5A, 0xA5, ADDR_ANJI, ADDR_TT, _CFG_UPDATE_CFG >> 8, _CFG_UPDATE_CFG & 0xff };
int p = 6;
rst[p++] = 0;
rst[p++] = size;
memcpy(rst + p,&scfg, size);
p+=size;
rst[p] = bccCRC(rst + 2, p-2);
rst[++p] = 0xED;
size = p+1;
upSend(rst, size);
// LOG_HEX("scfg",16,&scfg,size);
LOG_HEX("cfg",16,rst,p+1);
// updateSysCfg(rst, p+1);;
}
//3.2.8定时自报位置信息
//每小时传数据时同步传位置信息
//与告警信息共用编码方式
//首字节00为定时发送未检测围栏其它为在围栏外
//首字节为是否越界默认为00此处为预留。
//单次最多可上报15条位置信息
/**
* 15
* 15[]+[]+[15]
*
* 15MOB(most oldest bit)
* @param dout
* @return
*/
@ -468,7 +489,7 @@ static int packLocMsg(uint8_t *dout)
alertMsg[8] = 0; //首字节00为定时发送未检测围栏其它为在围栏外
int len = time2Byte(alertMsg+9);//添加时间戳
len += (getAndCheckLoc(alertMsg + 9 + len, 15)+1); //p指向第2个数据
len += getAndCheckLoc(alertMsg + 9 + len, 15) + 1; //p指向第2个数据
alertMsg[7] = len; //update len of raw data
alertMsg[8 + len] = bccCRC(alertMsg + 2, 8 + len - 2); //update CRC
@ -492,7 +513,7 @@ static void d_packLocMsg(void)
* @param dout
* @return
*/
int cryptLocMsg(uint8_t *din, size_t len, uint8_t *dout)
static int cryptLocMsg(uint8_t *din, size_t len, uint8_t *dout)
{ //加密。因加密后数据长度会变化,故不能只加密位置数据。
uint8_t cd[200]={0xAB,0xAB};
size_t nlen = 0;
@ -508,14 +529,109 @@ int cryptLocMsg(uint8_t *din, size_t len, uint8_t *dout)
return nlen;
}
int packAndSendLoc()
//static uint8_t locMsg[200];
//static rt_timer_t repLoc;
//static rt_sem_t isReadyToSendLoc;
int isInFence(uint8_t *loc);
/**
* 10s更新一次
* @return
*/
static void packAndChkLoc_thread_entry(void *parameter)
{
uint8_t rst[200];
int len = packLocMsg(rst);
LOG_D("len=%d",len);
len = cryptLocMsg(rst, len, rst);
LOG_D("len=%d",len);
LOG_HEX("crypt",16,rst,len);
while (isTCPok())
{
static size_t i = 0;
int isReadyToSendLoc=0;
uint8_t rst[200];
int len = packLocMsg(rst);
// LOG_D("len=%d", len);
len = cryptLocMsg(rst, len, rst);
// LOG_D("len=%d", len);
LOG_HEX("crypt", 16, rst, len);
//检测是否在围栏内
if (!isInFence(rst-9))//不在围栏内
{
rst[8]=1;
isReadyToSendLoc = 1;
}
rt_thread_mdelay(10000); //默认10s刷新一次
if (i++ > scfg.maxTTWaitTime * 60)//定时发送默认5分钟
{
i=0;
isReadyToSendLoc = 1;
}
if (isReadyToSendLoc) {
upSend(rst, len);
}
}
}
//创建定时任务默认时间5分钟采集发送
/**
*
*/
//static void upSendLoc_thread_entry(void *parameter)
//{
// while(1)
// {
// if (rt_sem_take(isReadyToSendLoc, RT_WAITING_FOREVER)) {
// uint8_t rst[200];
// size_t len = packAndChkLoc(rst);
// upSend(rst, len);
// }
// }
//}
//cb_upSendLoc()
//{
// if (isTCPok()) {
//// packAndSendLoc();
// rt_sem_release(isReadyToSendLoc);
// }
// else {
// rt_timer_delete(repLoc);
// }
//}
void initUpSendLoc()
{
// isReadyToSendLoc = rt_sem_create("SendLoc", 0, RT_IPC_FLAG_PRIO);
// repLoc = rt_timer_create("repLoc", cb_upSendLoc,
// RT_NULL, 10,
// RT_TIMER_FLAG_PERIODIC);
/* 创建 serial 线程 */
// rt_thread_t thread = rt_thread_create("sendLoc", upSendLoc_thread_entry, RT_NULL, 1024 * 1, 27, 10);
// /* 创建成功则启动线程 */
// if (thread != RT_NULL)
// {
// rt_thread_startup(thread);
// }
// else
// {
// LOG_E("thread 'sendLoc' create failure.");
// return;
// }
rt_thread_t thread = rt_thread_create("PCLoc", packAndChkLoc_thread_entry, RT_NULL, 1024 * 1, 27, 10);
/* 创建成功则启动线程 */
if (thread != RT_NULL)
{
rt_thread_startup(thread);
}
else
{
LOG_E("thread 'PCLoc' create failure.");
return;
}
}
@ -553,7 +669,7 @@ int depthAlert(uint8_t *din, int len)
* @param y
* @return truefalse
*/
static int isInFence(float x, float y)
static int isInPolgon(float x, float y)
{
float polyX[]={},polyY[]={};
int polyCorners = mapParse("/map.geojson",polyX,polyY);
@ -570,37 +686,27 @@ void setLocationAlertSWT(int setON)
}
/**
*
*
* @param loc 8
* @return 1-
*/
void checkLocAndAlert()
int isInFence(uint8_t *loc)
{
//get Lon and Lat
uint8_t loc[8];
getAndCheckLoc(loc,1);
float x,y =0;
memcpy(&x,loc,4);
memcpy(&y,loc+4,4);
int isIN = isInFence(x, y);
int isIN = isInPolgon(x, y);
if (isIN) {
LOG_I("设备在预设范围内,位置正常。");
// LOG_I("设备在预设范围内,位置正常。");
return 1;
}
else {
LOG_W("警告!设备不在预设范围内!");
uint8_t msg[200];
int len = packLocMsg(msg);
len = cryptLocMsg(msg,len,msg);
//告警信息与3.2.8定时自报位置信息的共用编码方式
// uint8_t alertMsg[]={0x5A,0xA5,ADDR_ANJI,ADDR_TT};
// alertMsg[4] = _CFG_LOCATION_ALERT >> 8;
// alertMsg[5] = _CFG_LOCATION_ALERT & 0xFF;
//
// //加密。
// uint8_t cd[200];
// size_t nlen = cryptByte(din, len, cd);
// upSend(alertMsg, sizeof(alertMsg));
return 0;
}
}
//创建定时任务默认时间10秒钟异常则发送
//3.2.12数据存储区清空
//
@ -648,7 +754,7 @@ void ttRunCMD(uint8_t *din, size_t len)
selfDestruct();
break;
case _CFG_COMM_WINDOW:
setCommWindow(din+8,din+7);//只支持两组开窗开窗时间为小时、分钟UTC+0
setCommWindow(din+8,din[7]);//只支持两组开窗开窗时间为小时、分钟UTC+0
break;
case _CMD_OPEN_WINDOW:
openWindow(din[7]?((din[8] << 8) + din[9]):0);//两字节开窗时间
@ -662,6 +768,13 @@ void ttRunCMD(uint8_t *din, size_t len)
case _CMD_CLEAR_DATA:
clearAllData();
break;
case _CFG_UPDATE_CFG:
if (din[7]) {//数据长度不为0则为覆写参数
updateSysCfg(din+8, din[7]);
}
else {//数据长度为0则为请求参数
reportSysCfg();
}
default:
LOG_W("0x%04X=未支持的指令。",cmd);
break;
@ -1089,10 +1202,11 @@ int isEthUP()
MSH_CMD_EXPORT(d_getFreeSpace,getFreeSpace);
MSH_CMD_EXPORT(selfTest,sysSelfTest);
MSH_CMD_EXPORT(d_packLocMsg,dpackLocMsg);
MSH_CMD_EXPORT(packAndSendLoc,packAndSendLoc);
MSH_CMD_EXPORT(initUpSendLoc,initUpSendLoc);
MSH_CMD_EXPORT(d_cacheData,d_cacheData);
MSH_CMD_EXPORT(d_getFileSize,d_getFileSize);
MSH_CMD_EXPORT(isEthUP,isEthUP);
MSH_CMD_EXPORT(reportSysCfg,reportSysCfg);
#endif

View File

@ -65,9 +65,9 @@ enum
#define _CMD_CLEAR_DATA 0x7005 // 执行清空数据
#define _CMD_RETRY_DATA 0x7006 //
#define _CMD_RETRY_DATA 0x7006 //数据重发
#define _CFG_UPDATE_CFG 0x7007
#define _CFG_UPDATE_CFG 0x7007 //更新、回传配置信息
//3S
#define _CMD_DEPTH_REQUEST 0x0601

View File

@ -199,9 +199,8 @@ static void rulecheck(void)
}
if (okCnt >= minTTPeriCnt) {
//TT具备发送条件
// rt_event_send(&sw_check, TT_IS_OK);
// upTTflag();
TTisReady();
// TTisReady();
TTIsReady();
LOG_I("符合规则TT具备发送状态。");
// updateSta();
okCnt = minTTPeriCnt -1;

View File

@ -270,15 +270,9 @@ static int tcpAck()
*/
int sendMsg(const rt_uint8_t *msg, size_t len)
{
// if (tcpInit() != RT_EOK)
// {
// return RT_ERROR;
// }
if (tcpSend(msg, len) != RT_EOK)
{
tcpClose();
// tcpClose();
return RT_ERROR;
}
//#define CHK_ACK
@ -290,9 +284,11 @@ int sendMsg(const rt_uint8_t *msg, size_t len)
};
#endif
//已发送数据存入log文件
char str[400];
bytes2str(msg, len, 16, " ", str);
trDataTolog(str, strlen(str), 1);
return RT_EOK;
}

View File

@ -29,15 +29,21 @@ typedef struct
typedef struct
{
int sendInterval;
int maxTTWaitTime;
int maxTTRetryCnt;
int minTTPeriCnt;
int minTTsinal;
int minActiveTime;
int maxActiveTime;
int timeout;
int maxSizePerFile;
uint8_t sendInterval;
uint8_t maxTTWaitTime;
uint8_t maxTTRetryCnt;
uint8_t minTTPeriCnt;
uint8_t minTTsinal;
uint8_t minActiveTime;
uint8_t maxActiveTime;
uint8_t timeout;
uint8_t openWindowTime[4];
uint16_t maxSizePerFile;
uint8_t commMode;
uint8_t selfDesSW;
uint8_t locAlert;
uint8_t locReportInterval;
} SYS_CFG;
//struct rt_event sw_check;//软件条件