26 changed files with 1067 additions and 348 deletions
@ -0,0 +1,88 @@ |
|||||
|
////////////////////////////////////////////////////////////////////////////
|
||||
|
///@copyright Copyright (c) 2018, 传控科技 All rights reserved.
|
||||
|
///-------------------------------------------------------------------------
|
||||
|
/// @file bsp_drv.c
|
||||
|
/// @brief bsp @ driver config
|
||||
|
///-------------------------------------------------------------------------
|
||||
|
/// @version 1.0
|
||||
|
/// @author CC
|
||||
|
/// @date 20180331
|
||||
|
/// @note cc_AS_stc02
|
||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
||||
|
#include "../app/task_smartconfig.h" |
||||
|
#include "../app/app_config.h" |
||||
|
#include "../app/task_w600.h" |
||||
|
#include "../msp/uartx.h" |
||||
|
#include "../msp/uart0.h" |
||||
|
#include "../msp/uart2.h" |
||||
|
#include "../clib/clib.h" |
||||
|
|
||||
|
|
||||
|
S_TASK_SMART_CONFIG task_smartconfig; |
||||
|
|
||||
|
|
||||
|
void L3_task_SmartConfig_init(void) |
||||
|
{ |
||||
|
L1_task_init(&task_smartconfig.task); |
||||
|
task_smartconfig.status = 0; |
||||
|
L3_task_s_go(task_smartconfig,D_task_init); |
||||
|
} |
||||
|
|
||||
|
#define D_task_DETECTCHANGE 0x50 |
||||
|
#define D_task_SAMRTCONFIG 0x51 |
||||
|
#define D_task_SMARTCSUCCESS 0x52 |
||||
|
#define D_task_SAMRTCSTOP 0x53 |
||||
|
#define D_task_SAMRTCSTOPPED 0x54 |
||||
|
|
||||
|
|
||||
|
void L3_task_SmartConfig_handler(S_TASK_SMART_CONFIG *s) |
||||
|
{ |
||||
|
TTSS_Task_init() |
||||
|
L2_task_go(D_task_DETECTCHANGE); |
||||
|
L0_uart0_uc('*'); |
||||
|
L0_uart0_uchex(task_smartconfig.status); |
||||
|
L0_uart0_uchex(s->status); |
||||
|
L0_uart0_0d0a(); |
||||
|
L0_uart0_ulhex((U32)s); |
||||
|
|
||||
|
TTSS_Task_step(D_task_DETECTCHANGE) |
||||
|
if(s->status != R.app_status) |
||||
|
{ |
||||
|
|
||||
|
task_smartconfig.status = R.app_status; |
||||
|
if(task_smartconfig.status == WIFI_CONFIG) |
||||
|
{ |
||||
|
L0_uart0_sendstr("task_smartconfig.status == WIFI_CONFIG"); |
||||
|
L3_gm35_send_str(AT_INS_ST_STARTSMART); //开启SmartC
|
||||
|
L2_task_go_Tdelay(D_task_SAMRTCONFIG,D_Tdelay_500ms); |
||||
|
} |
||||
|
} |
||||
|
TTSS_Task_step(D_task_SAMRTCONFIG) |
||||
|
if(Lc_strStartsWith(ts_uart[uNum2].r.buf,"\r\nOK")) |
||||
|
{ |
||||
|
L0_uart0_sendstr("SmartConfig Enter-->"); |
||||
|
// 语音输出:进入配网模式,请配合手机
|
||||
|
L2_task_go_Tdelay(D_task_SMARTCSUCCESS,D_Tdelay_300ms); |
||||
|
} |
||||
|
TTSS_Task_step(D_task_SMARTCSUCCESS) |
||||
|
if(Lc_strStartsWith(ts_uart[uNum2].r.buf,"\r\nsmartconfig type")) |
||||
|
{ |
||||
|
L0_uart0_sendstr("SmartConfig Success!"); |
||||
|
// 语音输出:配网模式成功,请重启设备
|
||||
|
L2_task_go_Tdelay(D_task_SAMRTCSTOP,D_Tdelay_300ms); |
||||
|
} |
||||
|
TTSS_Task_step(D_task_SAMRTCSTOP) |
||||
|
L3_gm35_send_str(AT_INS_ST_STOPSMART); |
||||
|
L2_task_go_Tdelay(D_task_SAMRTCSTOPPED,D_Tdelay_300ms); |
||||
|
|
||||
|
TTSS_Task_step(D_task_SAMRTCSTOPPED) |
||||
|
if (Lc_strStartsWith(ts_uart[uNum2].r.buf,"\r\nOK")) |
||||
|
{ |
||||
|
L0_uart0_sendstr("SmartConfig Stop!"); |
||||
|
R.app_status = WIFI_CONNECTED; |
||||
|
L2_task_go_Tdelay(D_task_DETECTCHANGE,D_Tdelay_300ms); |
||||
|
} |
||||
|
|
||||
|
TTSS_Task_end(); |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
////////////////////////////////////////////////////////////////////////////
|
||||
|
///@copyright Copyright (c) 2018, 传控科技 All rights reserved.
|
||||
|
///-------------------------------------------------------------------------
|
||||
|
/// @file bsp_drv.h
|
||||
|
/// @brief bsp @ driver config
|
||||
|
///-------------------------------------------------------------------------
|
||||
|
/// @version 1.0
|
||||
|
/// @author CC
|
||||
|
/// @date 20180331
|
||||
|
/// @note cc_AS_stc02
|
||||
|
|
||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
||||
|
#ifndef _TASK_SMARTC_H |
||||
|
#define _TASK_SMARTC_H |
||||
|
|
||||
|
#include "../ctask/task.h" |
||||
|
#include "../app/app_config.h" |
||||
|
#include "../clib/type.h" |
||||
|
|
||||
|
|
||||
|
|
||||
|
typedef struct _s_task_smartc |
||||
|
{ |
||||
|
TS_task task; |
||||
|
APP_STATUS status; |
||||
|
}S_TASK_SMART_CONFIG; |
||||
|
|
||||
|
extern S_TASK_SMART_CONFIG task_smartconfig; |
||||
|
|
||||
|
extern void L3_task_SmartConfig_init(void); |
||||
|
extern void L3_task_SmartConfig_handler(S_TASK_SMART_CONFIG *s); |
||||
|
|
||||
|
#endif // #ifndef
|
@ -0,0 +1,744 @@ |
|||||
|
////////////////////////////////////////////////////////////////////////////
|
||||
|
///@copyright Copyright (c) 2018, 传控科技 All rights reserved.
|
||||
|
///-------------------------------------------------------------------------
|
||||
|
/// @file bsp_test.c.c
|
||||
|
/// @brief bsp @ driver config
|
||||
|
///-------------------------------------------------------------------------
|
||||
|
/// @version 1.0
|
||||
|
/// @author CC
|
||||
|
/// @date 20180331
|
||||
|
/// @note cc_AS_stc02
|
||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
||||
|
#include "task_w600.h" |
||||
|
|
||||
|
#include "app_config.h" |
||||
|
#include "../msp/uart0.h" |
||||
|
#include "../msp/uart2.h" |
||||
|
#include "../asp/asp_oid.h" |
||||
|
#include "../bsp/bsp_config.h" |
||||
|
|
||||
|
struct _s_task_W600_Para _s_task_w600_para; |
||||
|
//TS_tcp_control ts_tcp_control;
|
||||
|
//TS_tcp ts_tcp;
|
||||
|
|
||||
|
|
||||
|
|
||||
|
#define LEN_GPRS_TCP_PKG 18 |
||||
|
|
||||
|
U8 ins_cipsend[30] = "AT+CIPSEND=000\r\n"; |
||||
|
|
||||
|
U8 * _cipsend_hex(U8 len) |
||||
|
{ |
||||
|
U8 pos = Lc_strlen("AT+CIPSEND="); |
||||
|
ins_cipsend[pos++] = len % 1000 / 100 + '0'; |
||||
|
ins_cipsend[pos++] = len % 100 / 10 + '0'; |
||||
|
ins_cipsend[pos++] = len % 10 / 1 + '0'; |
||||
|
|
||||
|
return ins_cipsend; |
||||
|
} |
||||
|
|
||||
|
void L3_gm35_send_str(U8 *str) |
||||
|
{ |
||||
|
L0_uart2_sendstr(str); |
||||
|
if(G.debug) |
||||
|
{ |
||||
|
L0_uart0_sendstr(str); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//将数据放入gm35待发送缓冲区
|
||||
|
void L3_gm35_send_data(U8 *buf , U16 len) |
||||
|
{ |
||||
|
//L3_gm35_send_str(_cipsend_hex(len));
|
||||
|
// L0_uart2_sendArray(buf,len);
|
||||
|
if(G.debug) |
||||
|
{ |
||||
|
L0_uart0_sendArray(buf,len); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void L3_gm35_rcv_data(U8* buf,U8 num) |
||||
|
{ |
||||
|
if(G.debug) |
||||
|
{ |
||||
|
L0_uart0_sendstr("ATRCV="); |
||||
|
L0_uart0_uchex(num); |
||||
|
L0_uart0_sendArray(buf,num+3); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
U8 wifi_ins[64]; |
||||
|
char *GET_WIFI_INS() |
||||
|
{ |
||||
|
//AT+CWJAP_DEF=\"ccsens\",\"ccsens123\"\r\n"
|
||||
|
Lc_strcpy(wifi_ins,"AT+CWJAP_DEF=\""); |
||||
|
Lc_strcpy(wifi_ins+Lc_strlen(wifi_ins),G.st_sid); |
||||
|
Lc_strcpy(wifi_ins+Lc_strlen(wifi_ins),"\",\""); |
||||
|
Lc_strcpy(wifi_ins+Lc_strlen(wifi_ins),G.st_pwd); |
||||
|
Lc_strcpy(wifi_ins+Lc_strlen(wifi_ins),"\"\r\n"); |
||||
|
return wifi_ins; |
||||
|
} |
||||
|
|
||||
|
U8 wifi_rev_buf[64], wifi_tmp[64]; |
||||
|
U8 tmp_num = 0; |
||||
|
void L3_uart2_wifi_parse(void) |
||||
|
{ |
||||
|
if (ts_uart[uNum2].r.ok == 1) |
||||
|
{ |
||||
|
U8 *ptr = wifi_rev_buf; |
||||
|
ts_uart[uNum2].r.ok = 0; |
||||
|
Lc_buf_copy_uc(wifi_rev_buf, ts_uart[uNum2].r.buf, ts_uart[uNum2].r.num); |
||||
|
wifi_rev_buf[ts_uart[uNum2].r.num] = 0; |
||||
|
while(*ptr) |
||||
|
{ |
||||
|
U8 c = *ptr++; |
||||
|
if(c != '\r' && c != '\n') |
||||
|
{ |
||||
|
wifi_tmp[tmp_num++] = c; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
wifi_tmp[tmp_num] = 0; |
||||
|
if(tmp_num == 0) |
||||
|
{ |
||||
|
continue; |
||||
|
} |
||||
|
L0_uart0_uc('>'); |
||||
|
L0_uart0_sendstr(wifi_tmp); |
||||
|
L0_uart0_0d0a(); |
||||
|
if(Lc_strcmp(wifi_tmp,"OK") == 0) |
||||
|
{ |
||||
|
// L0_uart0_sendstr("Moudle Answer:OK AND ins_ok = 1");
|
||||
|
_s_task_w600_para.ins_ok = 1; |
||||
|
} |
||||
|
else if(Lc_strcmp(wifi_tmp,"WIFI GOT IP") == 0) |
||||
|
{ |
||||
|
_s_task_w600_para.st_wifi_ok = 1; |
||||
|
} |
||||
|
else if(Lc_strcmp(wifi_tmp,"CONNECT") == 0) |
||||
|
{ |
||||
|
_s_task_w600_para.serve_ok = 1; |
||||
|
} |
||||
|
tmp_num = 0; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
void L3_uart2_wifi_parse111(void) |
||||
|
{ |
||||
|
if (ts_uart[uNum2].r.ok == 1) |
||||
|
{ |
||||
|
U8 *pPara = ts_uart[uNum2].r.buf; |
||||
|
pPara[ts_uart[uNum2].r.num] = 0; |
||||
|
ts_uart[uNum2].r.ok = 0; |
||||
|
L0_uart0_uc('$'); |
||||
|
// L0_uart0_sendArray(ts_uart[uNum2].r.buf,ts_uart[uNum2].r.num);
|
||||
|
L0_uart0_sendstr(ts_uart[uNum2].r.buf); |
||||
|
|
||||
|
if(Lc_strStartsWith(pPara,"\r\nOK")) |
||||
|
{ |
||||
|
LED3 = ~LED3; |
||||
|
L0_uart0_sendstr("Moudle Answer:OK AND ins_ok = 1"); |
||||
|
L0_uart0_0d0a(); |
||||
|
_s_task_w600_para.ins_ok = 1; |
||||
|
} |
||||
|
// if (Lc_strStartsWith(pPara,"WIFI DISCONNECT"))
|
||||
|
// {
|
||||
|
// LED3 = ~LED3;
|
||||
|
// }
|
||||
|
else if(Lc_strStartsWith(pPara,"WIFI GOT IP")) |
||||
|
{ |
||||
|
_s_task_w600_para.st_wifi_ok = 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"ERROR")) |
||||
|
{ |
||||
|
_s_task_w600_para.st_error= 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"no change")) |
||||
|
{ |
||||
|
_s_task_w600_para.serve_ok= 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"CIPMUX and")) |
||||
|
{ |
||||
|
_s_task_w600_para.ap_serve_ok = 1; |
||||
|
} |
||||
|
|
||||
|
//Station模式判定
|
||||
|
if(_s_task_w600_para.mode == W600_ST) |
||||
|
{ |
||||
|
if(Lc_strStartsWith(pPara,"WIFI GOT IP")) |
||||
|
{ |
||||
|
_s_task_w600_para.st_wifi_ok = 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"ALREADY CONNECTED")) |
||||
|
{ |
||||
|
_s_task_w600_para.st_cip_ok = 1; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#if 0 |
||||
|
|
||||
|
void L3_uart2_exp_protocol(struct _s_PC1_0D0A_ *p) |
||||
|
{ |
||||
|
if (1 == p->ok ) |
||||
|
{ |
||||
|
U8 *pPara = p->buf + 1; |
||||
|
_s_task_w600_para.gprs_last_recv_stmp = s_nos_tick.t_1s; |
||||
|
//通用判定
|
||||
|
if(Lc_strStartsWith(pPara,"OK")) |
||||
|
{ |
||||
|
_s_task_w600_para.ins_ok = 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"ERROR")) |
||||
|
{ |
||||
|
_s_task_w600_para.st_error= 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"no change")) |
||||
|
{ |
||||
|
_s_task_w600_para.serve_ok= 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"CIPMUX and")) |
||||
|
{ |
||||
|
_s_task_w600_para.ap_serve_ok = 1; |
||||
|
} |
||||
|
|
||||
|
//Station模式判定
|
||||
|
if(_s_task_w600_para.mode == W600_ST) |
||||
|
{ |
||||
|
if(Lc_strStartsWith(pPara,"WIFI GOT IP")) |
||||
|
{ |
||||
|
_s_task_w600_para.st_wifi_ok = 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"ALREADY CONNECTED")) |
||||
|
{ |
||||
|
_s_task_w600_para.st_cip_ok = 1; |
||||
|
} |
||||
|
} |
||||
|
//AP模式判定
|
||||
|
else if(_s_task_w600_para.mode == W600_AP) |
||||
|
{ |
||||
|
if(Lc_strStartsWith(pPara,"+IPD,")) |
||||
|
{ |
||||
|
//解析协议,success
|
||||
|
//1将id,pwd放入寄存器2.ok=1
|
||||
|
//失败不处理不设置标志位
|
||||
|
//buf: [20]+IPD,0,5:#ccsens:ccsens123$ 后面没\0
|
||||
|
//pPara: +IPD,0,5:#ccsens:ccsens123$
|
||||
|
|
||||
|
int j = 0 , len = p->buf[0]; |
||||
|
p->buf[len+1] = 0;//在+IPD,0,5:#ccsens:ccsens123$后加0
|
||||
|
for(j=0;j<len;j++) |
||||
|
{ |
||||
|
if(pPara[j] == ':') |
||||
|
{ |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
pPara += (j+1);//pPara ===== #ccsens:ccsens123$
|
||||
|
L0_uart0_sendstr(pPara); |
||||
|
len = Lc_strlen(pPara); |
||||
|
if(pPara[0] == '#' && pPara[len-1] == '$') |
||||
|
{ |
||||
|
pPara[len-1] = 0; |
||||
|
pPara++;//pPara ===== ccsens:ccsens123
|
||||
|
for(j=0;j<len;j++) |
||||
|
{ |
||||
|
if(pPara[j] == ':') |
||||
|
{ |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
pPara[j] = 0;//ccsens\0ccsens123
|
||||
|
Lc_strcpy(G.st_sid, pPara); |
||||
|
pPara += j+1;//ccsens123
|
||||
|
Lc_strcpy(G.st_pwd, pPara); |
||||
|
//标志位
|
||||
|
_s_task_w600_para.ap_rec_ok = 1; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
else if(Lc_strStartsWith(pPara,"0,CONNECT")) |
||||
|
{ |
||||
|
_s_task_w600_para.ap_tcp_ok = 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"1,CONNECT")) |
||||
|
{ |
||||
|
_s_task_w600_para.ap_tcp_ok = 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"SEND OK")) |
||||
|
{ |
||||
|
_s_task_w600_para.ap_data_ok= 1; |
||||
|
} |
||||
|
else if(Lc_strStartsWith(pPara,"+DIST_STA_IP")) |
||||
|
{ |
||||
|
_s_task_w600_para.ap_conn_ok = 1; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
p->ok = 0; |
||||
|
} |
||||
|
} |
||||
|
#endif |
||||
|
|
||||
|
//------------------------------------------------------ gm35 tasks --------------------------------
|
||||
|
|
||||
|
|
||||
|
void L3_task_W600_flow_init(U8 mode) |
||||
|
{ |
||||
|
L1_task_init(&_s_task_w600_para.task); |
||||
|
L3_task_s_go(_s_task_w600_para,D_task_init); |
||||
|
_s_task_w600_para.mode = mode; |
||||
|
_s_task_w600_para.send = 0; |
||||
|
_s_task_w600_para.conn_ok = 0; |
||||
|
#if 0 |
||||
|
g_at_send_status.send_lock = 0; |
||||
|
g_at_send_status.module_ok = 0; |
||||
|
g_at_send_status.sim_ok = 0; |
||||
|
g_at_send_status.net_ok = 0; |
||||
|
g_at_send_status.gprs_ok = 0; |
||||
|
g_at_send_status.conn_ok = 0; |
||||
|
|
||||
|
g_at_send_status.ins_stmp = 0; //每次发送指令时设置
|
||||
|
|
||||
|
g_at_send_status.heart_stmp = 0; //连接成功时设置
|
||||
|
g_at_send_status.data_stmp = 0; |
||||
|
g_at_send_status.sign_flag = 0; |
||||
|
g_at_send_status.ack_flag = 0; |
||||
|
|
||||
|
g_at_send_status.gprs_last_recv_stmp = 0; //接收到指令时设置
|
||||
|
g_at_send_status.tcp_last_recv_stmp = 0; //连接成功和接收到数据时设置
|
||||
|
g_at_send_status.tcp_close_stmp = 0; //重新上电和检测到断开时设置
|
||||
|
g_at_send_status.gm35_reboot_times = 0; //连接成功时清0
|
||||
|
#endif |
||||
|
} |
||||
|
|
||||
|
|
||||
|
//------------------------ GM35 Flow Handle -----------------------------------
|
||||
|
#define TTSS_TASK_GM35_MODE 0x01 |
||||
|
|
||||
|
#define TTSS_TASK_GM35_FLOW_ATEQV 0x02 |
||||
|
#define TTSS_TASK_GM35_FLOW_ST 0x03 |
||||
|
#define TTSS_TASK_GM35_FLOW_ST_WIFI 0x04 |
||||
|
#define TTSS_TASK_GM35_FLOW_ST_CIPMUX0 0x05 |
||||
|
#define TTSS_TASK_GM35_FLOW_ST_TCP 0x06 |
||||
|
#define TTSS_TASK_GM35_FLOW_ST_CIPMODE1 0x07 |
||||
|
#define TTSS_TASK_GM35_FLOW_ST_CIPSEND 0x08 |
||||
|
#define TTSS_TASK_GM35_FLOW_ST_DATA 0x09 |
||||
|
#define TTSS_TASK_GM35_FLOW_ST_CIPMODE0 0x10 |
||||
|
#define TTSS_TASK_GM35_FLOW_ST_SERVE 0x11 |
||||
|
|
||||
|
#define TTSS_TASK_GM35_FLOW_AP 0x20 |
||||
|
#define TTSS_TASK_GM35_FLOW_AP_WIFI 0x21 |
||||
|
#define TTSS_TASK_GM35_FLOW_AP_CIPMUX1 0x22 |
||||
|
#define TTSS_TASK_GM35_FLOW_AP_SERVER 0x23 |
||||
|
#define TTSS_TASK_GM35_FLOW_AP_CIPMUX0 0x24 |
||||
|
|
||||
|
#define TTSS_TASK_GM35_FLOW_TCP_TIME 0x25 |
||||
|
#define TTSS_TASK_GM35_FLOW_AP_DATA 0x26 |
||||
|
#define TTSS_TASK_GM35_FLOW_AP_TCP_CONN_WAIT 0x27 |
||||
|
#define TTSS_TASK_GM35_FLOW_AP_WIFI_DATA_STA_WAIT 0x28 |
||||
|
#define TTSS_TASK_MODE_TRAN 0x29 |
||||
|
#define TTSS_TASK_MODE_CONFIG_WAIT 0x2A |
||||
|
#define TTSS_TASK_MODE_SERVER_CLOSE 0x2B |
||||
|
|
||||
|
#define INS_TIMEOUT 5 |
||||
|
#define GM35_SEND_DATA_INTERVAL 300 |
||||
|
#define GM35_SEND_HEART_INTERVAL 60 |
||||
|
#define GM35_SEND_CIPSTATUS_INTERVAL 5 |
||||
|
|
||||
|
void L2_task_W600_flow_handle(struct _s_task_W600_Para *s) |
||||
|
{ |
||||
|
TTSS_Task_init() |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ATEQV,D_Tdelay_5s);//上电等待1s
|
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ATEQV) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_ATE0); //"ATE0\r\n" //模块查询+关闭回显
|
||||
|
s->ins_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->ap_serve_ok) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
s->ap_serve_ok = 0; |
||||
|
L3_gm35_send_str(AT_INS_AP_SERVER_CLOSE); |
||||
|
} |
||||
|
else if(s->serve_ok == 1 || s->ins_ok == 1) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
s->serve_ok = 0; |
||||
|
L2_task_go_Tdelay(s->mode == W600_ST ? TTSS_TASK_GM35_FLOW_ST |
||||
|
:TTSS_TASK_GM35_FLOW_ST_SERVE,D_Tdelay_1s); |
||||
|
} |
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_ST); |
||||
|
s->ins_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(s->ins_ok == 1) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_WIFI,D_Tdelay_1s); |
||||
|
} |
||||
|
|
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_WIFI) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(GET_WIFI_INS()); |
||||
|
s->ins_ok = 0; |
||||
|
s->st_wifi_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->st_wifi_ok) |
||||
|
{ |
||||
|
s->send = 0; |
||||
|
R.app_status = WIFI_CONNECTED; //wifi连接成功
|
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMUX0,D_Tdelay_1s); |
||||
|
} |
||||
|
|
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_CIPMUX0) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_ST_CIPMUX0); |
||||
|
s->ins_ok = 0; |
||||
|
s->st_wifi_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->ins_ok) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_TCP,D_Tdelay_1s); |
||||
|
} |
||||
|
|
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_TCP) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_ST_TCP); |
||||
|
s->ins_ok = 0; |
||||
|
s->st_cip_ok = 0; |
||||
|
s->serve_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
// else if(1 == s->ins_ok || 1 == s->st_cip_ok) //等待
|
||||
|
else if(1 == s->serve_ok) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
R.app_status = TCP_CONNECTED; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMODE1,D_Tdelay_1s); |
||||
|
} |
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_CIPMODE1) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_ST_CIPMODE1); |
||||
|
s->ins_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->ins_ok) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPSEND,D_Tdelay_1s); |
||||
|
} |
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_CIPSEND) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_ST_CIPSEND); |
||||
|
s->ins_ok = 0; |
||||
|
s->st_error = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
// L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPSEND,D_Tdelay_300ms);//发完之后要等,不然st_error == 0没用 ,没收到error之前也是=0
|
||||
|
} |
||||
|
else if((s->ins_ok == 1) && (s->st_error == 1)) |
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_TCP,0); |
||||
|
} |
||||
|
else if((s->ins_ok == 1) && (s->st_error == 0)) |
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_DATA,0); |
||||
|
} |
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_DATA) |
||||
|
//L0_uart2_sendstr("abcdefg");
|
||||
|
_s_task_w600_para.conn_ok = 1; |
||||
|
L2_task_go(TTSS_TASK_GM35_FLOW_ST_DATA); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/********************s->mode = W600_AP(按键进入)****************************** */ |
||||
|
|
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_SERVE) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_AP_SERVER_CLOSE); //关闭服务器
|
||||
|
s->ins_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(s->st_error) |
||||
|
{ |
||||
|
s->send = 0; |
||||
|
s->st_error = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMODE0,D_Tdelay_300ms); |
||||
|
} |
||||
|
else if((s->serve_ok == 1)|| (s->ins_ok == 1)) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
s->serve_ok = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMODE0,D_Tdelay_300ms); |
||||
|
} |
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_CIPMODE0) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_ST_CIPMODE0); |
||||
|
s->ins_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->ins_ok) //等待(等待过程中,进入AP模式)
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_AP,D_Tdelay_300ms); |
||||
|
} |
||||
|
|
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发(超时,设置单连接模式)
|
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_AP_CIPMUX0,D_Tdelay_300ms); |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_AP_CIPMUX0) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_ST_CIPMUX0); |
||||
|
s->ins_ok = 0; |
||||
|
s->st_wifi_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->ins_ok) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMODE0,D_Tdelay_300ms); |
||||
|
} |
||||
|
|
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_AP) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_AP); |
||||
|
s->ins_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->ins_ok) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_AP_WIFI,D_Tdelay_300ms); |
||||
|
} |
||||
|
|
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_AP_WIFI) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_AP_WIFI); |
||||
|
s->ins_ok = 0; |
||||
|
s->st_error = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if((1 == s->ins_ok)||(1 == s->st_error)) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_AP_CIPMUX1,D_Tdelay_300ms); |
||||
|
} |
||||
|
|
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_AP_CIPMUX1) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_AP_CIPMUX1); |
||||
|
s->ins_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->ins_ok) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_AP_SERVER,D_Tdelay_300ms); |
||||
|
} |
||||
|
|
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_AP_SERVER) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_AP_SERVER); |
||||
|
s->ins_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->ins_ok) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_TCP_TIME,D_Tdelay_300ms); |
||||
|
} |
||||
|
|
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_TCP_TIME) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_AP_TCP_TIME); |
||||
|
// LED2 = 0;
|
||||
|
s->ins_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->ins_ok) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
s->ap_tcp_ok = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_AP_TCP_CONN_WAIT,D_Tdelay_300ms); |
||||
|
} |
||||
|
|
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_AP_TCP_CONN_WAIT) //等待TCP连接
|
||||
|
if(1 == s->ap_tcp_ok) |
||||
|
{ |
||||
|
s->ap_conn_ok = 0; |
||||
|
s->ap_tcp_ok = 0; |
||||
|
s->ap_rec_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_AP_WIFI_DATA_STA_WAIT,0); |
||||
|
} |
||||
|
|
||||
|
TTSS_Task_step(TTSS_TASK_GM35_FLOW_AP_WIFI_DATA_STA_WAIT) |
||||
|
if(1 == s->ap_rec_ok)//收到正确的数据才会ok=1
|
||||
|
{//ok回复#ok$\r\n
|
||||
|
s->ap_rec_ok = 0; |
||||
|
s->rev = 1; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
//L0_uart0_sendstr("ap config ok");
|
||||
|
//L3_gm35_send_str(AT_INS_AP_SEND);//进入发送模式
|
||||
|
//L2_task_go(TTSS_TASK_MODE_TRAN);
|
||||
|
} |
||||
|
else if(1 == s->ap_conn_ok) |
||||
|
{ |
||||
|
s->ap_conn_ok = 0; |
||||
|
s->ap_tcp_ok = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_AP_CIPMUX1,D_Tdelay_300ms); |
||||
|
} |
||||
|
else if((s_nos_tick.t_1s - s->ins_stmp > 3) && (s->rev == 1)) |
||||
|
{//超时重发
|
||||
|
s->ap_data_ok = 0; |
||||
|
s->rev= 0; |
||||
|
L3_gm35_send_str(AT_INS_AP_SEND); |
||||
|
L2_task_go_Tdelay(TTSS_TASK_MODE_TRAN,D_Tdelay_100ms); |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_MODE_TRAN) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str("#OK$\r\n"); |
||||
|
// LED2 = 1;
|
||||
|
s->ap_rec_ok = 0; |
||||
|
s->ins_ok = 0; |
||||
|
s->send = 1; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
} |
||||
|
else if(1 == s->ap_data_ok) //等待//此处进入ins_ok,不进入send_ok,因为之前有一个no change OK,在进入AP关闭服务器那里
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
s->ap_tcp_ok = 0; |
||||
|
L2_task_go_Tdelay(TTSS_TASK_MODE_SERVER_CLOSE,D_Tdelay_100ms); |
||||
|
} |
||||
|
TTSS_Task_step(TTSS_TASK_MODE_SERVER_CLOSE) |
||||
|
if(s->send == 0) |
||||
|
{//发送
|
||||
|
L3_gm35_send_str(AT_INS_AP_SERVER_CLOSE); |
||||
|
s->ins_ok = 0; |
||||
|
s->ins_stmp = s_nos_tick.t_1s; |
||||
|
s->send = 1; |
||||
|
} |
||||
|
else if(1 == s->ins_ok) //等待
|
||||
|
{ |
||||
|
s->send = 0; |
||||
|
// LED1 = 1;
|
||||
|
// LED2 = 1;
|
||||
|
L3_task_W600_flow_init(W600_ST); |
||||
|
} |
||||
|
else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT) |
||||
|
{//超时重发
|
||||
|
s->send = 0; |
||||
|
} |
||||
|
TTSS_Task_end(); |
||||
|
} |
||||
|
|
||||
|
|
Loading…
Reference in new issue