diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym index a9b59b7..511b6f6 100644 Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym and b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym differ diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.siwork b/si4/soft_gsm_main.si4project/soft_gsm_main.siwork index 1e53d54..aef5b98 100644 Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.siwork and b/si4/soft_gsm_main.si4project/soft_gsm_main.siwork differ diff --git a/source/app/app_task_gm35.c b/source/app/app_task_gm35.c index c2a497b..0b37d73 100644 --- a/source/app/app_task_gm35.c +++ b/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"; -#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 pos = libc_strlen("AT+CIPSEND="); @@ -44,18 +41,19 @@ U8 * _cipsend_hex(U8 len) return ins_cipsend; } +void L3_gm35_send_str(U8 *str) +{ + L0_uart4_sendstr(str); + L0_uart0_sendstr(str); +} + //将数据放入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; - int i = 0x20000; - GM35_TCP_CIPSEND(_cipsend_hex(len)); - while(i--); + L3_gm35_send_str(_cipsend_hex(len)); L0_uart4_sendArray(buf,len); - GM35_TCP_CIPSEND_COMPLETE(); + L0_uart0_sendArray(buf,len); } - - //------------------------------------------------------ gm35 tasks -------------------------------- // 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); L3_task_s_go(s_task_gm35_daemon,D_task_init); + + P55 = 1; //灯灭 } //------------------------ 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); TTSS_Task_step(TTSS_TASK_GM35_DAEMON_CIPSTATUS) - //if(0 == g_at_send_status.send_lock) - //{ - L0_uart4_sendstr(AT_INS_CIPSTATUS); + L3_gm35_send_str(AT_INS_CIPSTATUS); L2_task_go_Tdelay(TTSS_TASK_GM35_DAEMON_JUDGE,D_Tdelay_2s); - //} TTSS_Task_step(TTSS_TASK_GM35_DAEMON_JUDGE) 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指令 { //关闭连接 @@ -132,11 +130,12 @@ void L2_task_gm35_daemon_handle(struct _s_task_gm35_gprs_ *s) { //关闭连接 g_at_send_status.conn_ok = 0; - L0_uart4_sendstr(AT_INS_CLOSED); + L3_gm35_send_str(AT_INS_CLOSED); } } else //未连接 { + P55 = 1; //灯灭 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) @@ -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 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.ins_stmp = s_nos_tick.t_1s; 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) - L0_uart4_sendstr(AT_INS_CCID); + L3_gm35_send_str(AT_INS_CCID); g_at_send_status.sim_ok = 0; 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 @@ -238,7 +237,7 @@ void L2_task_gm35_flow_handle(struct _s_task_gm35_gprs_ *s) } 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.ins_stmp = s_nos_tick.t_1s; 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) - L0_uart4_sendstr(AT_INS_GPRS); + L3_gm35_send_str(AT_INS_GPRS); g_at_send_status.gprs_ok = 0; 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 @@ -286,7 +285,7 @@ void L2_task_gm35_flow_handle(struct _s_task_gm35_gprs_ *s) } 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.ins_stmp = s_nos_tick.t_1s; L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_CIPSTART_WAIT,D_Tdelay_300ms); //指令发送完毕等待300ms diff --git a/source/app/app_task_gm35.h b/source/app/app_task_gm35.h index 26891a8..1502c63 100644 --- a/source/app/app_task_gm35.h +++ b/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_handle(void); -extern void L3_gm35_send(U8 *d , U8 len); +extern void L3_gm35_send_data(U8 *buf , U8 len); #endif diff --git a/source/app/app_task_tcp.c b/source/app/app_task_tcp.c index da41485..d751bb5 100644 --- a/source/app/app_task_tcp.c +++ b/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) //发送包 - L0_uart0_sendArray((U8*)&s->loopPkg,s->pkglen); - L3_gm35_send((U8*)&s->loopPkg,s->pkglen); + L3_gm35_send_data((U8*)&s->loopPkg,s->pkglen); s->sendStamp = s_nos_tick.t_1s; 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; 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); + if(s->pAckPkg->slaver == G.ccmd_slaver_info[s->slaverIndex].slaver) { s->ackFlag = 1; diff --git a/source/app/app_task_tcp_control.c b/source/app/app_task_tcp_control.c index 5507e52..ee9d007 100644 --- a/source/app/app_task_tcp_control.c +++ b/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) { //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) { diff --git a/source/clib/clib.c b/source/clib/clib.c index 1bb3a51..366548f 100644 --- a/source/clib/clib.c +++ b/source/clib/clib.c @@ -146,6 +146,14 @@ void L1_delay_test(void) } #endif +U8 L0_strlen(U8 *str) +{ + U8 count = 0; + while(*str++) + count++; + return count; +} + void Lc_delay_us(vU16 i) { vU16 m; diff --git a/source/clib/clib.h b/source/clib/clib.h index 3ee35af..92d4bea 100644 --- a/source/clib/clib.h +++ b/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 void byte_copy_uc(void *dst,void *src,U32 len); extern U8 StrStartsWith(U8 *s1,U8 *s2); +U8 L0_strlen(U8 *str); + #endif /* end __UART_H */ /***************************************************************************** diff --git a/source/msp/UART0.C b/source/msp/UART0.C index 5aeed43..36000ba 100644 --- a/source/msp/UART0.C +++ b/source/msp/UART0.C @@ -58,9 +58,10 @@ msp/uartx.c 底层代码 和cpu相关 缓存发送也放在里面 #include "uart2.h" #include "uart3.h" #include "uart4.h" - #include - -struct _s_protocol_ s_at0; + #include +#include "../clib/Clib.h" + +//struct _s_protocol_ s_at0; struct _s_uart0_send_buf_ s_uart0_send_shop; 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) { //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; L0_uart0_sendbuf(); } diff --git a/source/msp/UART4.C b/source/msp/UART4.C index 7d25e95..f22d6c1 100644 --- a/source/msp/UART4.C +++ b/source/msp/UART4.C @@ -213,14 +213,6 @@ void L0_uart4_ulhex(vU32 ww) 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) { //L0_uart4_sendbuf(str,strlen(str));