forked from xuos/xiuos
1、repair the agent null char parase problem;2、repair the zigbee open failed problem
This commit is contained in:
parent
cd13e10f58
commit
31c536ef88
|
@ -33,7 +33,7 @@
|
||||||
#define AT_CMD_MAX_LEN 128
|
#define AT_CMD_MAX_LEN 128
|
||||||
#define AT_AGENT_MAX 2
|
#define AT_AGENT_MAX 2
|
||||||
static char send_buf[AT_CMD_MAX_LEN];
|
static char send_buf[AT_CMD_MAX_LEN];
|
||||||
static uint32 last_cmd_len = 0;
|
static uint32_t last_cmd_len = 0;
|
||||||
|
|
||||||
static struct ATAgent at_agent_table[AT_AGENT_MAX] = {0};
|
static struct ATAgent at_agent_table[AT_AGENT_MAX] = {0};
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ void ATSprintf(int fd, const char *format, va_list params)
|
||||||
PrivWrite(fd, send_buf, last_cmd_len);
|
PrivWrite(fd, send_buf, last_cmd_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...)
|
int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const char *cmd_expr, ...)
|
||||||
{
|
{
|
||||||
if (agent == NULL) {
|
if (agent == NULL) {
|
||||||
printf("ATAgent is null");
|
printf("ATAgent is null");
|
||||||
|
@ -147,8 +147,8 @@ int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const ch
|
||||||
agent->entm_recv_len = 0;
|
agent->entm_recv_len = 0;
|
||||||
|
|
||||||
va_list params;
|
va_list params;
|
||||||
uint32 cmd_size = 0;
|
uint32_t cmd_size = 0;
|
||||||
uint32 result = 0;
|
uint32_t result = 0;
|
||||||
const char *cmd = NULL;
|
const char *cmd = NULL;
|
||||||
|
|
||||||
agent->reply = reply;
|
agent->reply = reply;
|
||||||
|
@ -317,7 +317,7 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||||
|
|
||||||
static int GetCompleteATReply(ATAgentType agent)
|
static int GetCompleteATReply(ATAgentType agent)
|
||||||
{
|
{
|
||||||
uint32 read_len = 0;
|
uint32_t read_len = 0;
|
||||||
char ch = 0, last_ch = 0;
|
char ch = 0, last_ch = 0;
|
||||||
bool is_full = false;
|
bool is_full = false;
|
||||||
|
|
||||||
|
@ -335,7 +335,9 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
{
|
{
|
||||||
PrivRead(agent->fd, &ch, 1);
|
PrivRead(agent->fd, &ch, 1);
|
||||||
#ifdef CONNECTION_FRAMEWORK_DEBUG
|
#ifdef CONNECTION_FRAMEWORK_DEBUG
|
||||||
printf(" %c (0x%x)\n", ch, ch);
|
if(ch != 0){
|
||||||
|
printf(" %c (0x%x)\n", ch, ch);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
|
@ -365,9 +367,13 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
{
|
{
|
||||||
if (read_len < agent->maintain_max)
|
if (read_len < agent->maintain_max)
|
||||||
{
|
{
|
||||||
agent->maintain_buffer[read_len] = ch;
|
if(ch != 0) ///< if the char is null then do not save it to the buff
|
||||||
read_len++;
|
{
|
||||||
agent->maintain_len = read_len;
|
agent->maintain_buffer[read_len] = ch;
|
||||||
|
read_len++;
|
||||||
|
agent->maintain_len = read_len;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("maintain_len is_full ...\n");
|
printf("maintain_len is_full ...\n");
|
||||||
is_full = true;
|
is_full = true;
|
||||||
|
|
|
@ -87,7 +87,7 @@ int InitATAgent(const char *agent_name, int fd, uint32 maintain_max);
|
||||||
int DeleteATAgent(ATAgentType agent);
|
int DeleteATAgent(ATAgentType agent);
|
||||||
int ParseATReply(char* str, const char *format, ...);
|
int ParseATReply(char* str, const char *format, ...);
|
||||||
void DeleteATReply(ATReplyType reply);
|
void DeleteATReply(ATReplyType reply);
|
||||||
int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...);
|
int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const char *cmd_expr, ...);
|
||||||
int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check);
|
int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -123,15 +123,22 @@ static int E18UartOpen(struct Adapter *adapter)
|
||||||
static int E18NetworkModeConfig(struct Adapter *adapter)
|
static int E18NetworkModeConfig(struct Adapter *adapter)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int mode = -1;
|
||||||
|
|
||||||
if (NULL == adapter) {
|
if (NULL == adapter) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_hex2at, "+OK");
|
mode = E18HardwareModeGet();
|
||||||
if(ret < 0) {
|
if(E18_AS_HEX_MODE == mode)
|
||||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,cmd_hex2at);
|
{
|
||||||
ret = -1;
|
ret = AtCmdConfigAndCheck(adapter->agent, cmd_hex2at, "+OK");
|
||||||
goto out;
|
if(ret < 0) {
|
||||||
|
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,cmd_hex2at);
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (adapter->info->work_mode)
|
switch (adapter->info->work_mode)
|
||||||
{
|
{
|
||||||
|
@ -168,7 +175,10 @@ static int E18NetworkModeConfig(struct Adapter *adapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
if(E18_AS_HEX_MODE == mode){
|
||||||
|
AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,6 +251,7 @@ static int E18Open(struct Adapter *adapter)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int try_times = 5;
|
int try_times = 5;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
if (NULL == adapter) {
|
if (NULL == adapter) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -267,9 +278,12 @@ static int E18Open(struct Adapter *adapter)
|
||||||
try_again:
|
try_again:
|
||||||
while(try_times--){
|
while(try_times--){
|
||||||
ret = E18NetRoleConfig(adapter);
|
ret = E18NetRoleConfig(adapter);
|
||||||
|
count++;
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
printf("E18NetRoleConfig failed [%d] times.\n",try_times);
|
printf("E18NetRoleConfig failed [%d] times.\n",count);
|
||||||
goto try_again;
|
continue;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue