Browse Source

v2.0.2 优化gm35连接

pingche_yh2
zhangsan 4 years ago
parent
commit
be132271df
  1. BIN
      si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym
  2. BIN
      si4/soft_gsm_main.si4project/soft_gsm_main.siwork
  3. 41
      source/app/app_task_gm35.c
  4. 2
      source/app/app_task_gm35.h
  5. 6
      source/app/app_task_tcp.c
  6. 2
      source/app/app_task_tcp_control.c
  7. 8
      source/clib/clib.c
  8. 2
      source/clib/clib.h
  9. 5
      source/msp/UART0.C
  10. 8
      source/msp/UART4.C

BIN
si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym

Binary file not shown.

BIN
si4/soft_gsm_main.si4project/soft_gsm_main.siwork

Binary file not shown.

41
source/app/app_task_gm35.c

@ -31,9 +31,6 @@ struct _s_task_gm35_gprs_ s_task_gm35_daemon;
U8 ins_cipsend[30] = "AT+CIPSEND=000\r\n"; U8 ins_cipsend[30] = "AT+CIPSEND=000\r\n";
#define GM35_TCP_CIPSEND(x) L0_uart4_sendstr(x); g_at_send_status.send_lock = 1
#define GM35_TCP_CIPSEND_COMPLETE() g_at_send_status.send_lock = 0
U8 * _cipsend_hex(U8 len) U8 * _cipsend_hex(U8 len)
{ {
U8 pos = libc_strlen("AT+CIPSEND="); U8 pos = libc_strlen("AT+CIPSEND=");
@ -44,18 +41,19 @@ U8 * _cipsend_hex(U8 len)
return ins_cipsend; return ins_cipsend;
} }
void L3_gm35_send_str(U8 *str)
{
L0_uart4_sendstr(str);
L0_uart0_sendstr(str);
}
//将数据放入gm35待发送缓冲区 //将数据放入gm35待发送缓冲区
void L3_gm35_send(U8 *buf , U8 len) void L3_gm35_send_data(U8 *buf , U8 len)
{ {
//g_at_send_status.tcp_last_send_stmp = s_nos_tick.t_1s; L3_gm35_send_str(_cipsend_hex(len));
int i = 0x20000;
GM35_TCP_CIPSEND(_cipsend_hex(len));
while(i--);
L0_uart4_sendArray(buf,len); L0_uart4_sendArray(buf,len);
GM35_TCP_CIPSEND_COMPLETE(); L0_uart0_sendArray(buf,len);
} }
//------------------------------------------------------ gm35 tasks -------------------------------- //------------------------------------------------------ gm35 tasks --------------------------------
// void L3_task_gm35_send_init(void) // void L3_task_gm35_send_init(void)
@ -92,6 +90,8 @@ void L3_task_gm35_daemon_init(void)
{ {
L1_task_init(&s_task_gm35_daemon.task); L1_task_init(&s_task_gm35_daemon.task);
L3_task_s_go(s_task_gm35_daemon,D_task_init); L3_task_s_go(s_task_gm35_daemon,D_task_init);
P55 = 1; //灯灭
} }
//------------------------ GM35 Daemon Handle ----------------------------------- //------------------------ GM35 Daemon Handle -----------------------------------
@ -114,15 +114,13 @@ void L2_task_gm35_daemon_handle(struct _s_task_gm35_gprs_ *s)
L2_task_go_Tdelay(TTSS_TASK_GM35_DAEMON_CIPSTATUS,D_Tdelay_10s); L2_task_go_Tdelay(TTSS_TASK_GM35_DAEMON_CIPSTATUS,D_Tdelay_10s);
TTSS_Task_step(TTSS_TASK_GM35_DAEMON_CIPSTATUS) TTSS_Task_step(TTSS_TASK_GM35_DAEMON_CIPSTATUS)
//if(0 == g_at_send_status.send_lock) L3_gm35_send_str(AT_INS_CIPSTATUS);
//{
L0_uart4_sendstr(AT_INS_CIPSTATUS);
L2_task_go_Tdelay(TTSS_TASK_GM35_DAEMON_JUDGE,D_Tdelay_2s); L2_task_go_Tdelay(TTSS_TASK_GM35_DAEMON_JUDGE,D_Tdelay_2s);
//}
TTSS_Task_step(TTSS_TASK_GM35_DAEMON_JUDGE) TTSS_Task_step(TTSS_TASK_GM35_DAEMON_JUDGE)
if(1 == g_at_send_status.conn_ok) //已连接 if(1 == g_at_send_status.conn_ok) //已连接
{ {
P55 = 0; //灯亮
if(s_nos_tick.t_1s - g_at_send_status.gprs_last_recv_stmp > GPRS_MAX_IDLE) //连续GPRS_MAX_IDLE秒没有收到 AT指令 if(s_nos_tick.t_1s - g_at_send_status.gprs_last_recv_stmp > GPRS_MAX_IDLE) //连续GPRS_MAX_IDLE秒没有收到 AT指令
{ {
//关闭连接 //关闭连接
@ -132,11 +130,12 @@ void L2_task_gm35_daemon_handle(struct _s_task_gm35_gprs_ *s)
{ {
//关闭连接 //关闭连接
g_at_send_status.conn_ok = 0; g_at_send_status.conn_ok = 0;
L0_uart4_sendstr(AT_INS_CLOSED); L3_gm35_send_str(AT_INS_CLOSED);
} }
} }
else //未连接 else //未连接
{ {
P55 = 1; //灯灭
if(s_nos_tick.t_1s - g_at_send_status.tcp_close_stmp > TCP_MAX_DISCONN) if(s_nos_tick.t_1s - g_at_send_status.tcp_close_stmp > TCP_MAX_DISCONN)
{ {
if(++g_at_send_status.gm35_reboot_times >= TCP_MAX_GM35_REBOOT_TIMES) if(++g_at_send_status.gm35_reboot_times >= TCP_MAX_GM35_REBOOT_TIMES)
@ -182,7 +181,7 @@ void L2_task_gm35_flow_handle(struct _s_task_gm35_gprs_ *s)
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ATEQV,D_Tdelay_10s);//上电等待10s L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ATEQV,D_Tdelay_10s);//上电等待10s
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ATEQV) TTSS_Task_step(TTSS_TASK_GM35_FLOW_ATEQV)
L0_uart4_sendstr(AT_INS_ATEQV); L3_gm35_send_str(AT_INS_ATEQV);
g_at_send_status.module_ok = 0; g_at_send_status.module_ok = 0;
g_at_send_status.ins_stmp = s_nos_tick.t_1s; g_at_send_status.ins_stmp = s_nos_tick.t_1s;
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ATEQV_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ATEQV_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms
@ -206,7 +205,7 @@ void L2_task_gm35_flow_handle(struct _s_task_gm35_gprs_ *s)
} }
TTSS_Task_step(TTSS_TASK_GM35_FLOW_CCID) TTSS_Task_step(TTSS_TASK_GM35_FLOW_CCID)
L0_uart4_sendstr(AT_INS_CCID); L3_gm35_send_str(AT_INS_CCID);
g_at_send_status.sim_ok = 0; g_at_send_status.sim_ok = 0;
g_at_send_status.ins_stmp = s_nos_tick.t_1s; g_at_send_status.ins_stmp = s_nos_tick.t_1s;
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_CCID_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_CCID_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms
@ -238,7 +237,7 @@ void L2_task_gm35_flow_handle(struct _s_task_gm35_gprs_ *s)
} }
TTSS_Task_step(TTSS_TASK_GM35_FLOW_CREG) TTSS_Task_step(TTSS_TASK_GM35_FLOW_CREG)
L0_uart4_sendstr(AT_INS_CREG); L3_gm35_send_str(AT_INS_CREG);
g_at_send_status.net_ok = 0; g_at_send_status.net_ok = 0;
g_at_send_status.ins_stmp = s_nos_tick.t_1s; g_at_send_status.ins_stmp = s_nos_tick.t_1s;
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_CREG_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_CREG_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms
@ -262,7 +261,7 @@ void L2_task_gm35_flow_handle(struct _s_task_gm35_gprs_ *s)
} }
TTSS_Task_step(TTSS_TASK_GM35_FLOW_GPRS) TTSS_Task_step(TTSS_TASK_GM35_FLOW_GPRS)
L0_uart4_sendstr(AT_INS_GPRS); L3_gm35_send_str(AT_INS_GPRS);
g_at_send_status.gprs_ok = 0; g_at_send_status.gprs_ok = 0;
g_at_send_status.ins_stmp = s_nos_tick.t_1s; g_at_send_status.ins_stmp = s_nos_tick.t_1s;
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_GPRS_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_GPRS_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms
@ -286,7 +285,7 @@ void L2_task_gm35_flow_handle(struct _s_task_gm35_gprs_ *s)
} }
TTSS_Task_step(TTSS_TASK_GM35_FLOW_CIPSTART) TTSS_Task_step(TTSS_TASK_GM35_FLOW_CIPSTART)
L0_uart4_sendstr(AT_INS_CIPSTART); L3_gm35_send_str(AT_INS_CIPSTART);
g_at_send_status.conn_ok = 0; g_at_send_status.conn_ok = 0;
g_at_send_status.ins_stmp = s_nos_tick.t_1s; g_at_send_status.ins_stmp = s_nos_tick.t_1s;
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_CIPSTART_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_CIPSTART_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms

