transform connection framework api from user-api to priv-api
This commit is contained in:
parent
4a07f534d8
commit
dd5a68916e
|
@ -17,6 +17,7 @@ extern int SensorFrameworkInit(void);
|
||||||
extern int AdapterFrameworkInit(void);
|
extern int AdapterFrameworkInit(void);
|
||||||
|
|
||||||
extern int Adapter4GInit(void);
|
extern int Adapter4GInit(void);
|
||||||
|
extern int AdapterBlueToothInit(void);
|
||||||
extern int AdapterWifiInit(void);
|
extern int AdapterWifiInit(void);
|
||||||
|
|
||||||
extern int D124VoiceInit(void);
|
extern int D124VoiceInit(void);
|
||||||
|
@ -89,10 +90,13 @@ static struct InitDesc sensor_desc[] =
|
||||||
|
|
||||||
static struct InitDesc connection_desc[] =
|
static struct InitDesc connection_desc[] =
|
||||||
{
|
{
|
||||||
#ifdef ADAPTER_4G
|
#ifdef CONNECTION_ADAPTER_4G
|
||||||
{ "4G adpter", Adapter4GInit},
|
{ "4G adpter", Adapter4GInit},
|
||||||
#endif
|
#endif
|
||||||
#ifdef ADAPTER_WIFI
|
#ifdef CONNECTION_ADAPTER_BLUETOOTH
|
||||||
|
{ "BlueTooth adpter", AdapterBlueToothInit},
|
||||||
|
#endif
|
||||||
|
#ifdef CONNECTION_ADAPTER_WIFI
|
||||||
{ "Wifi adpter", AdapterWifiInit},
|
{ "Wifi adpter", AdapterWifiInit},
|
||||||
#endif
|
#endif
|
||||||
{ "NULL", NULL },
|
{ "NULL", NULL },
|
||||||
|
|
|
@ -253,11 +253,11 @@ AdapterProductInfoType Ec200tAttach(struct Adapter *adapter)
|
||||||
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
||||||
if (!product_info) {
|
if (!product_info) {
|
||||||
printf("Ec200tAttach malloc product_info error\n");
|
printf("Ec200tAttach malloc product_info error\n");
|
||||||
free(product_info);
|
PrivFree(product_info);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
product_info->model_name = ADAPTER_4G_EC200T;
|
strcpy(product_info->model_name, ADAPTER_4G_EC200T);
|
||||||
|
|
||||||
product_info->model_done = (void *)&ec200t_done;
|
product_info->model_done = (void *)&ec200t_done;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
config ADAPTER_4G
|
config ADAPTER_EC200T
|
||||||
bool "Using 4G adapter function"
|
bool "Using 4G adapter device EC200T"
|
||||||
default y
|
default y
|
||||||
|
|
||||||
if ADAPTER_4G
|
if ADAPTER_EC200T
|
||||||
config ADAPTER_EC200T
|
source "$APP_DIR/Framework/connection/4G/EC200T/Kconfig"
|
||||||
bool "Using 4G adapter device EC200T"
|
endif
|
||||||
default y
|
|
||||||
|
|
||||||
if ADAPTER_EC200T
|
|
||||||
source "$APP_DIR/Framework/connection/4G/EC200T/Kconfig"
|
|
||||||
endif
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
SRC_FILES := adapter.c adapter_agent.c
|
SRC_FILES := adapter.c adapter_agent.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_LORA),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_LORA),y)
|
||||||
SRC_DIR += lora
|
SRC_DIR += lora
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_4G),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y)
|
||||||
SRC_DIR += 4G
|
SRC_DIR += 4G
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_NB),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_NB),y)
|
||||||
SRC_DIR += nbiot
|
SRC_DIR += nbiot
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_WIFI),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_WIFI),y)
|
||||||
SRC_DIR += wifi
|
SRC_DIR += wifi
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_ETHERNET),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_ETHERNET),y)
|
||||||
SRC_DIR += ethernet
|
SRC_DIR += ethernet
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_BLUETOOTH),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_BLUETOOTH),y)
|
||||||
SRC_DIR += bluetooth
|
SRC_DIR += bluetooth
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_ZIGBEE),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_ZIGBEE),y)
|
||||||
SRC_DIR += zigbee
|
SRC_DIR += zigbee
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_5G),y)
|
ifeq ($(CONFIG_CONNECTION_ADAPTER_5G),y)
|
||||||
SRC_DIR += 5G
|
SRC_DIR += 5G
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -39,15 +39,6 @@ extern "C" {
|
||||||
#define ADAPTER_LWIP_OPERATION 2
|
#define ADAPTER_LWIP_OPERATION 2
|
||||||
#define ADAPTER_RAWIP_OPERATION 3
|
#define ADAPTER_RAWIP_OPERATION 3
|
||||||
|
|
||||||
#define ADAPTER_LORA_FUNC ((uint32_t)(1 << ATAPTER_LORA))
|
|
||||||
#define ADAPTER_4G_FUNC ((uint32_t)(1 << ADAPTER_4G))
|
|
||||||
#define ADAPTER_NBIOT_FUNC ((uint32_t)(1 << ADAPTER_NBIOT))
|
|
||||||
#define ADAPTER_WIFI_FUNC ((uint32_t)(1 << ADAPTER_WIFI))
|
|
||||||
#define ADAPTER_ETHERNET_FUNC ((uint32_t)(1 << ADAPTER_ETHERNET))
|
|
||||||
#define ADAPTER_BLUETOOTH_FUNC ((uint32_t)(1 << ADAPTER_BLUETOOTH))
|
|
||||||
#define ADAPTER_ZIGBEE_FUNC ((uint32_t)(1 << ADAPTER_ZIGBEE))
|
|
||||||
#define ADAPTER_5G_FUNC ((uint32_t)(1 << ADAPTER_5G))
|
|
||||||
|
|
||||||
#ifdef CONNECTION_FRAMEWORK_DEBUG
|
#ifdef CONNECTION_FRAMEWORK_DEBUG
|
||||||
#define ADAPTER_DEBUG printf
|
#define ADAPTER_DEBUG printf
|
||||||
#else
|
#else
|
||||||
|
@ -110,8 +101,8 @@ enum IpType
|
||||||
struct AdapterProductInfo
|
struct AdapterProductInfo
|
||||||
{
|
{
|
||||||
uint32_t functions;
|
uint32_t functions;
|
||||||
const char *vendor_name;
|
char vendor_name[NAME_NUM_MAX];
|
||||||
const char *model_name;
|
char model_name[NAME_NUM_MAX];
|
||||||
|
|
||||||
void *model_done;
|
void *model_done;
|
||||||
};
|
};
|
||||||
|
@ -154,7 +145,7 @@ struct PrivProtocolDone
|
||||||
|
|
||||||
struct Adapter
|
struct Adapter
|
||||||
{
|
{
|
||||||
char *name;
|
char name[NAME_NUM_MAX];
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
int product_info_flag;
|
int product_info_flag;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <user_api.h>
|
#include <user_api.h>
|
||||||
#include <bus.h>
|
|
||||||
|
|
||||||
#define AT_CMD_MAX_LEN 128
|
#define AT_CMD_MAX_LEN 128
|
||||||
#define AT_AGENT_MAX 2
|
#define AT_AGENT_MAX 2
|
||||||
|
@ -36,12 +35,13 @@ static uint32 last_cmd_len = 0;
|
||||||
|
|
||||||
static struct ATAgent at_agent_table[AT_AGENT_MAX] = {0};
|
static struct ATAgent at_agent_table[AT_AGENT_MAX] = {0};
|
||||||
|
|
||||||
uint IpTint(char *ipstr){
|
unsigned int IpTint(char *ipstr)
|
||||||
|
{
|
||||||
if (ipstr == NULL)
|
if (ipstr == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char *token;
|
char *token;
|
||||||
uint i = 3, total = 0, cur;
|
unsigned int i = 3, total = 0, cur;
|
||||||
|
|
||||||
token = strtok(ipstr, ".");
|
token = strtok(ipstr, ".");
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void SwapStr(char *str, int begin, int end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *IpTstr(uint ipint)
|
char *IpTstr(unsigned int ipint)
|
||||||
{
|
{
|
||||||
int LEN = 16;
|
int LEN = 16;
|
||||||
char *new = (char *)malloc(LEN);
|
char *new = (char *)malloc(LEN);
|
||||||
|
@ -124,13 +124,17 @@ uint32 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, ATReplyType reply, const char *cmd_expr, ...)
|
int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...)
|
||||||
{
|
{
|
||||||
if (agent == NULL){
|
if (agent == NULL){
|
||||||
printf("ATAgent is null");
|
printf("ATAgent is null");
|
||||||
return -ERROR;
|
return -ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct timespec abstime;
|
||||||
|
|
||||||
|
abstime.tv_sec = timeout_s;
|
||||||
|
|
||||||
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);
|
||||||
|
@ -152,7 +156,7 @@ int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char
|
||||||
va_start(params, cmd_expr);
|
va_start(params, cmd_expr);
|
||||||
ATSprintf(agent->fd, cmd_expr, params);
|
ATSprintf(agent->fd, cmd_expr, params);
|
||||||
va_end(params);
|
va_end(params);
|
||||||
if (UserSemaphoreObtain(agent->rsp_sem, timeout) != EOK){
|
if (PrivSemaphoreObtainWait(&agent->rsp_sem, &abstime) != EOK){
|
||||||
result = -ETIMEOUT;
|
result = -ETIMEOUT;
|
||||||
goto __out;
|
goto __out;
|
||||||
}
|
}
|
||||||
|
@ -185,21 +189,23 @@ int EntmSend(ATAgentType agent, const char *data, int len)
|
||||||
memcpy(send_buf, data, len);
|
memcpy(send_buf, data, len);
|
||||||
memcpy(send_buf + len, "!@", 2);
|
memcpy(send_buf + len, "!@", 2);
|
||||||
|
|
||||||
write(agent->fd, send_buf, len + 2);
|
PrivWrite(agent->fd, send_buf, len + 2);
|
||||||
|
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int time_out)
|
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||||
{
|
{
|
||||||
UserTaskDelay(1000);
|
struct timespec abstime;
|
||||||
|
|
||||||
|
abstime.tv_sec = timeout_s;
|
||||||
|
|
||||||
|
PrivTaskDelay(1000);
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
UserSemaphoreSetValue(agent->entm_rx_notice, 0);
|
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)){
|
||||||
|
|
||||||
if (UserSemaphoreObtain(agent->entm_rx_notice, time_out)){
|
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,16 +231,17 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
agent->maintain_len = 0;
|
agent->maintain_len = 0;
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
read(agent->fd, &ch, 1);
|
PrivRead(agent->fd, &ch, 1);
|
||||||
|
|
||||||
printf(" %c(0x%x)\n", ch, ch);
|
printf(" %c(0x%x)\n", ch, ch);
|
||||||
|
|
||||||
if (agent->receive_mode == ENTM_MODE){
|
if (agent->receive_mode == ENTM_MODE){
|
||||||
if (agent->entm_recv_len < ENTM_RECV_MAX){
|
if (agent->entm_recv_len < ENTM_RECV_MAX){
|
||||||
agent->entm_recv_buf[agent->entm_recv_len++] = ch;
|
agent->entm_recv_buf[agent->entm_recv_len] = ch;
|
||||||
|
agent->entm_recv_len++;
|
||||||
|
|
||||||
if (last_ch == '!' && ch == '@'){
|
if (last_ch == '!' && ch == '@'){
|
||||||
UserSemaphoreAbandon(agent->entm_rx_notice);
|
PrivSemaphoreAbandon(&agent->entm_rx_notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
last_ch = ch;
|
last_ch = ch;
|
||||||
|
@ -245,7 +252,8 @@ static int GetCompleteATReply(ATAgentType agent)
|
||||||
}
|
}
|
||||||
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){
|
||||||
agent->maintain_buffer[read_len++] = ch;
|
agent->maintain_buffer[read_len] = ch;
|
||||||
|
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 ...\n");
|
||||||
|
@ -289,25 +297,25 @@ static int DeleteATAgent(ATAgentType agent)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->entm_rx_notice){
|
if (agent->entm_rx_notice){
|
||||||
UserSemaphoreDelete(agent->entm_rx_notice);
|
PrivSemaphoreDelete(&agent->entm_rx_notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->fd > 0){
|
if (agent->fd > 0){
|
||||||
close(agent->fd);
|
PrivClose(agent->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->rsp_sem){
|
if (agent->rsp_sem){
|
||||||
UserSemaphoreDelete(agent->rsp_sem);
|
PrivSemaphoreDelete(&agent->rsp_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent->maintain_buffer){
|
if (agent->maintain_buffer){
|
||||||
free(agent->maintain_buffer);
|
PrivFree(agent->maintain_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(agent, 0x00, sizeof(struct ATAgent));
|
memset(agent, 0x00, sizeof(struct ATAgent));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ATAgentReceiveProcess(void *param)
|
static void *ATAgentReceiveProcess(void *param)
|
||||||
{
|
{
|
||||||
ATAgentType agent = (ATAgentType)param;
|
ATAgentType agent = (ATAgentType)param;
|
||||||
const struct at_urc *urc;
|
const struct at_urc *urc;
|
||||||
|
@ -329,7 +337,7 @@ static void ATAgentReceiveProcess(void *param)
|
||||||
}
|
}
|
||||||
|
|
||||||
agent->reply = NULL;
|
agent->reply = NULL;
|
||||||
UserSemaphoreAbandon(agent->rsp_sem);
|
PrivSemaphoreAbandon(&agent->rsp_sem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,56 +347,51 @@ static int ATAgentInit(ATAgentType agent)
|
||||||
{
|
{
|
||||||
int result = EOK;
|
int result = EOK;
|
||||||
UtaskType at_utask;
|
UtaskType at_utask;
|
||||||
do
|
|
||||||
{
|
|
||||||
agent->maintain_len = 0;
|
|
||||||
agent->maintain_buffer = (char *)malloc(agent->maintain_max);
|
|
||||||
|
|
||||||
if (agent->maintain_buffer == NONE){
|
agent->maintain_len = 0;
|
||||||
break;
|
agent->maintain_buffer = (char *)malloc(agent->maintain_max);
|
||||||
}
|
|
||||||
|
|
||||||
agent->entm_rx_notice = UserSemaphoreCreate(0);
|
if (agent->maintain_buffer == NONE){
|
||||||
if (agent->entm_rx_notice == 0){
|
printf("ATAgentInit malloc maintain_buffer error\n");
|
||||||
break;
|
goto __out;
|
||||||
}
|
}
|
||||||
|
|
||||||
agent->rsp_sem = UserSemaphoreCreate(0);
|
result = PrivSemaphoreCreate(&agent->entm_rx_notice, 0, 0);
|
||||||
if (agent->rsp_sem == 0){
|
if (result < 0){
|
||||||
break;
|
printf("ATAgentInit create entm sem error\n");
|
||||||
}
|
goto __out;
|
||||||
if(PrivMutexCreate(&agent->lock, 0) < 0) {
|
}
|
||||||
printf("AdapterFrameworkInit mutex create failed.\n");
|
|
||||||
}
|
|
||||||
if (agent->lock == 0){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
agent->receive_mode = ENTM_MODE;
|
result = PrivSemaphoreCreate(&agent->rsp_sem, 0, 0);
|
||||||
|
if (result < 0){
|
||||||
|
printf("ATAgentInit create rsp sem error\n");
|
||||||
|
goto __out;
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(at_utask.name, "recv_task", strlen("recv_task"));
|
if(PrivMutexCreate(&agent->lock, 0) < 0) {
|
||||||
at_utask.func_entry = ATAgentReceiveProcess;
|
printf("AdapterFrameworkInit mutex create failed.\n");
|
||||||
at_utask.func_param = agent;
|
goto __out;
|
||||||
at_utask.stack_size = 1024;
|
}
|
||||||
at_utask.prio = 18;
|
|
||||||
|
|
||||||
agent->at_handler = UserTaskCreate(at_utask);
|
agent->receive_mode = ENTM_MODE;
|
||||||
|
|
||||||
// struct SerialDataCfg data_cfg;
|
pthread_attr_t attr;
|
||||||
// memset(&data_cfg, 0, sizeof(struct SerialDataCfg));
|
attr.schedparam.sched_priority = 18;
|
||||||
// data_cfg.serial_baud_rate = 57600;
|
attr.stacksize = 1024;
|
||||||
// ioctl(agent->fd, OPE_INT, &data_cfg);
|
|
||||||
|
|
||||||
if (agent->at_handler == 0) {
|
PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, agent);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = EOK;
|
// struct SerialDataCfg data_cfg;
|
||||||
return result;
|
// memset(&data_cfg, 0, sizeof(struct SerialDataCfg));
|
||||||
} while (1);
|
// data_cfg.serial_baud_rate = 57600;
|
||||||
|
// ioctl(agent->fd, OPE_INT, &data_cfg);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
__out:
|
||||||
DeleteATAgent(agent);
|
DeleteATAgent(agent);
|
||||||
result = -ERROR;
|
result = -ERROR;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +427,7 @@ int InitATAgent(const char *agent_name, int agent_fd, uint32 maintain_max)
|
||||||
result = ATAgentInit(agent);
|
result = ATAgentInit(agent);
|
||||||
if (result == EOK)
|
if (result == EOK)
|
||||||
{
|
{
|
||||||
UserTaskStartup(agent->at_handler);
|
PrivTaskStartup(&agent->at_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -445,7 +448,7 @@ ATReplyType CreateATReply(uint32 reply_max_len)
|
||||||
reply->reply_buffer = (char *)malloc(reply_max_len);
|
reply->reply_buffer = (char *)malloc(reply_max_len);
|
||||||
if (reply->reply_buffer == NULL){
|
if (reply->reply_buffer == NULL){
|
||||||
printf("no more memory\n");
|
printf("no more memory\n");
|
||||||
free(reply);
|
PrivFree(reply);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,13 +459,13 @@ void DeleteATReply(ATReplyType reply)
|
||||||
{
|
{
|
||||||
if (reply){
|
if (reply){
|
||||||
if (reply->reply_buffer){
|
if (reply->reply_buffer){
|
||||||
free(reply->reply_buffer);
|
PrivFree(reply->reply_buffer);
|
||||||
reply->reply_buffer = NULL;
|
reply->reply_buffer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply){
|
if (reply){
|
||||||
free(reply);
|
PrivFree(reply);
|
||||||
reply = NULL;
|
reply = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct ATAgent
|
||||||
ATReplyType reply;
|
ATReplyType reply;
|
||||||
int rsp_sem;
|
int rsp_sem;
|
||||||
|
|
||||||
int32 at_handler;
|
pthread_t at_handler;
|
||||||
|
|
||||||
#define ENTM_RECV_MAX 256
|
#define ENTM_RECV_MAX 256
|
||||||
char entm_recv_buf[ENTM_RECV_MAX];
|
char entm_recv_buf[ENTM_RECV_MAX];
|
||||||
|
@ -65,7 +65,7 @@ struct ATAgent
|
||||||
typedef struct ATAgent *ATAgentType;
|
typedef struct ATAgent *ATAgentType;
|
||||||
|
|
||||||
int EntmSend(ATAgentType agent, const char *data, int len);
|
int EntmSend(ATAgentType agent, const char *data, int len);
|
||||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int time_out);
|
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s);
|
||||||
char *GetReplyText(ATReplyType reply);
|
char *GetReplyText(ATReplyType reply);
|
||||||
ATReplyType CreateATReply(uint32 reply_max_len);
|
ATReplyType CreateATReply(uint32 reply_max_len);
|
||||||
uint IpTint(char *ipstr);
|
uint IpTint(char *ipstr);
|
||||||
|
@ -75,7 +75,7 @@ ATAgentType GetATAgent(const char *agent_name);
|
||||||
int InitATAgent(const char *agent_name, int fd, uint32 maintain_max);
|
int InitATAgent(const char *agent_name, int fd, uint32 maintain_max);
|
||||||
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, ATReplyType reply, const char *cmd_expr, ...);
|
int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...);
|
||||||
|
|
||||||
#define REPLY_TIME_OUT 3000
|
#define REPLY_TIME_OUT 3000
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
config ADAPTER_BLUETOOTH
|
config ADAPTER_HC08
|
||||||
bool "Using bluetooth adapter function"
|
bool "Using bluetooth adapter device HC08"
|
||||||
default y
|
default y
|
||||||
|
|
||||||
if ADAPTER_BLUETOOTH
|
if ADAPTER_HC08
|
||||||
config ADAPTER_HC08
|
source "$APP_DIR/Framework/connection/bluetooth/HC08/Kconfig"
|
||||||
bool "Using bluetooth adapter device HC08"
|
endif
|
||||||
default y
|
|
||||||
|
|
||||||
if ADAPTER_HC08
|
|
||||||
source "$APP_DIR/Framework/connection/bluetooth/HC08/Kconfig"
|
|
||||||
endif
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
|
@ -210,10 +210,10 @@ static int Hfa21SetAddr(struct Adapter *adapter, const char *ip, const char *gat
|
||||||
char *gw_str = NULL;
|
char *gw_str = NULL;
|
||||||
char *mask_str = NULL;
|
char *mask_str = NULL;
|
||||||
|
|
||||||
dhcp_mode = (char *) UserCalloc(1, 8);
|
dhcp_mode = (char *) PrivCalloc(1, 8);
|
||||||
ip_str = (char *) UserCalloc(1, 17);
|
ip_str = (char *) PrivCalloc(1, 17);
|
||||||
gw_str = (char *) UserCalloc(1, 17);
|
gw_str = (char *) PrivCalloc(1, 17);
|
||||||
mask_str = (char *) UserCalloc(1, 17);
|
mask_str = (char *) PrivCalloc(1, 17);
|
||||||
|
|
||||||
Hfa21InitAtCmd(adapter->agent);
|
Hfa21InitAtCmd(adapter->agent);
|
||||||
|
|
||||||
|
@ -260,8 +260,8 @@ static int Hfa21Ping(struct Adapter *adapter, const char *destination)
|
||||||
{
|
{
|
||||||
char *ping_result = NONE;
|
char *ping_result = NONE;
|
||||||
char *dst = NONE;
|
char *dst = NONE;
|
||||||
ping_result = (char *) UserCalloc(1, 17);
|
ping_result = (char *) PrivCalloc(1, 17);
|
||||||
dst = (char *) UserCalloc(1, 17);
|
dst = (char *) PrivCalloc(1, 17);
|
||||||
strcpy(dst, destination);
|
strcpy(dst, destination);
|
||||||
strcat(dst, "\r");
|
strcat(dst, "\r");
|
||||||
|
|
||||||
|
@ -327,11 +327,11 @@ static int Hfa21Netstat(struct Adapter *adapter)
|
||||||
char *local_ipaddr = NULL;
|
char *local_ipaddr = NULL;
|
||||||
char *gateway = NULL;
|
char *gateway = NULL;
|
||||||
char *netmask = NULL;
|
char *netmask = NULL;
|
||||||
local_ipaddr = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
local_ipaddr = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||||
gateway = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
gateway = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||||
netmask = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
netmask = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||||
work_mode = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
work_mode = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||||
ip_mode = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
ip_mode = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||||
|
|
||||||
reply = CreateATReply(HFA21_NETSTAT_RESP_SIZE);
|
reply = CreateATReply(HFA21_NETSTAT_RESP_SIZE);
|
||||||
if (reply == NULL) {
|
if (reply == NULL) {
|
||||||
|
@ -391,13 +391,13 @@ __exit:
|
||||||
if (reply)
|
if (reply)
|
||||||
DeleteATReply(reply);
|
DeleteATReply(reply);
|
||||||
if (local_ipaddr)
|
if (local_ipaddr)
|
||||||
UserFree(local_ipaddr);
|
PrivFree(local_ipaddr);
|
||||||
if (netmask)
|
if (netmask)
|
||||||
UserFree(netmask);
|
PrivFree(netmask);
|
||||||
if (gateway)
|
if (gateway)
|
||||||
UserFree(gateway);
|
PrivFree(gateway);
|
||||||
if (work_mode)
|
if (work_mode)
|
||||||
UserFree(work_mode);
|
PrivFree(work_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Hfa21Connect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
static int Hfa21Connect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||||
|
@ -504,11 +504,11 @@ AdapterProductInfoType Hfa21Attach(struct Adapter *adapter)
|
||||||
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
||||||
if (!product_info) {
|
if (!product_info) {
|
||||||
printf("Hfa21Attach Attach malloc product_info error\n");
|
printf("Hfa21Attach Attach malloc product_info error\n");
|
||||||
free(product_info);
|
PrivFree(product_info);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
product_info->model_name = ADAPTER_WIFI_HFA21;
|
strcpy(product_info->model_name, ADAPTER_WIFI_HFA21);
|
||||||
|
|
||||||
product_info->model_done = (void *)&hfa21_done;
|
product_info->model_done = (void *)&hfa21_done;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
config ADAPTER_WIFI
|
config ADAPTER_HFA21
|
||||||
bool "Using WIFI adapter function"
|
bool "Using wifi adapter device HFA21"
|
||||||
default y
|
default y
|
||||||
|
|
||||||
if ADAPTER_WIFI
|
if ADAPTER_HFA21
|
||||||
config ADAPTER_HFA21
|
source "$APP_DIR/Framework/connection/wifi/HFA21/Kconfig"
|
||||||
bool "Using wifi adapter device HFA21"
|
endif
|
||||||
default y
|
|
||||||
|
|
||||||
if ADAPTER_HFA21
|
|
||||||
source "$APP_DIR/Framework/connection/wifi/HFA21/Kconfig"
|
|
||||||
endif
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
|
@ -24,9 +24,8 @@
|
||||||
|
|
||||||
int sem_init(sem_t *sem, int pshared, unsigned int value)
|
int sem_init(sem_t *sem, int pshared, unsigned int value)
|
||||||
{
|
{
|
||||||
int32 ret = 0;
|
*sem = UserSemaphoreCreate(value);
|
||||||
ret = UserSemaphoreCreate(value);
|
if (*sem < 0) {
|
||||||
if (ret < 0) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue