Framework/connection/wifi verify

1.modify type definition in Mutex and Semaphore
2.modify the macro.
This commit is contained in:
yl1185 2022-04-24 14:57:06 +08:00
parent 63a32be4d6
commit ceafa6cfdc
3 changed files with 21 additions and 16 deletions

View File

@ -22,7 +22,7 @@
static DoublelistType adapter_list;
static int adapter_list_lock;
static pthread_mutex_t adapter_list_lock;
/**
* @description: Init adapter framework
@ -481,6 +481,7 @@ int AdapterDeviceDisconnect(struct Adapter *adapter, unsigned char *priv_net_gro
*/
int AdapterDeviceSetUp(struct Adapter *adapter)
{
if (!adapter)
return -1;
@ -488,10 +489,10 @@ int AdapterDeviceSetUp(struct Adapter *adapter)
struct IpProtocolDone *ip_done = NULL;
struct PrivProtocolDone *priv_done = NULL;
switch (adapter->net_protocol)
{
case PRIVATE_PROTOCOL:
priv_done = (struct PrivProtocolDone *)adapter->done;
if (NULL == priv_done->setup)
return 0;
@ -515,6 +516,7 @@ int AdapterDeviceSetUp(struct Adapter *adapter)
return 0;
result = ip_done->setup(adapter);
if (0 == result) {
printf("Device %s setup success.\n", adapter->name);
adapter->adapter_status = INSTALL;

View File

@ -29,6 +29,10 @@
#ifdef ADD_XIZI_FETURES
# include <user_api.h>
#endif
#ifdef ADD_RTTHREAD_FETURES
#include <rtthread.h>
#endif
#define AT_CMD_MAX_LEN 128
#define AT_AGENT_MAX 2
@ -139,7 +143,7 @@ int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const ch
PrivMutexObtain(&agent->lock);
agent->receive_mode = AT_MODE;
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
agent->maintain_len = 0;
@ -298,7 +302,7 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
// PrivTaskDelay(1000);
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
printf("wait sem[%d] timeout\n",agent->entm_rx_notice);
return -ERROR;
return -1;
}
PrivMutexObtain(&agent->lock);
@ -382,7 +386,7 @@ static int GetCompleteATReply(ATAgentType agent)
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
agent->maintain_len = 0;
PrivMutexAbandon(&agent->lock);
return -ERROR;
return -1;
}
printf("GetCompleteATReply done\n");
@ -424,20 +428,20 @@ int DeleteATAgent(ATAgentType agent)
PrivClose(agent->fd);
}
if (agent->lock) {
printf("delete agent lock = %d\n",agent->lock);
PrivMutexDelete(&agent->lock);
}
// if (agent->lock) {
// printf("delete agent lock = %d\n",agent->lock);
// PrivMutexDelete(&agent->lock);
// }
if (agent->entm_rx_notice) {
printf("delete agent entm_rx_notice = %d\n",agent->entm_rx_notice);
PrivSemaphoreDelete(&agent->entm_rx_notice);
}
if (agent->rsp_sem) {
printf("delete agent rsp_sem = %d\n",agent->rsp_sem);
PrivSemaphoreDelete(&agent->rsp_sem);
}
// if (agent->rsp_sem) {
// printf("delete agent rsp_sem = %d\n",agent->rsp_sem);
// PrivSemaphoreDelete(&agent->rsp_sem);
// }
if (agent->maintain_buffer) {
PrivFree(agent->maintain_buffer);

View File

@ -42,7 +42,6 @@ struct ATReply
uint32 reply_len;
};
typedef struct ATReply *ATReplyType;
struct ATAgent
{
char agent_name[64];
@ -53,14 +52,14 @@ struct ATAgent
uint32 maintain_len;
uint32 maintain_max;
int lock;
pthread_mutex_t lock;
ATReplyType reply;
char reply_lr_end;
char reply_end_last_char;
char reply_end_char;
uint32 reply_char_num;
int rsp_sem;
sem_t rsp_sem;
pthread_t at_handler;