From ab578dfe0eaaae26de8d2f96163ae17e86ec4899 Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Wed, 13 Oct 2021 17:57:34 +0800 Subject: [PATCH 1/4] support 4G adapter and ec200t device --- .../Framework/connection/4G/EC200T/Kconfig | 2 +- .../Framework/connection/4G/EC200T/ec200t.c | 183 ++++++++++++------ .../Framework/connection/4G/adapter_4G.c | 12 +- APP_Framework/Framework/connection/adapter.h | 14 +- .../Framework/connection/adapter_agent.c | 62 +++++- APP_Framework/Framework/connection/at_agent.h | 14 +- .../connection/bluetooth/HC08/hc08.c | 18 +- .../Framework/connection/zigbee/E18/e18.c | 33 ---- 8 files changed, 218 insertions(+), 120 deletions(-) diff --git a/APP_Framework/Framework/connection/4G/EC200T/Kconfig b/APP_Framework/Framework/connection/4G/EC200T/Kconfig index a9b0ea2c..a96619f1 100644 --- a/APP_Framework/Framework/connection/4G/EC200T/Kconfig +++ b/APP_Framework/Framework/connection/4G/EC200T/Kconfig @@ -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 diff --git a/APP_Framework/Framework/connection/4G/EC200T/ec200t.c b/APP_Framework/Framework/connection/4G/EC200T/ec200t.c index 1185fc59..25994ab6 100644 --- a/APP_Framework/Framework/connection/4G/EC200T/ec200t.c +++ b/APP_Framework/Framework/connection/4G/EC200T/ec200t.c @@ -21,6 +21,21 @@ #include #include +#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; } - - - diff --git a/APP_Framework/Framework/connection/4G/adapter_4G.c b/APP_Framework/Framework/connection/4G/adapter_4G.c index c8728ee4..cb81c65f 100644 --- a/APP_Framework/Framework/connection/4G/adapter_4G.c +++ b/APP_Framework/Framework/connection/4G/adapter_4G.c @@ -95,16 +95,18 @@ int Adapter4GTest(void) uint8 server_addr[64] = "115.238.53.61"; uint8 server_port[64] = "33333"; + adapter->socket.socket_id = 0; + AdapterDeviceOpen(adapter); AdapterDeviceControl(adapter, OPE_INT, &baud_rate); AdapterDeviceConnect(adapter, CLIENT, server_addr, server_port, IPV4); - while (1) { - AdapterDeviceSend(adapter, send_msg, strlen(send_msg)); - AdapterDeviceRecv(adapter, recv_msg, 128); - printf("4G recv msg %s\n", recv_msg); - } + // while (1) { + // AdapterDeviceSend(adapter, send_msg, strlen(send_msg)); + // AdapterDeviceRecv(adapter, recv_msg, 128); + // printf("4G recv msg %s\n", recv_msg); + // } #endif return 0; diff --git a/APP_Framework/Framework/connection/adapter.h b/APP_Framework/Framework/connection/adapter.h index 380aaa65..eb492301 100644 --- a/APP_Framework/Framework/connection/adapter.h +++ b/APP_Framework/Framework/connection/adapter.h @@ -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; diff --git a/APP_Framework/Framework/connection/adapter_agent.c b/APP_Framework/Framework/connection/adapter_agent.c index 874dd6e3..5a87b7ca 100755 --- a/APP_Framework/Framework/connection/adapter_agent.c +++ b/APP_Framework/Framework/connection/adapter_agent.c @@ -175,18 +175,67 @@ __out: 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; } @@ -284,10 +333,11 @@ static int GetCompleteATReply(ATAgentType agent) 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; @@ -351,7 +401,7 @@ static void *ATAgentReceiveProcess(void *param) 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){ memcpy(reply->reply_buffer, agent->maintain_buffer, agent->maintain_len); diff --git a/APP_Framework/Framework/connection/at_agent.h b/APP_Framework/Framework/connection/at_agent.h index d9acd71e..527de572 100755 --- a/APP_Framework/Framework/connection/at_agent.h +++ b/APP_Framework/Framework/connection/at_agent.h @@ -26,6 +26,8 @@ #include #include +#define REPLY_TIME_OUT 3000 + enum ReceiveMode { ENTM_MODE = 1, @@ -52,6 +54,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 +73,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 \ No newline at end of file diff --git a/APP_Framework/Framework/connection/bluetooth/HC08/hc08.c b/APP_Framework/Framework/connection/bluetooth/HC08/hc08.c index d2d94ee0..44cff9c8 100644 --- a/APP_Framework/Framework/connection/bluetooth/HC08/hc08.c +++ b/APP_Framework/Framework/connection/bluetooth/HC08/hc08.c @@ -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; diff --git a/APP_Framework/Framework/connection/zigbee/E18/e18.c b/APP_Framework/Framework/connection/zigbee/E18/e18.c index 7bd814a7..1342ad63 100644 --- a/APP_Framework/Framework/connection/zigbee/E18/e18.c +++ b/APP_Framework/Framework/connection/zigbee/E18/e18.c @@ -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; From 8aac82b1b4120c7578fe30dc7a605e2962383a50 Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Thu, 14 Oct 2021 17:25:04 +0800 Subject: [PATCH 2/4] support adapter_4G send and receive data function --- .../Framework/connection/4G/adapter_4G.c | 21 ++-- .../Framework/connection/adapter_agent.c | 110 +++++++++--------- APP_Framework/Framework/connection/at_agent.h | 1 + 3 files changed, 69 insertions(+), 63 deletions(-) diff --git a/APP_Framework/Framework/connection/4G/adapter_4G.c b/APP_Framework/Framework/connection/4G/adapter_4G.c index cb81c65f..00bf150d 100644 --- a/APP_Framework/Framework/connection/4G/adapter_4G.c +++ b/APP_Framework/Framework/connection/4G/adapter_4G.c @@ -84,16 +84,16 @@ 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; @@ -102,11 +102,12 @@ int Adapter4GTest(void) AdapterDeviceConnect(adapter, CLIENT, server_addr, server_port, IPV4); - // while (1) { - // AdapterDeviceSend(adapter, send_msg, strlen(send_msg)); - // AdapterDeviceRecv(adapter, recv_msg, 128); - // printf("4G recv msg %s\n", recv_msg); - // } + while (1) { + AdapterDeviceSend(adapter, send_msg, strlen(send_msg)); + AdapterDeviceRecv(adapter, recv_msg, 256); + printf("4G recv msg %s\n", recv_msg); + memset(recv_msg, 0, 256); + } #endif return 0; diff --git a/APP_Framework/Framework/connection/adapter_agent.c b/APP_Framework/Framework/connection/adapter_agent.c index 5a87b7ca..401dec9a 100755 --- a/APP_Framework/Framework/connection/adapter_agent.c +++ b/APP_Framework/Framework/connection/adapter_agent.c @@ -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,7 +170,7 @@ 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; } @@ -275,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; } @@ -303,32 +307,34 @@ 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; } @@ -356,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]; } } @@ -368,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); } @@ -396,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] = '\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); } @@ -427,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; } @@ -435,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; } @@ -498,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); } @@ -511,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; } @@ -519,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; @@ -532,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; } diff --git a/APP_Framework/Framework/connection/at_agent.h b/APP_Framework/Framework/connection/at_agent.h index 527de572..4f690f50 100755 --- a/APP_Framework/Framework/connection/at_agent.h +++ b/APP_Framework/Framework/connection/at_agent.h @@ -30,6 +30,7 @@ enum ReceiveMode { + DEFAULT_MODE = 0, ENTM_MODE = 1, AT_MODE = 2, }; From 8f6cac9797ffe91c1497f2f85d8a9ebf8ca233fb Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Fri, 15 Oct 2021 10:12:19 +0800 Subject: [PATCH 3/4] fix adapter_bluetooth test function bugs --- .../Framework/connection/bluetooth/adapter_bluetooth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c b/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c index f75bd377..0f855a4a 100644 --- a/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c +++ b/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c @@ -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 From 06c9c6ecc4967ffa32bb2d8a7da39585e72e03e8 Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Fri, 15 Oct 2021 11:05:36 +0800 Subject: [PATCH 4/4] refactor connection directory to follow code standards --- APP_Framework/Framework/connection/4G/Makefile | 7 ------- APP_Framework/Framework/connection/{4G => 4g}/Kconfig | 2 +- APP_Framework/Framework/connection/4g/Makefile | 7 +++++++ .../connection/{4G/adapter_4G.c => 4g/adapter_4g.c} | 0 .../Framework/connection/{4G/EC200T => 4g/ec200t}/Kconfig | 0 .../Framework/connection/{4G/EC200T => 4g/ec200t}/Makefile | 0 .../Framework/connection/{4G/EC200T => 4g/ec200t}/ec200t.c | 0 APP_Framework/Framework/connection/{5G => 5g}/Kconfig | 0 .../Framework/connection/{wifi/HFA21 => 5g}/Makefile | 2 +- .../connection/{5G/adapter_5G.c => 5g/adapter_5g.c} | 2 +- APP_Framework/Framework/connection/Kconfig | 4 ++-- APP_Framework/Framework/connection/Makefile | 4 ++-- APP_Framework/Framework/connection/bluetooth/Kconfig | 2 +- APP_Framework/Framework/connection/bluetooth/Makefile | 2 +- .../Framework/connection/bluetooth/{HC08 => hc08}/Kconfig | 0 .../Framework/connection/bluetooth/{HC08 => hc08}/Makefile | 0 .../Framework/connection/bluetooth/{HC08 => hc08}/hc08.c | 0 .../Framework/connection/lora/{SX1278 => sx1278}/Kconfig | 0 .../Framework/connection/lora/{SX1278 => sx1278}/Makefile | 0 .../Framework/connection/lora/{SX1278 => sx1278}/sx1278.c | 0 .../Framework/connection/nbiot/{BC28 => bc28}/Kconfig | 0 .../Framework/connection/nbiot/{BC28 => bc28}/Makefile | 0 .../Framework/connection/nbiot/{BC28 => bc28}/bc28.c | 0 APP_Framework/Framework/connection/wifi/Kconfig | 6 +++--- APP_Framework/Framework/connection/wifi/Makefile | 4 ++-- APP_Framework/Framework/connection/wifi/adapter_wifi.c | 4 ++-- .../connection/wifi/{HFA21 => hfa21_wifi}/Kconfig | 4 ++-- .../Framework/connection/{5G => wifi/hfa21_wifi}/Makefile | 2 +- .../wifi/{HFA21/hfa21.c => hfa21_wifi/hfa21_wifi.c} | 0 APP_Framework/Framework/connection/zigbee/Kconfig | 2 +- APP_Framework/Framework/connection/zigbee/Makefile | 2 +- .../Framework/connection/zigbee/{E18 => e18}/Kconfig | 0 .../Framework/connection/zigbee/{E18 => e18}/Makefile | 0 .../Framework/connection/zigbee/{E18 => e18}/e18.c | 0 .../Framework/connection/zigbee/{E18 => e18}/e18.h | 0 35 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 APP_Framework/Framework/connection/4G/Makefile rename APP_Framework/Framework/connection/{4G => 4g}/Kconfig (67%) create mode 100644 APP_Framework/Framework/connection/4g/Makefile rename APP_Framework/Framework/connection/{4G/adapter_4G.c => 4g/adapter_4g.c} (100%) rename APP_Framework/Framework/connection/{4G/EC200T => 4g/ec200t}/Kconfig (100%) rename APP_Framework/Framework/connection/{4G/EC200T => 4g/ec200t}/Makefile (100%) rename APP_Framework/Framework/connection/{4G/EC200T => 4g/ec200t}/ec200t.c (100%) rename APP_Framework/Framework/connection/{5G => 5g}/Kconfig (100%) rename APP_Framework/Framework/connection/{wifi/HFA21 => 5g}/Makefile (58%) mode change 100755 => 100644 rename APP_Framework/Framework/connection/{5G/adapter_5G.c => 5g/adapter_5g.c} (96%) rename APP_Framework/Framework/connection/bluetooth/{HC08 => hc08}/Kconfig (100%) rename APP_Framework/Framework/connection/bluetooth/{HC08 => hc08}/Makefile (100%) rename APP_Framework/Framework/connection/bluetooth/{HC08 => hc08}/hc08.c (100%) rename APP_Framework/Framework/connection/lora/{SX1278 => sx1278}/Kconfig (100%) rename APP_Framework/Framework/connection/lora/{SX1278 => sx1278}/Makefile (100%) rename APP_Framework/Framework/connection/lora/{SX1278 => sx1278}/sx1278.c (100%) rename APP_Framework/Framework/connection/nbiot/{BC28 => bc28}/Kconfig (100%) rename APP_Framework/Framework/connection/nbiot/{BC28 => bc28}/Makefile (100%) rename APP_Framework/Framework/connection/nbiot/{BC28 => bc28}/bc28.c (100%) rename APP_Framework/Framework/connection/wifi/{HFA21 => hfa21_wifi}/Kconfig (92%) rename APP_Framework/Framework/connection/{5G => wifi/hfa21_wifi}/Makefile (58%) mode change 100644 => 100755 rename APP_Framework/Framework/connection/wifi/{HFA21/hfa21.c => hfa21_wifi/hfa21_wifi.c} (100%) rename APP_Framework/Framework/connection/zigbee/{E18 => e18}/Kconfig (100%) rename APP_Framework/Framework/connection/zigbee/{E18 => e18}/Makefile (100%) rename APP_Framework/Framework/connection/zigbee/{E18 => e18}/e18.c (100%) rename APP_Framework/Framework/connection/zigbee/{E18 => e18}/e18.h (100%) diff --git a/APP_Framework/Framework/connection/4G/Makefile b/APP_Framework/Framework/connection/4G/Makefile deleted file mode 100644 index 1ef3b927..00000000 --- a/APP_Framework/Framework/connection/4G/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -SRC_FILES := adapter_4G.c - -ifeq ($(CONFIG_ADAPTER_EC200T),y) - SRC_DIR += EC200T -endif - -include $(KERNEL_ROOT)/compiler.mk \ No newline at end of file diff --git a/APP_Framework/Framework/connection/4G/Kconfig b/APP_Framework/Framework/connection/4g/Kconfig similarity index 67% rename from APP_Framework/Framework/connection/4G/Kconfig rename to APP_Framework/Framework/connection/4g/Kconfig index 95052942..17e05a97 100644 --- a/APP_Framework/Framework/connection/4G/Kconfig +++ b/APP_Framework/Framework/connection/4g/Kconfig @@ -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 diff --git a/APP_Framework/Framework/connection/4g/Makefile b/APP_Framework/Framework/connection/4g/Makefile new file mode 100644 index 00000000..436b7d97 --- /dev/null +++ b/APP_Framework/Framework/connection/4g/Makefile @@ -0,0 +1,7 @@ +SRC_FILES := adapter_4g.c + +ifeq ($(CONFIG_ADAPTER_EC200T),y) + SRC_DIR += ec200t +endif + +include $(KERNEL_ROOT)/compiler.mk \ No newline at end of file diff --git a/APP_Framework/Framework/connection/4G/adapter_4G.c b/APP_Framework/Framework/connection/4g/adapter_4g.c similarity index 100% rename from APP_Framework/Framework/connection/4G/adapter_4G.c rename to APP_Framework/Framework/connection/4g/adapter_4g.c diff --git a/APP_Framework/Framework/connection/4G/EC200T/Kconfig b/APP_Framework/Framework/connection/4g/ec200t/Kconfig similarity index 100% rename from APP_Framework/Framework/connection/4G/EC200T/Kconfig rename to APP_Framework/Framework/connection/4g/ec200t/Kconfig diff --git a/APP_Framework/Framework/connection/4G/EC200T/Makefile b/APP_Framework/Framework/connection/4g/ec200t/Makefile similarity index 100% rename from APP_Framework/Framework/connection/4G/EC200T/Makefile rename to APP_Framework/Framework/connection/4g/ec200t/Makefile diff --git a/APP_Framework/Framework/connection/4G/EC200T/ec200t.c b/APP_Framework/Framework/connection/4g/ec200t/ec200t.c similarity index 100% rename from APP_Framework/Framework/connection/4G/EC200T/ec200t.c rename to APP_Framework/Framework/connection/4g/ec200t/ec200t.c diff --git a/APP_Framework/Framework/connection/5G/Kconfig b/APP_Framework/Framework/connection/5g/Kconfig similarity index 100% rename from APP_Framework/Framework/connection/5G/Kconfig rename to APP_Framework/Framework/connection/5g/Kconfig diff --git a/APP_Framework/Framework/connection/wifi/HFA21/Makefile b/APP_Framework/Framework/connection/5g/Makefile old mode 100755 new mode 100644 similarity index 58% rename from APP_Framework/Framework/connection/wifi/HFA21/Makefile rename to APP_Framework/Framework/connection/5g/Makefile index a5c95324..5b98645c --- a/APP_Framework/Framework/connection/wifi/HFA21/Makefile +++ b/APP_Framework/Framework/connection/5g/Makefile @@ -1,3 +1,3 @@ -SRC_FILES := hfa21.c +SRC_FILES := adapter_5g.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/connection/5G/adapter_5G.c b/APP_Framework/Framework/connection/5g/adapter_5g.c similarity index 96% rename from APP_Framework/Framework/connection/5G/adapter_5G.c rename to APP_Framework/Framework/connection/5g/adapter_5g.c index ff5ff194..27485e10 100644 --- a/APP_Framework/Framework/connection/5G/adapter_5G.c +++ b/APP_Framework/Framework/connection/5g/adapter_5g.c @@ -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 diff --git a/APP_Framework/Framework/connection/Kconfig b/APP_Framework/Framework/connection/Kconfig index bd062e6f..a2ef6e64 100644 --- a/APP_Framework/Framework/connection/Kconfig +++ b/APP_Framework/Framework/connection/Kconfig @@ -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 diff --git a/APP_Framework/Framework/connection/Makefile b/APP_Framework/Framework/connection/Makefile index 328455fd..54ebc25b 100644 --- a/APP_Framework/Framework/connection/Makefile +++ b/APP_Framework/Framework/connection/Makefile @@ -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 \ No newline at end of file diff --git a/APP_Framework/Framework/connection/bluetooth/Kconfig b/APP_Framework/Framework/connection/bluetooth/Kconfig index c2daecda..cb71df57 100644 --- a/APP_Framework/Framework/connection/bluetooth/Kconfig +++ b/APP_Framework/Framework/connection/bluetooth/Kconfig @@ -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 diff --git a/APP_Framework/Framework/connection/bluetooth/Makefile b/APP_Framework/Framework/connection/bluetooth/Makefile index 29ef7fc3..bb367019 100644 --- a/APP_Framework/Framework/connection/bluetooth/Makefile +++ b/APP_Framework/Framework/connection/bluetooth/Makefile @@ -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 diff --git a/APP_Framework/Framework/connection/bluetooth/HC08/Kconfig b/APP_Framework/Framework/connection/bluetooth/hc08/Kconfig similarity index 100% rename from APP_Framework/Framework/connection/bluetooth/HC08/Kconfig rename to APP_Framework/Framework/connection/bluetooth/hc08/Kconfig diff --git a/APP_Framework/Framework/connection/bluetooth/HC08/Makefile b/APP_Framework/Framework/connection/bluetooth/hc08/Makefile similarity index 100% rename from APP_Framework/Framework/connection/bluetooth/HC08/Makefile rename to APP_Framework/Framework/connection/bluetooth/hc08/Makefile diff --git a/APP_Framework/Framework/connection/bluetooth/HC08/hc08.c b/APP_Framework/Framework/connection/bluetooth/hc08/hc08.c similarity index 100% rename from APP_Framework/Framework/connection/bluetooth/HC08/hc08.c rename to APP_Framework/Framework/connection/bluetooth/hc08/hc08.c diff --git a/APP_Framework/Framework/connection/lora/SX1278/Kconfig b/APP_Framework/Framework/connection/lora/sx1278/Kconfig similarity index 100% rename from APP_Framework/Framework/connection/lora/SX1278/Kconfig rename to APP_Framework/Framework/connection/lora/sx1278/Kconfig diff --git a/APP_Framework/Framework/connection/lora/SX1278/Makefile b/APP_Framework/Framework/connection/lora/sx1278/Makefile similarity index 100% rename from APP_Framework/Framework/connection/lora/SX1278/Makefile rename to APP_Framework/Framework/connection/lora/sx1278/Makefile diff --git a/APP_Framework/Framework/connection/lora/SX1278/sx1278.c b/APP_Framework/Framework/connection/lora/sx1278/sx1278.c similarity index 100% rename from APP_Framework/Framework/connection/lora/SX1278/sx1278.c rename to APP_Framework/Framework/connection/lora/sx1278/sx1278.c diff --git a/APP_Framework/Framework/connection/nbiot/BC28/Kconfig b/APP_Framework/Framework/connection/nbiot/bc28/Kconfig similarity index 100% rename from APP_Framework/Framework/connection/nbiot/BC28/Kconfig rename to APP_Framework/Framework/connection/nbiot/bc28/Kconfig diff --git a/APP_Framework/Framework/connection/nbiot/BC28/Makefile b/APP_Framework/Framework/connection/nbiot/bc28/Makefile similarity index 100% rename from APP_Framework/Framework/connection/nbiot/BC28/Makefile rename to APP_Framework/Framework/connection/nbiot/bc28/Makefile diff --git a/APP_Framework/Framework/connection/nbiot/BC28/bc28.c b/APP_Framework/Framework/connection/nbiot/bc28/bc28.c similarity index 100% rename from APP_Framework/Framework/connection/nbiot/BC28/bc28.c rename to APP_Framework/Framework/connection/nbiot/bc28/bc28.c diff --git a/APP_Framework/Framework/connection/wifi/Kconfig b/APP_Framework/Framework/connection/wifi/Kconfig index 3ef0316f..acda2455 100644 --- a/APP_Framework/Framework/connection/wifi/Kconfig +++ b/APP_Framework/Framework/connection/wifi/Kconfig @@ -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 diff --git a/APP_Framework/Framework/connection/wifi/Makefile b/APP_Framework/Framework/connection/wifi/Makefile index 8c5a0c86..3e08f065 100644 --- a/APP_Framework/Framework/connection/wifi/Makefile +++ b/APP_Framework/Framework/connection/wifi/Makefile @@ -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 diff --git a/APP_Framework/Framework/connection/wifi/adapter_wifi.c b/APP_Framework/Framework/connection/wifi/adapter_wifi.c index 379c7e3f..f9c27e48 100644 --- a/APP_Framework/Framework/connection/wifi/adapter_wifi.c +++ b/APP_Framework/Framework/connection/wifi/adapter_wifi.c @@ -21,7 +21,7 @@ #include #include -#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"); diff --git a/APP_Framework/Framework/connection/wifi/HFA21/Kconfig b/APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig similarity index 92% rename from APP_Framework/Framework/connection/wifi/HFA21/Kconfig rename to APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig index d61721c7..82f0489b 100755 --- a/APP_Framework/Framework/connection/wifi/HFA21/Kconfig +++ b/APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig @@ -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 diff --git a/APP_Framework/Framework/connection/5G/Makefile b/APP_Framework/Framework/connection/wifi/hfa21_wifi/Makefile old mode 100644 new mode 100755 similarity index 58% rename from APP_Framework/Framework/connection/5G/Makefile rename to APP_Framework/Framework/connection/wifi/hfa21_wifi/Makefile index 9ce9e188..5304916d --- a/APP_Framework/Framework/connection/5G/Makefile +++ b/APP_Framework/Framework/connection/wifi/hfa21_wifi/Makefile @@ -1,3 +1,3 @@ -SRC_FILES := adapter_5G.c +SRC_FILES := hfa21_wifi.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/connection/wifi/HFA21/hfa21.c b/APP_Framework/Framework/connection/wifi/hfa21_wifi/hfa21_wifi.c similarity index 100% rename from APP_Framework/Framework/connection/wifi/HFA21/hfa21.c rename to APP_Framework/Framework/connection/wifi/hfa21_wifi/hfa21_wifi.c diff --git a/APP_Framework/Framework/connection/zigbee/Kconfig b/APP_Framework/Framework/connection/zigbee/Kconfig index 8656d3c0..42619008 100644 --- a/APP_Framework/Framework/connection/zigbee/Kconfig +++ b/APP_Framework/Framework/connection/zigbee/Kconfig @@ -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 diff --git a/APP_Framework/Framework/connection/zigbee/Makefile b/APP_Framework/Framework/connection/zigbee/Makefile index db3ac987..316cd2d0 100644 --- a/APP_Framework/Framework/connection/zigbee/Makefile +++ b/APP_Framework/Framework/connection/zigbee/Makefile @@ -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 diff --git a/APP_Framework/Framework/connection/zigbee/E18/Kconfig b/APP_Framework/Framework/connection/zigbee/e18/Kconfig similarity index 100% rename from APP_Framework/Framework/connection/zigbee/E18/Kconfig rename to APP_Framework/Framework/connection/zigbee/e18/Kconfig diff --git a/APP_Framework/Framework/connection/zigbee/E18/Makefile b/APP_Framework/Framework/connection/zigbee/e18/Makefile similarity index 100% rename from APP_Framework/Framework/connection/zigbee/E18/Makefile rename to APP_Framework/Framework/connection/zigbee/e18/Makefile diff --git a/APP_Framework/Framework/connection/zigbee/E18/e18.c b/APP_Framework/Framework/connection/zigbee/e18/e18.c similarity index 100% rename from APP_Framework/Framework/connection/zigbee/E18/e18.c rename to APP_Framework/Framework/connection/zigbee/e18/e18.c diff --git a/APP_Framework/Framework/connection/zigbee/E18/e18.h b/APP_Framework/Framework/connection/zigbee/e18/e18.h similarity index 100% rename from APP_Framework/Framework/connection/zigbee/E18/e18.h rename to APP_Framework/Framework/connection/zigbee/e18/e18.h