feat(duch): Cat1 DUCH模式环形缓冲区+AT+QISEND明文输出
- Cat1仅DUCH时走独立环形缓冲区(8192B),Debug_Printf按\r\n分行写入 - DUCH_MODE逐段AT+QISEND=0,n raw模式发送,\x1A结尾,500ms间隔 - 长日志(para/help)全量明文到达,无丢包 - Cat1DuchReady标志+Cat1DuchSend外部接口 - rt_hw_console_output CH_CAT1保持DebugOrCat1UartSend(未变)
This commit is contained in:
@@ -1078,7 +1078,7 @@
|
|||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>::RTOS</GroupName>
|
<GroupName>::RTOS</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>1</RteFlg>
|
<RteFlg>1</RteFlg>
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ void rt_hw_console_output(const char *str)
|
|||||||
case CH_RS485_2: RS485Ch2UartSend((uint8_t *)str, strlen(str)); break;
|
case CH_RS485_2: RS485Ch2UartSend((uint8_t *)str, strlen(str)); break;
|
||||||
case CH_ETH: EthUartSend((uint8_t *)str, strlen(str)); break;
|
case CH_ETH: EthUartSend((uint8_t *)str, strlen(str)); break;
|
||||||
case CH_LORA: Sx1276LoRaSendBuffer((uint8_t *)str, strlen(str)); break;
|
case CH_LORA: Sx1276LoRaSendBuffer((uint8_t *)str, strlen(str)); break;
|
||||||
case CH_DBG:
|
case CH_CAT1: DebugOrCat1UartSend((uint8_t *)str, strlen(str)); break;
|
||||||
case CH_CAT1:
|
case CH_DBG: DebugOrCat1UartSend((uint8_t *)str, strlen(str)); break;
|
||||||
default: DebugOrCat1UartSend((uint8_t *)str, strlen(str)); break;
|
default: DebugOrCat1UartSend((uint8_t *)str, strlen(str)); break;
|
||||||
}
|
}
|
||||||
rt_exit_critical();
|
rt_exit_critical();
|
||||||
|
|||||||
@@ -42,7 +42,21 @@ void Debug_Printf(char *format, ...)
|
|||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vsprintf(&tempBuff[0], format, args);
|
vsprintf(&tempBuff[0], format, args);
|
||||||
rt_hw_console_output(tempBuff);
|
if(GateWay && GateWay->ConfigPara.Duch == CH_CAT1
|
||||||
|
&& GateWay->ConfigPara.Much != CH_CAT1
|
||||||
|
&& GateWay->ConfigPara.Auch != CH_CAT1
|
||||||
|
&& !(GateWay->ConfigPara.CuchMask & CUCH_CAT1)) {
|
||||||
|
char *line = tempBuff;
|
||||||
|
while(line && *line) {
|
||||||
|
char *end = strstr(line, "\r\n");
|
||||||
|
uint16_t n = end ? (uint16_t)(end - line + 2) : (uint16_t)strlen(line);
|
||||||
|
if(n > 240) n = 240;
|
||||||
|
if(n > 0) Cat1DuchSend(line, n);
|
||||||
|
line = end ? end + 2 : NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rt_kprintf(tempBuff);
|
||||||
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ typedef enum {
|
|||||||
CAT_ONE_RESET,
|
CAT_ONE_RESET,
|
||||||
CAT_ONE_OFF,
|
CAT_ONE_OFF,
|
||||||
CAT_ONE_CLOSE_TCP,
|
CAT_ONE_CLOSE_TCP,
|
||||||
|
CAT_ONE_DUCH_MODE,
|
||||||
}CatOneStatus_m;
|
}CatOneStatus_m;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -96,4 +97,5 @@ void CatOne_Thread_Entry(void *parameter);
|
|||||||
void Cat1IrqCallback(uint8_t rData);
|
void Cat1IrqCallback(uint8_t rData);
|
||||||
void Cat1OverHandler(void);
|
void Cat1OverHandler(void);
|
||||||
void CatReadImeiOrSim(char *Imei, char *Sim);
|
void CatReadImeiOrSim(char *Imei, char *Sim);
|
||||||
|
void Cat1DuchSend(const char *text, uint16_t len);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -21,6 +21,24 @@ static char CommUnitSendASCII[CAT_ONE_REV_LEN_MAX * 2];
|
|||||||
static uint8_t Cat1RevTimeOutCnt;
|
static uint8_t Cat1RevTimeOutCnt;
|
||||||
static uint16_t CatSendErrCnt = 0;
|
static uint16_t CatSendErrCnt = 0;
|
||||||
|
|
||||||
|
bool Cat1DuchReady = false;
|
||||||
|
static char duchRing[8192];
|
||||||
|
static uint16_t duchWr, duchRd;
|
||||||
|
|
||||||
|
void Cat1DuchSend(const char *text, uint16_t len)
|
||||||
|
{
|
||||||
|
if(len == 0 || len > 240) return;
|
||||||
|
if(duchWr + len <= 8192) {
|
||||||
|
memcpy(&duchRing[duchWr], text, len);
|
||||||
|
duchWr += len;
|
||||||
|
} else {
|
||||||
|
uint16_t part = 8192 - duchWr;
|
||||||
|
memcpy(&duchRing[duchWr], text, part);
|
||||||
|
memcpy(duchRing, text + part, len - part);
|
||||||
|
duchWr = len - part;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define CAT1_DBG_LOG(...) { if(CAT1DispEn) Debug_Printf(__VA_ARGS__);}
|
#define CAT1_DBG_LOG(...) { if(CAT1DispEn) Debug_Printf(__VA_ARGS__);}
|
||||||
|
|
||||||
#define CATONE_RESET_DELAY_TIME_MAX (5 * 60 * 1000)
|
#define CATONE_RESET_DELAY_TIME_MAX (5 * 60 * 1000)
|
||||||
@@ -434,13 +452,16 @@ void CatOneLoopHandler(void)
|
|||||||
|
|
||||||
case CAT_ONE_WAIT_CONN:
|
case CAT_ONE_WAIT_CONN:
|
||||||
if(CatOne.TcpConnFlag) {
|
if(CatOne.TcpConnFlag) {
|
||||||
if(CatOne.GateWay->ConfigPara.Much != CH_CAT1) {
|
if(CatOne.GateWay->ConfigPara.Much == CH_CAT1) {
|
||||||
|
CatOne.Cat1Status = CAT_ONE_REG_SVR;
|
||||||
|
}
|
||||||
|
else if(CatOne.GateWay->ConfigPara.Auch == CH_CAT1 || (CatOne.GateWay->ConfigPara.CuchMask & CUCH_CAT1)) {
|
||||||
GateWayRegister(Payload);
|
GateWayRegister(Payload);
|
||||||
CatOneTxLen = NetCommOrgData(CatOne.GateWay, Payload, CatOneTxBuff);
|
CatOneTxLen = NetCommOrgData(CatOne.GateWay, Payload, CatOneTxBuff);
|
||||||
CatOne.Cat1Status = CAT_ONE_SEND_DATA;
|
CatOne.Cat1Status = CAT_ONE_SEND_DATA;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CatOne.Cat1Status = CAT_ONE_REG_SVR;
|
CatOne.Cat1Status = CAT_ONE_DUCH_MODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -515,6 +536,33 @@ void CatOneLoopHandler(void)
|
|||||||
CatOneAtCmdSend(CAT_ONE_LTPCLOSE, 1000, CAT_ONE_OFF);
|
CatOneAtCmdSend(CAT_ONE_LTPCLOSE, 1000, CAT_ONE_OFF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CAT_ONE_DUCH_MODE:
|
||||||
|
Cat1DuchReady = true;
|
||||||
|
while(ChannelIsActive(CatOne.GateWay->ConfigPara, CH_CAT1)) {
|
||||||
|
if(duchRd != duchWr) {
|
||||||
|
uint16_t avail = (duchWr - duchRd) & 0x1FFF;
|
||||||
|
uint16_t n = avail > 240 ? 240 : avail;
|
||||||
|
sprintf(CatOne.CatOneSendBuff, "AT+QISEND=0,%d\r\n", n);
|
||||||
|
DebugOrCat1UartSend((uint8_t *)CatOne.CatOneSendBuff, strlen(CatOne.CatOneSendBuff));
|
||||||
|
rt_thread_delay(200);
|
||||||
|
if(duchRd + n <= 8192) {
|
||||||
|
DebugOrCat1UartSend((uint8_t *)&duchRing[duchRd], n);
|
||||||
|
} else {
|
||||||
|
uint16_t part = 8192 - duchRd;
|
||||||
|
DebugOrCat1UartSend((uint8_t *)&duchRing[duchRd], part);
|
||||||
|
DebugOrCat1UartSend((uint8_t *)duchRing, n - part);
|
||||||
|
}
|
||||||
|
DebugOrCat1UartSend((uint8_t *)"\x1A", 1);
|
||||||
|
rt_thread_delay(500);
|
||||||
|
duchRd = (duchRd + n) & 0x1FFF;
|
||||||
|
} else {
|
||||||
|
rt_thread_delay(50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Cat1DuchReady = false;
|
||||||
|
CatOne.Cat1Status = CAT_ONE_IDEL;
|
||||||
|
break;
|
||||||
|
|
||||||
case CAT_ONE_OFF:
|
case CAT_ONE_OFF:
|
||||||
CAT1_RESET_SET();
|
CAT1_RESET_SET();
|
||||||
CAT1_PWR_KEY_CLR();
|
CAT1_PWR_KEY_CLR();
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ void GateWayInit(void)
|
|||||||
if(GateWay.ConfigPara.SavFlag != LOG_SAV_FLAG) {
|
if(GateWay.ConfigPara.SavFlag != LOG_SAV_FLAG) {
|
||||||
memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t));
|
memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t));
|
||||||
GateWay.ConfigPara.SavFlag = LOG_SAV_FLAG;
|
GateWay.ConfigPara.SavFlag = LOG_SAV_FLAG;
|
||||||
GateWay.ConfigPara.Much = CH_CAT1;
|
GateWay.ConfigPara.Much = CH_ETH;
|
||||||
GateWay.ConfigPara.Auch = CH_NULL;
|
GateWay.ConfigPara.Auch = CH_NULL;
|
||||||
GateWay.ConfigPara.Duch = CH_ETH;
|
GateWay.ConfigPara.Duch = CH_CAT1;
|
||||||
GateWay.ConfigPara.CuchMask = CUCH_LORA;
|
GateWay.ConfigPara.CuchMask = CUCH_LORA;
|
||||||
#if MAC_ADDR_TYPE == 0//测试服务器
|
#if MAC_ADDR_TYPE == 0//测试服务器
|
||||||
GateWay.ConfigPara.LTENet.DestAddr[0] = 39;
|
GateWay.ConfigPara.LTENet.DestAddr[0] = 39;
|
||||||
|
|||||||
Reference in New Issue
Block a user