|
|
@ -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
|
|
|
|