commit
ac588f2fcf
|
@ -1,7 +0,0 @@
|
|||
SRC_FILES := adapter_4G.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_EC200T),y)
|
||||
SRC_DIR += EC200T
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -3,6 +3,6 @@ config ADAPTER_EC200T
|
|||
default y
|
||||
|
||||
if ADAPTER_EC200T
|
||||
source "$APP_DIR/Framework/connection/4G/EC200T/Kconfig"
|
||||
source "$APP_DIR/Framework/connection/4g/ec200t/Kconfig"
|
||||
endif
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
SRC_FILES := adapter_4g.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_EC200T),y)
|
||||
SRC_DIR += ec200t
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -84,16 +84,18 @@ int Adapter4GInit(void)
|
|||
/******************4G TEST*********************/
|
||||
int Adapter4GTest(void)
|
||||
{
|
||||
const char *send_msg = "SendHeart";
|
||||
char recv_msg[128];
|
||||
const char *send_msg = "Adapter_4G Test";
|
||||
char recv_msg[256] = {0};
|
||||
int baud_rate = BAUD_RATE_115200;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_4G_NAME);
|
||||
|
||||
#ifdef ADAPTER_EC200T
|
||||
//Using DSD server to test 4G Socket connection
|
||||
uint8 server_addr[64] = "115.238.53.61";
|
||||
uint8 server_port[64] = "33333";
|
||||
//Using Hang Xiao server to test 4G Socket connection
|
||||
uint8 server_addr[64] = "101.68.82.219";
|
||||
uint8 server_port[64] = "9898";
|
||||
|
||||
adapter->socket.socket_id = 0;
|
||||
|
||||
AdapterDeviceOpen(adapter);
|
||||
AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
|
||||
|
@ -102,8 +104,9 @@ int Adapter4GTest(void)
|
|||
|
||||
while (1) {
|
||||
AdapterDeviceSend(adapter, send_msg, strlen(send_msg));
|
||||
AdapterDeviceRecv(adapter, recv_msg, 128);
|
||||
AdapterDeviceRecv(adapter, recv_msg, 256);
|
||||
printf("4G recv msg %s\n", recv_msg);
|
||||
memset(recv_msg, 0, 256);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -17,7 +17,7 @@ if ADD_XIUOS_FETURES
|
|||
|
||||
config ADAPTER_EC200T_DRIVER
|
||||
string "EC200T device uart driver path"
|
||||
default "/dev/uart2_dev2"
|
||||
default "/dev/usart2_dev2"
|
||||
depends on !ADAPTER_EC200T_DRIVER_EXTUART
|
||||
|
||||
if ADAPTER_EC200T_DRIVER_EXTUART
|
|
@ -21,6 +21,21 @@
|
|||
#include <adapter.h>
|
||||
#include <at_agent.h>
|
||||
|
||||
#define EC200T_AT_MODE_CMD "+++"
|
||||
#define EC200T_GET_CCID_CMD "AT+CCID\r\n"
|
||||
#define EC200T_GET_CPIN_CMD "AT+CPIN?\r\n"
|
||||
#define EC200T_GET_CREG_CMD "AT+CREG?\r\n"
|
||||
#define EC200T_OPEN_SOCKET_CMD "AT+QIOPEN=1,%u"
|
||||
#define EC200T_CLOSE_SOCKET_CMD "AT+QICLOSE=%u\r\n"
|
||||
#define EC200T_ACTIVE_PDP_CMD "AT+QIACT=1\r\n"
|
||||
#define EC200T_DEACTIVE_PDP_CMD "AT+QIDEACT=1\r\n"
|
||||
#define EC200T_CFG_TCP_CMD "AT+QICSGP"
|
||||
|
||||
#define EC200T_OK_REPLY "OK"
|
||||
#define EC200T_READY_REPLY "READY"
|
||||
#define EC200T_CREG_REPLY ",1"
|
||||
#define EC200T_CONNECT_REPLY "CONNECT"
|
||||
|
||||
static void Ec200tPowerSet(void)
|
||||
{
|
||||
int pin_fd;
|
||||
|
@ -47,6 +62,8 @@ static void Ec200tPowerSet(void)
|
|||
PrivWrite(pin_fd, &pin_stat, 1);
|
||||
|
||||
PrivClose(pin_fd);
|
||||
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
static int Ec200tOpen(struct Adapter *adapter)
|
||||
|
@ -70,32 +87,6 @@ static int Ec200tOpen(struct Adapter *adapter)
|
|||
adapter->agent = at_agent;
|
||||
}
|
||||
|
||||
/*step3: serial write "+++", quit transparent mode*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
||||
|
||||
/*step4: serial write "AT+CCID", get SIM ID*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+CCID\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step5: serial write "AT+CPIN?", check SIM status*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+CPIN?\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step6: serial write "AT+CREG?", check whether registered to GSM net*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+CREG?\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step7: serial write "AT+QICLOSE", close socket connect before open socket*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QICLOSE=0\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step8: serial write "AT+QIDEACT", close TCP net before open socket*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QIDEACT=1\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
ADAPTER_DEBUG("Ec200t open done\n");
|
||||
|
@ -105,31 +96,41 @@ static int Ec200tOpen(struct Adapter *adapter)
|
|||
|
||||
static int Ec200tClose(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
uint8_t ec200t_cmd[64];
|
||||
|
||||
if (!adapter->agent) {
|
||||
printf("Ec200tClose AT agent NULL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B);
|
||||
|
||||
/*step1: serial write "+++", quit transparent mode*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
||||
|
||||
/*step2: serial write "AT+QICLOSE", close socket connect before open socket*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QICLOSE=0\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||
sprintf(ec200t_cmd, EC200T_CLOSE_SOCKET_CMD, adapter->socket.socket_id);
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step3: serial write "AT+QIDEACT", close TCP net before open socket*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QIDEACT=1\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_DEACTIVE_PDP_CMD, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
/*step4: close ec200t serial port*/
|
||||
PrivClose(adapter->fd);
|
||||
|
||||
/*step5: power down ec200t*/
|
||||
Ec200tPowerSet();
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
|
||||
|
@ -159,15 +160,41 @@ static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
|
|||
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
|
||||
ioctl_cfg.args = &serial_cfg;
|
||||
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
|
||||
|
||||
Ec200tPowerSet();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||
{
|
||||
int ret = 0;
|
||||
uint8_t ec200t_cmd[64];
|
||||
|
||||
/*step1: serial write "AT+QICSGP", connect to China Mobile using ipv4 or ipv6*/
|
||||
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B);
|
||||
|
||||
/*step1: serial write "+++", quit transparent mode*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
||||
|
||||
/*step2: serial write "AT+CCID", get SIM ID*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CCID_CMD, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step3: serial write "AT+CPIN?", check SIM status*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CPIN_CMD, EC200T_READY_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step4: serial write "AT+CREG?", check whether registered to GSM net*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CREG_CMD, EC200T_CREG_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step5: serial write "AT+QICSGP", connect to China Mobile using ipv4 or ipv6*/
|
||||
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||
|
||||
if (IPV4 == ip_type) {
|
||||
|
@ -176,58 +203,105 @@ static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, con
|
|||
strcpy(ec200t_cmd, "AT+QICSGP=1,2,\"CMNET\",\"\",\"\",1\r\n");
|
||||
}
|
||||
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, ec200t_cmd);
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step2: serial write "AT+QIACT", open TCP net*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QIACT=1\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step3: serial write "AT+QIOPEN", connect socket using TCP*/
|
||||
/*step6: serial write "AT+QICLOSE", close socket connect before open socket*/
|
||||
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||
strcpy(ec200t_cmd, "AT+QIOPEN=1,0,\"TCP\",\"");
|
||||
sprintf(ec200t_cmd, EC200T_CLOSE_SOCKET_CMD, adapter->socket.socket_id);
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step7: serial write "AT+QIDEACT", close TCP net before open socket*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_DEACTIVE_PDP_CMD, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step8: serial write "AT+QIACT", open TCP net*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_ACTIVE_PDP_CMD, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step9: serial write "AT+QIOPEN", connect socket using TCP*/
|
||||
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||
sprintf(ec200t_cmd, EC200T_OPEN_SOCKET_CMD, adapter->socket.socket_id);
|
||||
strcat(ec200t_cmd, ",\"TCP\",\"");
|
||||
strcat(ec200t_cmd, ip);
|
||||
strcat(ec200t_cmd, "\",");
|
||||
strcat(ec200t_cmd, port);
|
||||
strcat(ec200t_cmd, ",0,2\r\n");
|
||||
|
||||
ADAPTER_DEBUG("Ec200t connect AT CMD :%s\n", ec200t_cmd);
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, ec200t_cmd);
|
||||
AtSetReplyEndChar(adapter->agent, 0x43, 0x54);
|
||||
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_CONNECT_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
ADAPTER_DEBUG("Ec200t connect TCP done\n");
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
ADAPTER_DEBUG("Ec200t connect TCP failed. Power down\n");
|
||||
Ec200tPowerSet();
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int Ec200tSend(struct Adapter *adapter, const void *buf, size_t len)
|
||||
{
|
||||
PrivWrite(adapter->fd, buf, len);
|
||||
x_err_t result = EOK;
|
||||
if (adapter->agent) {
|
||||
EntmSend(adapter->agent, (const char *)buf, len);
|
||||
} else {
|
||||
printf("Ec200tSend can not find agent\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Ec200tRecv(struct Adapter *adapter, void *buf, size_t len)
|
||||
{
|
||||
PrivRead(adapter->fd, buf, len);
|
||||
return 0;
|
||||
if (adapter->agent) {
|
||||
return EntmRecv(adapter->agent, (char *)buf, len, 40000);
|
||||
} else {
|
||||
printf("Ec200tRecv can not find agent\n");
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int Ec200tDisconnect(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
uint8_t ec200t_cmd[64];
|
||||
|
||||
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B);
|
||||
|
||||
/*step1: serial write "+++", quit transparent mode*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
||||
|
||||
/*step2: serial write "AT+QICLOSE", close socket connect before open socket*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QICLOSE=0\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||
sprintf(ec200t_cmd, EC200T_CLOSE_SOCKET_CMD, adapter->socket.socket_id);
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
ADAPTER_DEBUG("Ec200t disconnect TCP done\n");
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
ADAPTER_DEBUG("Ec200t disconnect TCP failed. Power down\n");
|
||||
Ec200tPowerSet();
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const struct IpProtocolDone ec200t_done =
|
||||
|
@ -261,10 +335,5 @@ AdapterProductInfoType Ec200tAttach(struct Adapter *adapter)
|
|||
|
||||
product_info->model_done = (void *)&ec200t_done;
|
||||
|
||||
Ec200tPowerSet();
|
||||
|
||||
return product_info;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
SRC_FILES := adapter_5G.c
|
||||
SRC_FILES := adapter_5g.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -11,7 +11,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* @file adapter_5G.c
|
||||
* @file adapter_5g.c
|
||||
* @brief Implement the connection 5G adapter function
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
|
@ -18,7 +18,7 @@ if SUPPORT_CONNECTION_FRAMEWORK
|
|||
bool "Using 4G adapter device"
|
||||
default n
|
||||
if CONNECTION_ADAPTER_4G
|
||||
source "$APP_DIR/Framework/connection/4G/Kconfig"
|
||||
source "$APP_DIR/Framework/connection/4g/Kconfig"
|
||||
endif
|
||||
|
||||
menuconfig CONNECTION_ADAPTER_NB
|
||||
|
@ -60,6 +60,6 @@ if SUPPORT_CONNECTION_FRAMEWORK
|
|||
bool "Using 5G adapter device"
|
||||
default n
|
||||
if CONNECTION_ADAPTER_5G
|
||||
source "$APP_DIR/Framework/connection/5G/Kconfig"
|
||||
source "$APP_DIR/Framework/connection/5g/Kconfig"
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -5,7 +5,7 @@ ifeq ($(CONFIG_CONNECTION_ADAPTER_LORA),y)
|
|||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y)
|
||||
SRC_DIR += 4G
|
||||
SRC_DIR += 4g
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_NB),y)
|
||||
|
@ -29,7 +29,7 @@ ifeq ($(CONFIG_CONNECTION_ADAPTER_ZIGBEE),y)
|
|||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_5G),y)
|
||||
SRC_DIR += 5G
|
||||
SRC_DIR += 5g
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -42,7 +42,7 @@ extern "C" {
|
|||
#ifdef CONNECTION_FRAMEWORK_DEBUG
|
||||
#define ADAPTER_DEBUG printf
|
||||
#else
|
||||
#define ADAPTER_DEBUF
|
||||
#define ADAPTER_DEBUG
|
||||
#endif
|
||||
|
||||
struct Adapter;
|
||||
|
@ -52,8 +52,14 @@ typedef struct AdapterProductInfo *AdapterProductInfoType;
|
|||
|
||||
struct Socket
|
||||
{
|
||||
int id;
|
||||
struct Adapter *adapter;
|
||||
uint8_t type; ///< socket type:DGRAM->UDP,STREAM->TCP
|
||||
uint8_t protocal; ///< udp or tcp
|
||||
unsigned short listen_port; ///< 0-65535
|
||||
uint8_t socket_id; ///< socket id
|
||||
uint8_t recv_control; ///< receive control
|
||||
uint8_t af_type; ///< IPv4 or IPv6
|
||||
char *src_ip_addr; ///< source P address
|
||||
char *dst_ip_addr; ///< destination IP address
|
||||
};
|
||||
|
||||
enum AdapterType
|
||||
|
@ -156,7 +162,7 @@ struct Adapter
|
|||
struct AdapterProductInfo *info;
|
||||
ATAgentType agent;
|
||||
|
||||
//struct Socket *socket;
|
||||
struct Socket socket;
|
||||
|
||||
enum NetProtocolType net_protocol;
|
||||
enum NetRoleType net_role;
|
||||
|
|
|
@ -45,9 +45,9 @@ unsigned int IpTint(char *ipstr)
|
|||
|
||||
token = strtok(ipstr, ".");
|
||||
|
||||
while (token != NULL){
|
||||
while (token != NULL) {
|
||||
cur = atoi(token);
|
||||
if (cur >= 0 && cur <= 255){
|
||||
if (cur >= 0 && cur <= 255) {
|
||||
total += cur * pow(256, i);
|
||||
}
|
||||
i--;
|
||||
|
@ -61,8 +61,8 @@ void SwapStr(char *str, int begin, int end)
|
|||
{
|
||||
int i, j;
|
||||
|
||||
for (i = begin, j = end; i <= j; i++, j--){
|
||||
if (str[i] != str[j]){
|
||||
for (i = begin, j = end; i <= j; i++, j--) {
|
||||
if (str[i] != str[j]) {
|
||||
str[i] = str[i] ^ str[j];
|
||||
str[j] = str[i] ^ str[j];
|
||||
str[i] = str[i] ^ str[j];
|
||||
|
@ -79,7 +79,7 @@ char *IpTstr(unsigned int ipint)
|
|||
char token[4];
|
||||
int bt, ed, len, cur;
|
||||
|
||||
while (ipint){
|
||||
while (ipint) {
|
||||
cur = ipint % 256;
|
||||
sprintf(token, "%d", cur);
|
||||
strcat(new, token);
|
||||
|
@ -91,8 +91,8 @@ char *IpTstr(unsigned int ipint)
|
|||
len = strlen(new);
|
||||
SwapStr(new, 0, len - 1);
|
||||
|
||||
for (bt = ed = 0; ed < len;){
|
||||
while (ed < len && new[ed] != '.'){
|
||||
for (bt = ed = 0; ed < len;) {
|
||||
while (ed < len && new[ed] != '.') {
|
||||
ed++;
|
||||
}
|
||||
SwapStr(new, bt, ed - 1);
|
||||
|
@ -126,7 +126,7 @@ uint32 ATSprintf(int fd, const char *format, va_list params)
|
|||
|
||||
int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...)
|
||||
{
|
||||
if (agent == NULL){
|
||||
if (agent == NULL) {
|
||||
printf("ATAgent is null");
|
||||
return -ERROR;
|
||||
}
|
||||
|
@ -151,16 +151,16 @@ int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const ch
|
|||
|
||||
agent->reply = reply;
|
||||
|
||||
if(agent->reply != NULL){
|
||||
if(agent->reply != NULL) {
|
||||
reply->reply_len = 0;
|
||||
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) != EOK) {
|
||||
result = -ETIMEOUT;
|
||||
goto __out;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
va_start(params, cmd_expr);
|
||||
ATSprintf(agent->fd, cmd_expr, params);
|
||||
va_end(params);
|
||||
|
@ -170,23 +170,72 @@ int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const ch
|
|||
__out:
|
||||
agent->reply = NULL;
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
agent->receive_mode = ENTM_MODE;
|
||||
agent->receive_mode = DEFAULT_MODE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check)
|
||||
{
|
||||
int ret = 0;
|
||||
char *result = NULL;
|
||||
if (NULL == agent || NULL == cmd || NULL == check ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ATReplyType reply = CreateATReply(64);
|
||||
if (NULL == reply) {
|
||||
printf("%s %d at_create_resp failed!\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd);
|
||||
PrivTaskDelay(3000);
|
||||
|
||||
result = GetReplyText(reply);
|
||||
if (!result) {
|
||||
printf("%s %n get reply failed.\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
printf("[reply result :\n");
|
||||
printf("%s]\n", result);
|
||||
if(!strstr(result, check)) {
|
||||
printf("%s %d check[%s] reply[%s] failed.\n",__func__,__LINE__,check,result);
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
__exit:
|
||||
DeleteATReply(reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *GetReplyText(ATReplyType reply)
|
||||
{
|
||||
return reply->reply_buffer;
|
||||
}
|
||||
|
||||
int AtSetReplyEndChar(ATAgentType agent, char ch)
|
||||
int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
||||
{
|
||||
if (!agent) {
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
agent->reply_end_char = ch;
|
||||
agent->reply_lr_end = enable;
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
||||
{
|
||||
if (!agent) {
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
agent->reply_end_last_char = last_ch;
|
||||
agent->reply_end_char = end_ch;
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
@ -226,21 +275,25 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
|||
|
||||
PrivTaskDelay(1000);
|
||||
|
||||
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
PrivMutexObtain(&agent->lock);
|
||||
|
||||
if (buffer_len < agent->entm_recv_len) {
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
printf("EntmRecv once len %u.\n", agent->entm_recv_len);
|
||||
|
||||
agent->entm_recv_buf[agent->entm_recv_len - 1] = '\0';
|
||||
memcpy(rev_buffer, agent->entm_recv_buf, agent->entm_recv_len - 2);
|
||||
|
||||
memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX);
|
||||
agent->entm_recv_len = 0;
|
||||
|
||||
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)){
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
if (buffer_len < agent->entm_recv_len){
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
printf("EntmRecv once .\n");
|
||||
|
||||
agent->entm_recv_buf[agent->entm_recv_len - 2] = '\0';
|
||||
memcpy(rev_buffer, agent->entm_recv_buf, agent->entm_recv_len - 2);
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
@ -254,40 +307,43 @@ static int GetCompleteATReply(ATAgentType agent)
|
|||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||
agent->maintain_len = 0;
|
||||
|
||||
while (1){
|
||||
while (1) {
|
||||
PrivRead(agent->fd, &ch, 1);
|
||||
|
||||
printf(" %c (0x%x)\n", ch, ch);
|
||||
|
||||
if (agent->receive_mode == ENTM_MODE){
|
||||
if (agent->entm_recv_len < ENTM_RECV_MAX){
|
||||
if (agent->entm_recv_len < ENTM_RECV_MAX) {
|
||||
PrivMutexObtain(&agent->lock);
|
||||
|
||||
agent->entm_recv_buf[agent->entm_recv_len] = ch;
|
||||
agent->entm_recv_len++;
|
||||
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
|
||||
if (last_ch == '!' && ch == '@'){
|
||||
PrivSemaphoreAbandon(&agent->entm_rx_notice);
|
||||
}
|
||||
|
||||
last_ch = ch;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
printf("entm_recv_buf is_full ...\n");
|
||||
}
|
||||
}
|
||||
else if (agent->receive_mode == AT_MODE){
|
||||
} else if (agent->receive_mode == AT_MODE) {
|
||||
if (read_len < agent->maintain_max){
|
||||
agent->maintain_buffer[read_len] = ch;
|
||||
read_len++;
|
||||
agent->maintain_len = read_len;
|
||||
}else{
|
||||
} else {
|
||||
printf("maintain_len is_full ...\n");
|
||||
is_full = true;
|
||||
}
|
||||
|
||||
if ((ch == '\n' && last_ch == '\r') ||
|
||||
((ch == agent->reply_end_char) && (agent->reply_end_char)) ||
|
||||
if (((ch == '\n') && (last_ch == '\r') && (agent->reply_lr_end)) ||
|
||||
((ch == agent->reply_end_char) && (agent->reply_end_char) &&
|
||||
(last_ch == agent->reply_end_last_char) && (agent->reply_end_last_char)) ||
|
||||
((read_len == agent->reply_char_num) && (agent->reply_char_num))){
|
||||
if (is_full){
|
||||
if (is_full) {
|
||||
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;
|
||||
|
@ -306,8 +362,8 @@ static int GetCompleteATReply(ATAgentType agent)
|
|||
ATAgentType GetATAgent(const char *agent_name)
|
||||
{
|
||||
struct ATAgent* result = NULL;
|
||||
for (int i = 0; i < AT_AGENT_MAX; i++){
|
||||
if (strcmp(at_agent_table[i].agent_name, agent_name) == 0){
|
||||
for (int i = 0; i < AT_AGENT_MAX; i++) {
|
||||
if (strcmp(at_agent_table[i].agent_name, agent_name) == 0) {
|
||||
result = &at_agent_table[i];
|
||||
}
|
||||
}
|
||||
|
@ -318,23 +374,23 @@ ATAgentType GetATAgent(const char *agent_name)
|
|||
|
||||
static int DeleteATAgent(ATAgentType agent)
|
||||
{
|
||||
if (agent->lock){
|
||||
if (agent->lock) {
|
||||
PrivMutexDelete(&agent->lock);
|
||||
}
|
||||
|
||||
if (agent->entm_rx_notice){
|
||||
if (agent->entm_rx_notice) {
|
||||
PrivSemaphoreDelete(&agent->entm_rx_notice);
|
||||
}
|
||||
|
||||
if (agent->fd > 0){
|
||||
if (agent->fd > 0) {
|
||||
PrivClose(agent->fd);
|
||||
}
|
||||
|
||||
if (agent->rsp_sem){
|
||||
if (agent->rsp_sem) {
|
||||
PrivSemaphoreDelete(&agent->rsp_sem);
|
||||
}
|
||||
|
||||
if (agent->maintain_buffer){
|
||||
if (agent->maintain_buffer) {
|
||||
PrivFree(agent->maintain_buffer);
|
||||
}
|
||||
|
||||
|
@ -346,19 +402,18 @@ static void *ATAgentReceiveProcess(void *param)
|
|||
ATAgentType agent = (ATAgentType)param;
|
||||
const struct at_urc *urc;
|
||||
|
||||
while (1){
|
||||
if (GetCompleteATReply(agent) > 0){
|
||||
while (1) {
|
||||
if (GetCompleteATReply(agent) > 0) {
|
||||
if (agent->reply != NULL){
|
||||
ATReplyType reply = agent->reply;
|
||||
|
||||
agent->maintain_buffer[agent->maintain_len - 1] = '\0';
|
||||
agent->maintain_buffer[agent->maintain_len] = '\0';
|
||||
|
||||
if (agent->maintain_len < reply->reply_max_len){
|
||||
if (agent->maintain_len < reply->reply_max_len) {
|
||||
memcpy(reply->reply_buffer, agent->maintain_buffer, agent->maintain_len);
|
||||
|
||||
reply->reply_len = agent->maintain_len;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
printf("out of memory (%d)!", reply->reply_max_len);
|
||||
}
|
||||
|
||||
|
@ -377,7 +432,7 @@ static int ATAgentInit(ATAgentType agent)
|
|||
agent->maintain_len = 0;
|
||||
agent->maintain_buffer = (char *)PrivMalloc(agent->maintain_max);
|
||||
|
||||
if (agent->maintain_buffer == NONE){
|
||||
if (agent->maintain_buffer == NONE) {
|
||||
printf("ATAgentInit malloc maintain_buffer error\n");
|
||||
goto __out;
|
||||
}
|
||||
|
@ -385,13 +440,13 @@ static int ATAgentInit(ATAgentType agent)
|
|||
memset(agent->maintain_buffer, 0, agent->maintain_max);
|
||||
|
||||
result = PrivSemaphoreCreate(&agent->entm_rx_notice, 0, 0);
|
||||
if (result < 0){
|
||||
if (result < 0) {
|
||||
printf("ATAgentInit create entm sem error\n");
|
||||
goto __out;
|
||||
}
|
||||
|
||||
result = PrivSemaphoreCreate(&agent->rsp_sem, 0, 0);
|
||||
if (result < 0){
|
||||
if (result < 0) {
|
||||
printf("ATAgentInit create rsp sem error\n");
|
||||
goto __out;
|
||||
}
|
||||
|
@ -448,8 +503,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 == EOK) {
|
||||
PrivTaskStartup(&agent->at_handler);
|
||||
}
|
||||
|
||||
|
@ -461,7 +515,7 @@ ATReplyType CreateATReply(uint32 reply_max_len)
|
|||
ATReplyType reply = NULL;
|
||||
|
||||
reply = (ATReplyType)PrivMalloc(sizeof(struct ATReply));
|
||||
if (reply == NULL){
|
||||
if (reply == NULL) {
|
||||
printf("no more memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -469,7 +523,7 @@ ATReplyType CreateATReply(uint32 reply_max_len)
|
|||
reply->reply_max_len = reply_max_len;
|
||||
|
||||
reply->reply_buffer = (char *)PrivMalloc(reply_max_len);
|
||||
if (reply->reply_buffer == NULL){
|
||||
if (reply->reply_buffer == NULL) {
|
||||
printf("no more memory\n");
|
||||
PrivFree(reply);
|
||||
return NULL;
|
||||
|
@ -482,14 +536,14 @@ ATReplyType CreateATReply(uint32 reply_max_len)
|
|||
|
||||
void DeleteATReply(ATReplyType reply)
|
||||
{
|
||||
if (reply){
|
||||
if (reply->reply_buffer){
|
||||
if (reply) {
|
||||
if (reply->reply_buffer) {
|
||||
PrivFree(reply->reply_buffer);
|
||||
reply->reply_buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (reply){
|
||||
if (reply) {
|
||||
PrivFree(reply);
|
||||
reply = NULL;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,11 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define REPLY_TIME_OUT 3000
|
||||
|
||||
enum ReceiveMode
|
||||
{
|
||||
DEFAULT_MODE = 0,
|
||||
ENTM_MODE = 1,
|
||||
AT_MODE = 2,
|
||||
};
|
||||
|
@ -52,6 +55,8 @@ struct ATAgent
|
|||
int lock;
|
||||
|
||||
ATReplyType reply;
|
||||
char reply_lr_end;
|
||||
char reply_end_last_char;
|
||||
char reply_end_char;
|
||||
uint32 reply_char_num;
|
||||
int rsp_sem;
|
||||
|
@ -69,18 +74,18 @@ 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 ch);
|
||||
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);
|
||||
uint IpTint(char *ipstr);
|
||||
unsigned int IpTint(char *ipstr);
|
||||
void SwapStr(char *str, int begin, int end);
|
||||
char* IpTstr(uint ipint);
|
||||
char* IpTstr(unsigned int ipint);
|
||||
ATAgentType GetATAgent(const char *agent_name);
|
||||
int InitATAgent(const char *agent_name, int fd, uint32 maintain_max);
|
||||
int ParseATReply(char* str, const char *format, ...);
|
||||
void DeleteATReply(ATReplyType reply);
|
||||
int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...);
|
||||
|
||||
#define REPLY_TIME_OUT 3000
|
||||
int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check);
|
||||
|
||||
#endif
|
|
@ -3,5 +3,5 @@ config ADAPTER_HC08
|
|||
default y
|
||||
|
||||
if ADAPTER_HC08
|
||||
source "$APP_DIR/Framework/connection/bluetooth/HC08/Kconfig"
|
||||
source "$APP_DIR/Framework/connection/bluetooth/hc08/Kconfig"
|
||||
endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
SRC_FILES := adapter_bluetooth.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_HC08),y)
|
||||
SRC_DIR += HC08
|
||||
SRC_DIR += hc08
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
@ -85,7 +85,6 @@ int AdapterBlueToothTest(void)
|
|||
{
|
||||
const char *bluetooth_msg = "BT Adapter Test";
|
||||
char bluetooth_recv_msg[128];
|
||||
char recv_msg[128];
|
||||
int len;
|
||||
int baud_rate = BAUD_RATE_115200;
|
||||
|
||||
|
@ -103,6 +102,7 @@ int AdapterBlueToothTest(void)
|
|||
AdapterDeviceSend(adapter, bluetooth_msg, len);
|
||||
printf("send %s after recv\n", bluetooth_msg);
|
||||
PrivTaskDelay(100);
|
||||
memset(bluetooth_recv_msg, 0, 128);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -98,19 +98,19 @@ static int Hc08AtConfigure(ATAgentType agent, enum Hc08AtCmd hc08_at_cmd, void *
|
|||
switch (hc08_at_cmd)
|
||||
{
|
||||
case HC08_AT_CMD_DETECT:
|
||||
AtSetReplyEndChar(agent, 0x4B);
|
||||
AtSetReplyEndChar(agent, 0x4F, 0x4B);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_DETECT_CMD);
|
||||
break;
|
||||
case HC08_AT_CMD_DEFAULT:
|
||||
AtSetReplyEndChar(agent, 0x4B);
|
||||
AtSetReplyEndChar(agent, 0x4F, 0x4B);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_DEFAULT_CMD);
|
||||
break;
|
||||
case HC08_AT_CMD_RESET:
|
||||
AtSetReplyEndChar(agent, 0x4B);
|
||||
AtSetReplyEndChar(agent, 0x4F, 0x4B);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_RESET_CMD);
|
||||
break;
|
||||
case HC08_AT_CMD_CLEAR:
|
||||
AtSetReplyEndChar(agent, 0x4B);
|
||||
AtSetReplyEndChar(agent, 0x4F, 0x4B);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_CLEAR_CMD);
|
||||
break;
|
||||
case HC08_AT_CMD_GET_DEVICE_INFO:
|
||||
|
@ -121,23 +121,23 @@ static int Hc08AtConfigure(ATAgentType agent, enum Hc08AtCmd hc08_at_cmd, void *
|
|||
baudrate = *(unsigned int *)param;
|
||||
sprintf(cmd_str, HC08_SET_BAUDRATE_CMD, baudrate);
|
||||
strcat(cmd_str, ",N");
|
||||
AtSetReplyEndChar(agent, 0x45);
|
||||
AtSetReplyEndChar(agent, 0x4E, 0x45);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd_str);
|
||||
reply_ok_flag = 0;
|
||||
break;
|
||||
case HC08_AT_CMD_GET_BAUDRATE:
|
||||
AtSetReplyEndChar(agent, 0x4E);
|
||||
AtSetReplyEndChar(agent, 0x2C, 0x4E);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_BAUDRATE_CMD);
|
||||
reply_ok_flag = 0;
|
||||
break;
|
||||
case HC08_AT_CMD_SET_CONNECTABLE:
|
||||
connectable = (char *)param;
|
||||
sprintf(cmd_str, HC08_SET_CONNECTABLE, connectable);
|
||||
AtSetReplyEndChar(agent, 0x4B);
|
||||
AtSetReplyEndChar(agent, 0x4F, 0x4B);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd_str);
|
||||
break;
|
||||
case HC08_AT_CMD_GET_CONNECTABLE:
|
||||
AtSetReplyEndChar(agent, 0x65);
|
||||
AtSetReplyEndChar(agent, 0x6C, 0x65);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_CONNECTABLE);
|
||||
reply_ok_flag = 0;
|
||||
break;
|
||||
|
@ -346,7 +346,7 @@ static int Hc08Send(struct Adapter *adapter, const void *buf, size_t len)
|
|||
x_err_t result = EOK;
|
||||
if (adapter->agent) {
|
||||
EntmSend(adapter->agent, (const char *)buf, len);
|
||||
}else {
|
||||
} else {
|
||||
printf("Hc08Send can not find agent\n");
|
||||
}
|
||||
return 0;
|
|
@ -1,7 +1,7 @@
|
|||
config ADAPTER_HFA21
|
||||
config ADAPTER_HFA21_WIFI
|
||||
bool "Using wifi adapter device HFA21"
|
||||
default y
|
||||
|
||||
if ADAPTER_HFA21
|
||||
source "$APP_DIR/Framework/connection/wifi/HFA21/Kconfig"
|
||||
if ADAPTER_HFA21_WIFI
|
||||
source "$APP_DIR/Framework/connection/wifi/hfa21_wifi/Kconfig"
|
||||
endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
SRC_FILES := adapter_wifi.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_HFA21),y)
|
||||
SRC_DIR += HFA21
|
||||
ifeq ($(CONFIG_ADAPTER_HFA21_WIFI),y)
|
||||
SRC_DIR += hfa21_wifi
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <adapter.h>
|
||||
#include <bus_pin.h>
|
||||
|
||||
#ifdef ADAPTER_HFA21
|
||||
#ifdef ADAPTER_HFA21_WIFI
|
||||
extern AdapterProductInfoType Hfa21Attach(struct Adapter *adapter);
|
||||
#endif
|
||||
|
||||
|
@ -65,7 +65,7 @@ int AdapterWifiInit(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifdef ADAPTER_HFA21
|
||||
#ifdef ADAPTER_HFA21_WIFI
|
||||
AdapterProductInfoType product_info = Hfa21Attach(adapter);
|
||||
if (!product_info) {
|
||||
printf("AdapterWifiInit hfa21 attach error\n");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
config ADAPTER_WIFI_HFA21
|
||||
string "HFA21 adapter name"
|
||||
default "hfa21"
|
||||
string "HFA21 WIFI adapter name"
|
||||
default "hfa21_wifi"
|
||||
|
||||
if ADD_XIUOS_FETURES
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
SRC_FILES := hfa21.c
|
||||
SRC_FILES := hfa21_wifi.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -4,7 +4,7 @@ if CONNECTION_ADAPTER_ZIGBEE
|
|||
default y
|
||||
|
||||
if ADAPTER_E18
|
||||
source "$APP_DIR/Framework/connection/zigbee/E18/Kconfig"
|
||||
source "$APP_DIR/Framework/connection/zigbee/e18/Kconfig"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
SRC_FILES := adapter_zigbee.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_E18),y)
|
||||
SRC_DIR += E18
|
||||
SRC_DIR += e18
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
@ -79,39 +79,6 @@ static int E18UartOpen(struct Adapter *adapter)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check)
|
||||
{
|
||||
char *result = NULL;
|
||||
if (NULL == agent || NULL == cmd || NULL == check ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ATReplyType reply = CreateATReply(64);
|
||||
if (NULL == reply) {
|
||||
printf("%s %d at_create_resp failed!\n",__func__,__LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd);
|
||||
PrivTaskDelay(3000);
|
||||
|
||||
result = GetReplyText(reply);
|
||||
if (!result) {
|
||||
printf("%s %n get reply failed.\n",__func__,__LINE__);
|
||||
goto __exit;
|
||||
}
|
||||
if(0 != strncmp(result, check, strlen(check))) {
|
||||
printf("%s %d check[%s] reply[%s] failed.\n",__func__,__LINE__,check,result);
|
||||
goto __exit;
|
||||
}
|
||||
return 0;
|
||||
|
||||
__exit:
|
||||
DeleteATReply(reply);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int E18NetworkModeConfig(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
Loading…
Reference in New Issue