|
|
@ -9,6 +9,7 @@ |
|
|
#include "rtthread.h" |
|
|
#include "rtthread.h" |
|
|
#include "rttypes.h" |
|
|
#include "rttypes.h" |
|
|
|
|
|
|
|
|
|
|
|
#ifdef EDU_TRAINING |
|
|
#if defined(__CC_ARM) && !defined(__clang__) |
|
|
#if defined(__CC_ARM) && !defined(__clang__) |
|
|
#define VK_MAVLINK_DO_PRAGMA(x) _Pragma(#x) |
|
|
#define VK_MAVLINK_DO_PRAGMA(x) _Pragma(#x) |
|
|
#define __pragma(x) VK_MAVLINK_DO_PRAGMA(x) |
|
|
#define __pragma(x) VK_MAVLINK_DO_PRAGMA(x) |
|
|
@ -22,22 +23,25 @@ |
|
|
#undef __pragma |
|
|
#undef __pragma |
|
|
#undef VK_MAVLINK_DO_PRAGMA |
|
|
#undef VK_MAVLINK_DO_PRAGMA |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#define DBG_TAG "LINK_LOG" |
|
|
#define DBG_TAG "LINK_LOG" |
|
|
#define DBG_LVL DBG_INFO |
|
|
#define DBG_LVL DBG_INFO |
|
|
#include "rtdbg.h" |
|
|
#include "rtdbg.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char cmd_cmd[100] = {0}; |
|
|
|
|
|
char cmd_str[100] = {0}; |
|
|
|
|
|
|
|
|
static char cmd_cmd[128] = {0}; |
|
|
|
|
|
|
|
|
no_carrier_match_t _no_carrier_t = {0}; |
|
|
no_carrier_match_t _no_carrier_t = {0}; |
|
|
|
|
|
|
|
|
/*关闭TCP连接*/ |
|
|
/*关闭TCP连接*/ |
|
|
void client_tcp_close(Cclient_t *client) { |
|
|
void client_tcp_close(Cclient_t *client) { |
|
|
|
|
|
char close_cmd[24]; |
|
|
|
|
|
|
|
|
client->connect_sta = false; |
|
|
client->connect_sta = false; |
|
|
rt_sprintf(cmd_str, AT_QICLOSE, client->connect_ID); |
|
|
|
|
|
BSP_LTE_SendCmd(cmd_str, DEFAULT_EXPECT, DEFAULT_ERROR, LTE_CMD_WAIT_QICLOSE); |
|
|
|
|
|
|
|
|
rt_snprintf(close_cmd, sizeof(close_cmd), AT_QICLOSE, client->connect_ID); |
|
|
|
|
|
BSP_LTE_SendCmd(close_cmd, DEFAULT_EXPECT, DEFAULT_ERROR, |
|
|
|
|
|
LTE_CMD_WAIT_QICLOSE); |
|
|
client->error_cnt = 0; |
|
|
client->error_cnt = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -130,10 +134,8 @@ static int no_carrier_char_parser(uint8_t ch){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void no_carrier_match(uint8_t * at_buf,rt_size_t len){ |
|
|
static void no_carrier_match(uint8_t * at_buf,rt_size_t len){ |
|
|
uint8_t buff[256] = {0}; |
|
|
|
|
|
rt_memcpy(buff, at_buf, len); |
|
|
|
|
|
for(int i = 0;i < len;i++){ |
|
|
for(int i = 0;i < len;i++){ |
|
|
if(no_carrier_char_parser(buff[i]) == 1){ |
|
|
|
|
|
|
|
|
if(no_carrier_char_parser(at_buf[i]) == 1){ |
|
|
_no_carrier_t.match_flag = COMPLETE_MATCH; |
|
|
_no_carrier_t.match_flag = COMPLETE_MATCH; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -230,36 +232,8 @@ int16_t EC800K_Reset(void) { |
|
|
return rst; |
|
|
return rst; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*将EC800K为透传模式*/ |
|
|
|
|
|
// int16_t Set_Tansparent_Mode(Cclient_t *pClient)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// int AT_QISWTMD_error_count = 0;
|
|
|
|
|
|
// /*如果socket成功打开,则将它设置为透传模式*/
|
|
|
|
|
|
// if(pClient->connect_sta == true)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// /*打开透传模式*/
|
|
|
|
|
|
// memset(cmd_cmd, 0, sizeof(cmd_cmd));
|
|
|
|
|
|
// sprintf(cmd_cmd, AT_QISWTMD, pClient->connect_ID, 2);
|
|
|
|
|
|
// while(0 != BSP_LTE_SendCmd( cmd_cmd, CONNECTE_OK, DEFAULT_ERROR,
|
|
|
|
|
|
// LTE_CMD_WAIT_LONG ))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// //rt_thread_mdelay(1000);
|
|
|
|
|
|
//
|
|
|
|
|
|
// if(AT_QISWTMD_error_count++ > 5)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// EC800K_Reset();
|
|
|
|
|
|
//
|
|
|
|
|
|
// rt_thread_mdelay(3000);
|
|
|
|
|
|
//
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// return 0;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
int16_t client_tcp_connect(Cclient_t *client) { |
|
|
int16_t client_tcp_connect(Cclient_t *client) { |
|
|
|
|
|
int cmd_len; |
|
|
int16_t rtn = 0; |
|
|
int16_t rtn = 0; |
|
|
|
|
|
|
|
|
if (lte_dev.config_sta == false) |
|
|
if (lte_dev.config_sta == false) |
|
|
@ -299,9 +273,14 @@ int16_t client_tcp_connect(Cclient_t *client) { |
|
|
|
|
|
|
|
|
// 2, 打开链接
|
|
|
// 2, 打开链接
|
|
|
memset(cmd_cmd, 0, sizeof(cmd_cmd)); |
|
|
memset(cmd_cmd, 0, sizeof(cmd_cmd)); |
|
|
memset(cmd_str, 0, sizeof(cmd_str)); |
|
|
|
|
|
rt_sprintf(cmd_cmd, AT_QIOPEN_TRANS /*AT_QIOPEN_FORW*/, client->connect_ID, |
|
|
|
|
|
client->mode, client->ip, client->port); |
|
|
|
|
|
|
|
|
cmd_len = rt_snprintf(cmd_cmd, sizeof(cmd_cmd), AT_QIOPEN_TRANS, |
|
|
|
|
|
client->connect_ID, client->mode, client->ip, |
|
|
|
|
|
client->port); |
|
|
|
|
|
if (cmd_len < 0 || cmd_len >= (int)sizeof(cmd_cmd)) { |
|
|
|
|
|
LOG_E("QIOPEN command is too long"); |
|
|
|
|
|
lte_diag.qioopen_failures++; |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
/* 透传模式成功返回 CONNECT;一次尝试只发送一次 QIOPEN。 */ |
|
|
/* 透传模式成功返回 CONNECT;一次尝试只发送一次 QIOPEN。 */ |
|
|
while (0 != BSP_LTE_SendCmd(cmd_cmd, CONNECTE_OK, DEFAULT_ERROR, |
|
|
while (0 != BSP_LTE_SendCmd(cmd_cmd, CONNECTE_OK, DEFAULT_ERROR, |
|
|
LTE_CMD_WAIT_QIOPEN)) { |
|
|
LTE_CMD_WAIT_QIOPEN)) { |
|
|
@ -328,10 +307,6 @@ int16_t client_tcp_connect(Cclient_t *client) { |
|
|
client->error_cnt = 0; |
|
|
client->error_cnt = 0; |
|
|
lte_dev.reset_flag = DTU_CF_NO_NEED_RESET; |
|
|
lte_dev.reset_flag = DTU_CF_NO_NEED_RESET; |
|
|
|
|
|
|
|
|
#ifdef TRANSPARENT_MODE |
|
|
|
|
|
// Set_Tansparent_Mode(client);
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef EDU_TRAINING |
|
|
#ifdef EDU_TRAINING |
|
|
mavlink_message_t msg = {0}; |
|
|
mavlink_message_t msg = {0}; |
|
|
uint8_t mav_buf[MAVLINK_MAX_PACKET_LEN] = {0}; |
|
|
uint8_t mav_buf[MAVLINK_MAX_PACKET_LEN] = {0}; |
|
|
@ -492,9 +467,6 @@ void client_yield(CLte_dev_t *pLte_dev) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void client_task(void) { |
|
|
void client_task(void) { |
|
|
if (lte_dev.config_sta == false) { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
client_yield(<e_dev); |
|
|
client_yield(<e_dev); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|