forked from xuos/xiuos
Framework/connection/wifi verify
1.modify type definition in Mutex and Semaphore 2.modify the macro.
This commit is contained in:
parent
bf93a554ca
commit
50995f3c1f
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
static DoublelistType adapter_list;
|
static DoublelistType adapter_list;
|
||||||
|
|
||||||
static int adapter_list_lock;
|
static pthread_mutex_t adapter_list_lock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Init adapter framework
|
* @description: Init adapter framework
|
||||||
|
@ -481,6 +481,7 @@ int AdapterDeviceDisconnect(struct Adapter *adapter, unsigned char *priv_net_gro
|
||||||
*/
|
*/
|
||||||
int AdapterDeviceSetUp(struct Adapter *adapter)
|
int AdapterDeviceSetUp(struct Adapter *adapter)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!adapter)
|
if (!adapter)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -488,10 +489,10 @@ int AdapterDeviceSetUp(struct Adapter *adapter)
|
||||||
|
|
||||||
struct IpProtocolDone *ip_done = NULL;
|
struct IpProtocolDone *ip_done = NULL;
|
||||||
struct PrivProtocolDone *priv_done = NULL;
|
struct PrivProtocolDone *priv_done = NULL;
|
||||||
|
|
||||||
switch (adapter->net_protocol)
|
switch (adapter->net_protocol)
|
||||||
{
|
{
|
||||||
case PRIVATE_PROTOCOL:
|
case PRIVATE_PROTOCOL:
|
||||||
|
|
||||||
priv_done = (struct PrivProtocolDone *)adapter->done;
|
priv_done = (struct PrivProtocolDone *)adapter->done;
|
||||||
if (NULL == priv_done->setup)
|
if (NULL == priv_done->setup)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -515,6 +516,7 @@ int AdapterDeviceSetUp(struct Adapter *adapter)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
result = ip_done->setup(adapter);
|
result = ip_done->setup(adapter);
|
||||||
|
|
||||||
if (0 == result) {
|
if (0 == result) {
|
||||||
printf("Device %s setup success.\n", adapter->name);
|
printf("Device %s setup success.\n", adapter->name);
|
||||||
adapter->adapter_status = INSTALL;
|
adapter->adapter_status = INSTALL;
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#ifdef ADD_XIZI_FETURES
|
#ifdef ADD_XIZI_FETURES
|
||||||
# include <user_api.h>
|
# include <user_api.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ADD_RTTHREAD_FETURES
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
#define AT_CMD_MAX_LEN 128
|
#define AT_CMD_MAX_LEN 128
|
||||||
#define AT_AGENT_MAX 2
|
#define AT_AGENT_MAX 2
|
||||||
|
@ -300,7 +302,7 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||||
//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 -ERROR;
|
return -1;
|
||||||
}
|
}
|
||||||
PrivMutexObtain(&agent->lock);
|
PrivMutexObtain(&agent->lock);
|
||||||
|
|
||||||
|
@ -390,7 +392,7 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||||
agent->maintain_len = 0;
|
agent->maintain_len = 0;
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
return -ERROR;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("GetCompleteATReply done\n");
|
printf("GetCompleteATReply done\n");
|
||||||
|
@ -449,10 +451,10 @@ int DeleteATAgent(ATAgentType agent)
|
||||||
PrivSemaphoreDelete(&agent->entm_rx_notice);
|
PrivSemaphoreDelete(&agent->entm_rx_notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->rsp_sem) {
|
// if (agent->rsp_sem) {
|
||||||
printf("delete agent rsp_sem = %d\n",agent->rsp_sem);
|
// printf("delete agent rsp_sem = %d\n",agent->rsp_sem);
|
||||||
PrivSemaphoreDelete(&agent->rsp_sem);
|
// PrivSemaphoreDelete(&agent->rsp_sem);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (agent->maintain_buffer) {
|
if (agent->maintain_buffer) {
|
||||||
PrivFree(agent->maintain_buffer);
|
PrivFree(agent->maintain_buffer);
|
||||||
|
|
|
@ -42,7 +42,6 @@ struct ATReply
|
||||||
uint32 reply_len;
|
uint32 reply_len;
|
||||||
};
|
};
|
||||||
typedef struct ATReply *ATReplyType;
|
typedef struct ATReply *ATReplyType;
|
||||||
|
|
||||||
struct ATAgent
|
struct ATAgent
|
||||||
{
|
{
|
||||||
char agent_name[64];
|
char agent_name[64];
|
||||||
|
@ -56,7 +55,7 @@ struct ATAgent
|
||||||
#ifdef ADD_NUTTX_FETURES
|
#ifdef ADD_NUTTX_FETURES
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
#else
|
#else
|
||||||
int lock;
|
pthread_mutex_t lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ATReplyType reply;
|
ATReplyType reply;
|
||||||
|
@ -64,7 +63,33 @@ struct ATAgent
|
||||||
char reply_end_last_char;
|
char reply_end_last_char;
|
||||||
char reply_end_char;
|
char reply_end_char;
|
||||||
uint32 reply_char_num;
|
uint32 reply_char_num;
|
||||||
int rsp_sem;
|
sem_t rsp_sem;
|
||||||
|
|
||||||
|
pthread_t at_handler;
|
||||||
|
|
||||||
|
#define ENTM_RECV_MAX 256
|
||||||
|
char entm_recv_buf[ENTM_RECV_MAX];
|
||||||
|
uint32 entm_recv_len;
|
||||||
|
enum ReceiveMode receive_mode;
|
||||||
|
int entm_rx_notice;
|
||||||
|
};
|
||||||
|
typedef struct ATAgent *ATAgentType;
|
||||||
|
|
||||||
|
int EntmSend(ATAgentType agent, const char *data, int len);
|
||||||
|
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s);
|
||||||
|
char *GetReplyText(ATReplyType reply);
|
||||||
|
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch);
|
||||||
|
int AtSetReplyCharNum(ATAgentType agent, unsigned int num);
|
||||||
|
int AtSetReplyLrEnd(ATAgentType agent, char enable);
|
||||||
|
ATReplyType CreateATReply(uint32 reply_max_len);
|
||||||
|
unsigned int IpTint(char *ipstr);
|
||||||
|
void SwapStr(char *str, int begin, int end);
|
||||||
|
char* IpTstr(unsigned int ipint);
|
||||||
|
ATAgentType GetATAgent(const char *agent_name);
|
||||||
|
int InitATAgent(const char *agent_name, int fd, uint32 maintain_max);
|
||||||
|
int DeleteATAgent(ATAgentType agent);
|
||||||
|
int ParseATReply(char* str, const char *format, ...);
|
||||||
|
void DeleteATReply(ATReplyType reply);
|
||||||
|
|
||||||
pthread_t at_handler;
|
pthread_t at_handler;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue