forked from xuos/xiuos
support adapter_ethernet and hfa21 device
This commit is contained in:
@@ -117,10 +117,10 @@ int ParseATReply(char *str, const char *format, ...)
|
||||
return counts;
|
||||
}
|
||||
|
||||
uint32 ATSprintf(int fd, const char *format, va_list params)
|
||||
void ATSprintf(int fd, const char *format, va_list params)
|
||||
{
|
||||
last_cmd_len = vsnprintf(send_buf, sizeof(send_buf), format, params);
|
||||
printf("ATSprintf send %s len %u\n",send_buf, last_cmd_len);
|
||||
printf("AT send %s len %u\n",send_buf, last_cmd_len);
|
||||
PrivWrite(fd, send_buf, last_cmd_len);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const ch
|
||||
{
|
||||
if (agent == NULL) {
|
||||
printf("ATAgent is null");
|
||||
return -ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct timespec abstime;
|
||||
@@ -145,7 +145,7 @@ int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const ch
|
||||
|
||||
va_list params;
|
||||
uint32 cmd_size = 0;
|
||||
uint32 result = EOK;
|
||||
uint32 result = 0;
|
||||
const char *cmd = NULL;
|
||||
PrivMutexObtain(&agent->lock);
|
||||
|
||||
@@ -156,7 +156,7 @@ int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const ch
|
||||
va_start(params, cmd_expr);
|
||||
ATSprintf(agent->fd, cmd_expr, params);
|
||||
va_end(params);
|
||||
if (PrivSemaphoreObtainWait(&agent->rsp_sem, &abstime) != EOK) {
|
||||
if (PrivSemaphoreObtainWait(&agent->rsp_sem, &abstime) != 0) {
|
||||
result = -ETIMEOUT;
|
||||
goto __out;
|
||||
}
|
||||
@@ -220,35 +220,35 @@ char *GetReplyText(ATReplyType reply)
|
||||
int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
||||
{
|
||||
if (!agent) {
|
||||
return -ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
agent->reply_lr_end = enable;
|
||||
|
||||
return EOK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
||||
{
|
||||
if (!agent) {
|
||||
return -ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
agent->reply_end_last_char = last_ch;
|
||||
agent->reply_end_char = end_ch;
|
||||
|
||||
return EOK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AtSetReplyCharNum(ATAgentType agent, unsigned int num)
|
||||
{
|
||||
if (!agent) {
|
||||
return -ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
agent->reply_char_num = num;
|
||||
|
||||
return EOK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EntmSend(ATAgentType agent, const char *data, int len)
|
||||
@@ -262,7 +262,7 @@ int EntmSend(ATAgentType agent, const char *data, int len)
|
||||
|
||||
PrivWrite(agent->fd, send_buf, len + 2);
|
||||
|
||||
return EOK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||
@@ -276,13 +276,13 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||
PrivTaskDelay(1000);
|
||||
|
||||
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
|
||||
return -ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
PrivMutexObtain(&agent->lock);
|
||||
|
||||
if (buffer_len < agent->entm_recv_len) {
|
||||
return -ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("EntmRecv once len %u.\n", agent->entm_recv_len);
|
||||
@@ -295,7 +295,7 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
|
||||
return EOK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int GetCompleteATReply(ATAgentType agent)
|
||||
@@ -347,7 +347,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||
printf("read line failed. The line data length is out of buffer size(%d)!", agent->maintain_max);
|
||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||
agent->maintain_len = 0;
|
||||
return -ERROR;
|
||||
return -1;
|
||||
}
|
||||
printf("GetCompleteATReply done\n");
|
||||
break;
|
||||
@@ -371,7 +371,6 @@ ATAgentType GetATAgent(const char *agent_name)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int DeleteATAgent(ATAgentType agent)
|
||||
{
|
||||
if (agent->lock) {
|
||||
@@ -426,13 +425,12 @@ static void *ATAgentReceiveProcess(void *param)
|
||||
|
||||
static int ATAgentInit(ATAgentType agent)
|
||||
{
|
||||
int result = EOK;
|
||||
UtaskType at_utask;
|
||||
int result = 0;
|
||||
|
||||
agent->maintain_len = 0;
|
||||
agent->maintain_buffer = (char *)PrivMalloc(agent->maintain_max);
|
||||
|
||||
if (agent->maintain_buffer == NONE) {
|
||||
if (agent->maintain_buffer == NULL) {
|
||||
printf("ATAgentInit malloc maintain_buffer error\n");
|
||||
goto __out;
|
||||
}
|
||||
@@ -468,7 +466,7 @@ static int ATAgentInit(ATAgentType agent)
|
||||
|
||||
__out:
|
||||
DeleteATAgent(agent);
|
||||
result = -ERROR;
|
||||
result = -1;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -476,9 +474,9 @@ __out:
|
||||
int InitATAgent(const char *agent_name, int agent_fd, uint32 maintain_max)
|
||||
{
|
||||
int i = 0;
|
||||
int result = EOK;
|
||||
int open_result = EOK;
|
||||
struct ATAgent *agent = NONE;
|
||||
int result = 0;
|
||||
int open_result = 0;
|
||||
struct ATAgent *agent = NULL;
|
||||
|
||||
if (GetATAgent(agent_name) != NULL) {
|
||||
return result;
|
||||
@@ -490,7 +488,7 @@ int InitATAgent(const char *agent_name, int agent_fd, uint32 maintain_max)
|
||||
|
||||
if (i >= AT_AGENT_MAX) {
|
||||
printf("agent buffer(%d) is full.", AT_AGENT_MAX);
|
||||
result = -ERROR;
|
||||
result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -503,7 +501,7 @@ int InitATAgent(const char *agent_name, int agent_fd, uint32 maintain_max)
|
||||
agent->maintain_max = maintain_max;
|
||||
|
||||
result = ATAgentInit(agent);
|
||||
if (result == EOK) {
|
||||
if (result == 0) {
|
||||
PrivTaskStartup(&agent->at_handler);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user