2
source/app/app_task_gm35.h

@ -84,7 +84,7 @@ extern struct _s_task_gm35_gprs_ s_task_connect_gprs;
extern void L3_task_gm35_core_init(void); extern void L3_task_gm35_core_init(void);
extern void L3_task_gm35_core_handle(void); extern void L3_task_gm35_core_handle(void);
extern void L3_gm35_send(U8 *d , U8 len); extern void L3_gm35_send_data(U8 *buf , U8 len);
#endif #endif

6
source/app/app_task_tcp.c

@ -44,8 +44,7 @@ void L3_task_tcp_handle(TS_tcp *s)
} }
TTSS_Task_step(D_task_tcp_send_modbus_pkg) //发送包 TTSS_Task_step(D_task_tcp_send_modbus_pkg) //发送包
L0_uart0_sendArray((U8*)&s->loopPkg,s->pkglen); L3_gm35_send_data((U8*)&s->loopPkg,s->pkglen);
L3_gm35_send((U8*)&s->loopPkg,s->pkglen);
s->sendStamp = s_nos_tick.t_1s; s->sendStamp = s_nos_tick.t_1s;
if(G.ccmd_slaver_info[s->slaverIndex].mask == 1) if(G.ccmd_slaver_info[s->slaverIndex].mask == 1)
{ {
@ -60,7 +59,10 @@ void L3_task_tcp_handle(TS_tcp *s)
g_at_send_status.tcp_last_recv_stmp = s_nos_tick.t_1s; g_at_send_status.tcp_last_recv_stmp = s_nos_tick.t_1s;
s->pAckPkg = (TS_PH3_ccmodbus*)(s_uart4_tcp_rec.sp); s->pAckPkg = (TS_PH3_ccmodbus*)(s_uart4_tcp_rec.sp);
L0_uart0_sendstr("ATRCV=");
L0_uart0_uchex(s->pAckPkg->num + 3);
L0_uart0_sendArray((U8*)s->pAckPkg,s->pAckPkg->num + 3); L0_uart0_sendArray((U8*)s->pAckPkg,s->pAckPkg->num + 3);
if(s->pAckPkg->slaver == G.ccmd_slaver_info[s->slaverIndex].slaver) if(s->pAckPkg->slaver == G.ccmd_slaver_info[s->slaverIndex].slaver)
{ {
s->ackFlag = 1; s->ackFlag = 1;

2
source/app/app_task_tcp_control.c

@ -35,7 +35,7 @@ void L3_task_tcp_control_handle(TS_tcp_control *s)
if(g_at_send_status.conn_ok) if(g_at_send_status.conn_ok)
{ {
//3s一次发送数据包 //3s一次发送数据包
if(s_nos_tick.t_1s - ts_tcp_control.tcp_send_stmp >= 2) if(s_nos_tick.t_1s - ts_tcp_control.tcp_send_stmp >= 3)
{ {
if(!G.authed) if(!G.authed)
{ {

8
source/clib/clib.c

@ -146,6 +146,14 @@ void L1_delay_test(void)
} }
#endif #endif
U8 L0_strlen(U8 *str)
{
U8 count = 0;
while(*str++)
count++;
return count;
}
void Lc_delay_us(vU16 i) void Lc_delay_us(vU16 i)
{ {
vU16 m; vU16 m;

2
source/clib/clib.h

@ -103,6 +103,8 @@ extern U8 libc_strhas(U8 *s1,U8 len1,U8*s2,U8 len2);
extern U8 libc_atoi(U8 *str); extern U8 libc_atoi(U8 *str);
extern void byte_copy_uc(void *dst,void *src,U32 len); extern void byte_copy_uc(void *dst,void *src,U32 len);
extern U8 StrStartsWith(U8 *s1,U8 *s2); extern U8 StrStartsWith(U8 *s1,U8 *s2);
U8 L0_strlen(U8 *str);
#endif /* end __UART_H */ #endif /* end __UART_H */
/***************************************************************************** /*****************************************************************************

5
source/msp/UART0.C

@ -59,8 +59,9 @@ msp/uartx.c 底层代码 和cpu相关 缓存发送也放在里面
#include "uart3.h" #include "uart3.h"
#include "uart4.h" #include "uart4.h"
#include <stdio.h> #include <stdio.h>
#include "../clib/Clib.h"
struct _s_protocol_ s_at0; //struct _s_protocol_ s_at0;
struct _s_uart0_send_buf_ s_uart0_send_shop; struct _s_uart0_send_buf_ s_uart0_send_shop;
struct _s_uart0_send_buf_ s_uart0_send_depot; struct _s_uart0_send_buf_ s_uart0_send_depot;
@ -195,7 +196,7 @@ void L0_uart0_ulhex(vU32 ww)
void L0_uart0_sendstr(U8 *str) void L0_uart0_sendstr(U8 *str)
{ {
//L0_uart0_sendbuf(str,strlen(str)); //L0_uart0_sendbuf(str,strlen(str));
s_uart0_send_depot.max = strlen(str); s_uart0_send_depot.max = L0_strlen(str);
s_uart0_send_depot.p = str; s_uart0_send_depot.p = str;
L0_uart0_sendbuf(); L0_uart0_sendbuf();
} }

8
source/msp/UART4.C

@ -213,14 +213,6 @@ void L0_uart4_ulhex(vU32 ww)
L0_uart4_uchex(ultemp.BYTE4.byte3); L0_uart4_uchex(ultemp.BYTE4.byte3);
} }
U8 L0_strlen(U8 *str)
{
U8 count = 0;
while(*str++)
count++;
return count;
}
void L0_uart4_sendstr(U8 *str) void L0_uart4_sendstr(U8 *str)
{ {
//L0_uart4_sendbuf(str,strlen(str)); //L0_uart4_sendbuf(str,strlen(str));

Loading…
Cancel
Save