forked from xuos/xiuos
fixed the bug of wifi test on nuttx and remove warning
This commit is contained in:
parent
48250b7285
commit
ecba6148cb
|
@ -139,9 +139,9 @@ int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const
|
||||||
|
|
||||||
abstime.tv_sec = timeout_s;
|
abstime.tv_sec = timeout_s;
|
||||||
|
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
agent->receive_mode = AT_MODE;
|
agent->receive_mode = AT_MODE;
|
||||||
|
|
||||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||||
agent->maintain_len = 0;
|
agent->maintain_len = 0;
|
||||||
|
|
||||||
|
@ -154,8 +154,8 @@ int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const
|
||||||
const char *cmd = NULL;
|
const char *cmd = NULL;
|
||||||
|
|
||||||
agent->reply = reply;
|
agent->reply = reply;
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
|
|
||||||
if(agent->reply != NULL) {
|
if(agent->reply != NULL) {
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
reply->reply_len = 0;
|
reply->reply_len = 0;
|
||||||
|
@ -230,7 +230,7 @@ char *GetReplyText(ATReplyType reply)
|
||||||
}
|
}
|
||||||
|
|
||||||
int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
||||||
{
|
{
|
||||||
if (!agent) {
|
if (!agent) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
||||||
}
|
}
|
||||||
|
|
||||||
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
||||||
{
|
{
|
||||||
if (!agent) {
|
if (!agent) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
int AtSetReplyCharNum(ATAgentType agent, unsigned int num)
|
int AtSetReplyCharNum(ATAgentType agent, unsigned int num)
|
||||||
{
|
{
|
||||||
if (!agent) {
|
if (!agent) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -292,18 +292,18 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||||
abstime.tv_sec = timeout_s;
|
abstime.tv_sec = timeout_s;
|
||||||
if(buffer_len > ENTM_RECV_MAX){
|
if(buffer_len > ENTM_RECV_MAX){
|
||||||
printf("read length more then max length[%d] Bytes",ENTM_RECV_MAX);
|
printf("read length more then max length[%d] Bytes",ENTM_RECV_MAX);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
agent->receive_mode = ENTM_MODE;
|
agent->receive_mode = ENTM_MODE;
|
||||||
agent->read_len = buffer_len;
|
agent->read_len = buffer_len;
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
//PrivTaskDelay(1000);
|
//PrivTaskDelay(1000);
|
||||||
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
|
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
|
||||||
printf("wait sem[%d] timeout\n",agent->entm_rx_notice);
|
printf("wait sem[%d] timeout\n",agent->entm_rx_notice);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
|
|
||||||
printf("EntmRecv once len %d.\n", agent->entm_recv_len);
|
printf("EntmRecv once len %d.\n", agent->entm_recv_len);
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||||
memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX);
|
memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX);
|
||||||
agent->entm_recv_len = 0;
|
agent->entm_recv_len = 0;
|
||||||
agent->read_len = 0;
|
agent->read_len = 0;
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
|
|
||||||
return buffer_len;
|
return buffer_len;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
char ch = 0, last_ch = 0;
|
char ch = 0, last_ch = 0;
|
||||||
bool is_full = false;
|
bool is_full = false;
|
||||||
|
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
|
|
||||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||||
agent->maintain_len = 0;
|
agent->maintain_len = 0;
|
||||||
|
@ -331,7 +331,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
memset(agent->entm_recv_buf, 0x00, 256);
|
memset(agent->entm_recv_buf, 0x00, 256);
|
||||||
agent->entm_recv_len = 0;
|
agent->entm_recv_len = 0;
|
||||||
|
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
PrivRead(agent->fd, &ch, 1);
|
PrivRead(agent->fd, &ch, 1);
|
||||||
|
@ -359,7 +359,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
} else {
|
} else {
|
||||||
printf("entm_recv_buf is_full ...\n");
|
printf("entm_recv_buf is_full ...\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (agent->receive_mode == AT_MODE) {
|
else if (agent->receive_mode == AT_MODE) {
|
||||||
if (read_len < agent->maintain_max) {
|
if (read_len < agent->maintain_max) {
|
||||||
if(ch != 0) { ///< if the char is null then do not save it to the buff
|
if(ch != 0) { ///< if the char is null then do not save it to the buff
|
||||||
|
@ -367,13 +367,14 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
read_len++;
|
read_len++;
|
||||||
agent->maintain_len = read_len;
|
agent->maintain_len = read_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("maintain_len is_full ...\n");
|
printf("maintain_len is_full %d ...\n", read_len);
|
||||||
is_full = true;
|
is_full = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((ch == '\n') && (last_ch == '\r') && (agent->reply_lr_end)) ||
|
if (((ch == '\n') && (agent->reply_lr_end)) ||
|
||||||
|
((ch == '\n') && (last_ch == '\r') && (agent->reply_lr_end)) ||
|
||||||
((ch == agent->reply_end_char) && (agent->reply_end_char) &&
|
((ch == agent->reply_end_char) && (agent->reply_end_char) &&
|
||||||
(last_ch == agent->reply_end_last_char) && (agent->reply_end_last_char)) ||
|
(last_ch == agent->reply_end_last_char) && (agent->reply_end_last_char)) ||
|
||||||
((read_len == agent->reply_char_num) && (agent->reply_char_num))) {
|
((read_len == agent->reply_char_num) && (agent->reply_char_num))) {
|
||||||
|
@ -384,7 +385,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("GetCompleteATReply done\n");
|
printf("GetCompleteATReply done\n");
|
||||||
agent->receive_mode = DEFAULT_MODE;
|
agent->receive_mode = DEFAULT_MODE;
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
|
@ -418,7 +419,7 @@ int DeleteATAgent(ATAgentType agent)
|
||||||
if(agent->at_handler > 0){
|
if(agent->at_handler > 0){
|
||||||
PrivTaskDelete(agent->at_handler, 0);
|
PrivTaskDelete(agent->at_handler, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->fd > 0) {
|
if (agent->fd > 0) {
|
||||||
printf("close agent fd = %d\n",agent->fd);
|
printf("close agent fd = %d\n",agent->fd);
|
||||||
PrivClose(agent->fd);
|
PrivClose(agent->fd);
|
||||||
|
@ -464,7 +465,7 @@ static void *ATAgentReceiveProcess(void *param)
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (GetCompleteATReply(agent) > 0) {
|
if (GetCompleteATReply(agent) > 0) {
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
if (agent->reply != NULL) {
|
if (agent->reply != NULL) {
|
||||||
ATReplyType reply = agent->reply;
|
ATReplyType reply = agent->reply;
|
||||||
|
|
||||||
|
@ -550,7 +551,7 @@ int InitATAgent(const char *agent_name, int agent_fd, uint32 maintain_max)
|
||||||
if (GetATAgent(agent_name) != NULL) {
|
if (GetATAgent(agent_name) != NULL) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (i < AT_AGENT_MAX && at_agent_table[i].fd > 0) {
|
while (i < AT_AGENT_MAX && at_agent_table[i].fd > 0) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,8 +99,8 @@ int AdapterWifiInit(void)
|
||||||
/******************wifi TEST*********************/
|
/******************wifi TEST*********************/
|
||||||
int AdapterWifiTest(void)
|
int AdapterWifiTest(void)
|
||||||
{
|
{
|
||||||
char cmd[64];
|
// char cmd[64];
|
||||||
int baud_rate = BAUD_RATE_57600;
|
// int baud_rate = BAUD_RATE_57600;
|
||||||
|
|
||||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ void AdapterWifiGetParam(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int AdapterWifiTest(int argc, char *argv[])
|
int AdapterWifiTestWithParam(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
|
|
||||||
struct WifiParam
|
struct WifiParam
|
||||||
{
|
{
|
||||||
uint8_t wifi_ssid[128];
|
char wifi_ssid[128];
|
||||||
uint8_t wifi_pwd[128];
|
char wifi_pwd[128];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ static int Esp07sWifiSetUp(struct Adapter *adapter)
|
||||||
|
|
||||||
result = GetReplyText(reply);
|
result = GetReplyText(reply);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
printf("%s %n get reply failed.\n",__func__,__LINE__);
|
printf("%s %d get reply failed.\n",__func__,__LINE__);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ static int Esp07sWifiNetstat(struct Adapter *adapter)
|
||||||
|
|
||||||
result = GetReplyText(reply);
|
result = GetReplyText(reply);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
printf("%s %n get reply failed.\n",__func__,__LINE__);
|
printf("%s %d get reply failed.\n",__func__,__LINE__);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,15 +47,17 @@ CONFIG_SYSTEM_NSH=y
|
||||||
CONFIG_DEV_GPIO=y
|
CONFIG_DEV_GPIO=y
|
||||||
CONFIG_READLINE_CMD_HISTORY=y
|
CONFIG_READLINE_CMD_HISTORY=y
|
||||||
CONFIG_READLINE_CMD_HISTORY_LEN=100
|
CONFIG_READLINE_CMD_HISTORY_LEN=100
|
||||||
|
|
||||||
CONFIG_READLINE_CMD_HISTORY_LINELEN=120
|
CONFIG_READLINE_CMD_HISTORY_LINELEN=120
|
||||||
CONFIG_READLINE_TABCOMPLETION=y
|
CONFIG_READLINE_TABCOMPLETION=y
|
||||||
CONFIG_FS_ROMFS=y
|
CONFIG_FS_ROMFS=y
|
||||||
CONFIG_NSH_ROMFSETC=y
|
CONFIG_NSH_ROMFSETC=y
|
||||||
CONFIG_NSH_ARCHROMFS=y
|
CONFIG_NSH_ARCHROMFS=y
|
||||||
CONFIG_BOARDCTL_RESET=y
|
CONFIG_BOARDCTL_RESET=y
|
||||||
CONFIG_CONNECTION_FRAMEWORK_DEBUG=y
|
|
||||||
CONFIG_CONNECTION_ADAPTER_WIFI=y
|
CONFIG_CONNECTION_ADAPTER_WIFI=y
|
||||||
CONFIG_ADAPTER_ESP07S_WIFI=y
|
CONFIG_ADAPTER_ESP07S_WIFI=y
|
||||||
CONFIG_ADAPTER_WIFI_ESP07S="esp07s_wifi"
|
CONFIG_ADAPTER_WIFI_ESP07S="esp07s_wifi"
|
||||||
CONFIG_ADAPTER_ESP07S_DRIVER="/dev/ttyS2"
|
CONFIG_ADAPTER_ESP07S_DRIVER="/dev/ttyS2"
|
||||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_SUPPORT_CONNECTION_FRAMEWORK=y
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue