diff --git a/APP_Framework/Framework/connection/SConscript b/APP_Framework/Framework/connection/SConscript new file mode 100644 index 000000000..4150ca779 --- /dev/null +++ b/APP_Framework/Framework/connection/SConscript @@ -0,0 +1,21 @@ +import os +Import('RTT_ROOT') +Import('rtconfig') +from building import * + +cwd = GetCurrentDir() +SOURCES = [] +if GetDepend(['SUPPORT_CONNECTION_FRAMEWORK']): + SOURCES = ['adapter.c'] +['adapter_agent.c']+ SOURCES +path = [cwd] +objs = [] +group = DefineGroup('connection', SOURCES, depend = [], CPPPATH = [cwd]) +objs = objs + group +list = os.listdir(cwd) +if GetDepend(['SUPPORT_CONNECTION_FRAMEWORK']): + for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(path, 'SConscript')) + +Return('objs') diff --git a/APP_Framework/Framework/connection/adapter.c b/APP_Framework/Framework/connection/adapter.c index 6d3d8f227..96d93c828 100644 --- a/APP_Framework/Framework/connection/adapter.c +++ b/APP_Framework/Framework/connection/adapter.c @@ -22,7 +22,7 @@ static DoublelistType adapter_list; -static int adapter_list_lock; +static pthread_mutex_t adapter_list_lock; /** * @description: Init adapter framework @@ -481,6 +481,7 @@ int AdapterDeviceDisconnect(struct Adapter *adapter, unsigned char *priv_net_gro */ int AdapterDeviceSetUp(struct Adapter *adapter) { + if (!adapter) return -1; @@ -488,10 +489,10 @@ int AdapterDeviceSetUp(struct Adapter *adapter) struct IpProtocolDone *ip_done = NULL; struct PrivProtocolDone *priv_done = NULL; - switch (adapter->net_protocol) { case PRIVATE_PROTOCOL: + priv_done = (struct PrivProtocolDone *)adapter->done; if (NULL == priv_done->setup) return 0; @@ -515,6 +516,7 @@ int AdapterDeviceSetUp(struct Adapter *adapter) return 0; result = ip_done->setup(adapter); + if (0 == result) { printf("Device %s setup success.\n", adapter->name); adapter->adapter_status = INSTALL; diff --git a/APP_Framework/Framework/connection/adapter_agent.c b/APP_Framework/Framework/connection/adapter_agent.c index 29b4cae8f..5c0222847 100755 --- a/APP_Framework/Framework/connection/adapter_agent.c +++ b/APP_Framework/Framework/connection/adapter_agent.c @@ -29,6 +29,8 @@ #ifdef ADD_XIZI_FETURES # include #endif +#ifdef ADD_RTTHREAD_FETURES +#include #define AT_CMD_MAX_LEN 128 #define AT_AGENT_MAX 2 @@ -139,7 +141,7 @@ int ATOrderSend(ATAgentType agent, uint32_t timeout_s, ATReplyType reply, const PrivMutexObtain(&agent->lock); agent->receive_mode = AT_MODE; - + memset(agent->maintain_buffer, 0x00, agent->maintain_max); agent->maintain_len = 0; @@ -300,7 +302,7 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s) //PrivTaskDelay(1000); if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) { printf("wait sem[%d] timeout\n",agent->entm_rx_notice); - return -ERROR; + return -1; } PrivMutexObtain(&agent->lock); @@ -390,7 +392,7 @@ static int GetCompleteATReply(ATAgentType agent) memset(agent->maintain_buffer, 0x00, agent->maintain_max); agent->maintain_len = 0; PrivMutexAbandon(&agent->lock); - return -ERROR; + return -1; } printf("GetCompleteATReply done\n"); @@ -449,10 +451,10 @@ int DeleteATAgent(ATAgentType agent) PrivSemaphoreDelete(&agent->entm_rx_notice); } - if (agent->rsp_sem) { - printf("delete agent rsp_sem = %d\n",agent->rsp_sem); - PrivSemaphoreDelete(&agent->rsp_sem); - } + // if (agent->rsp_sem) { + // printf("delete agent rsp_sem = %d\n",agent->rsp_sem); + // PrivSemaphoreDelete(&agent->rsp_sem); + // } if (agent->maintain_buffer) { PrivFree(agent->maintain_buffer); diff --git a/APP_Framework/Framework/connection/at_agent.h b/APP_Framework/Framework/connection/at_agent.h index c98428573..7f82f511a 100755 --- a/APP_Framework/Framework/connection/at_agent.h +++ b/APP_Framework/Framework/connection/at_agent.h @@ -42,7 +42,6 @@ struct ATReply uint32 reply_len; }; typedef struct ATReply *ATReplyType; - struct ATAgent { char agent_name[64]; @@ -56,7 +55,7 @@ struct ATAgent #ifdef ADD_NUTTX_FETURES pthread_mutex_t lock; #else - int lock; + pthread_mutex_t lock; #endif ATReplyType reply; @@ -64,7 +63,33 @@ struct ATAgent char reply_end_last_char; char reply_end_char; uint32 reply_char_num; - int rsp_sem; + sem_t rsp_sem; + + pthread_t at_handler; + + #define ENTM_RECV_MAX 256 + char entm_recv_buf[ENTM_RECV_MAX]; + uint32 entm_recv_len; + enum ReceiveMode receive_mode; + int entm_rx_notice; +}; +typedef struct ATAgent *ATAgentType; + +int EntmSend(ATAgentType agent, const char *data, int len); +int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s); +char *GetReplyText(ATReplyType reply); +int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch); +int AtSetReplyCharNum(ATAgentType agent, unsigned int num); +int AtSetReplyLrEnd(ATAgentType agent, char enable); +ATReplyType CreateATReply(uint32 reply_max_len); +unsigned int IpTint(char *ipstr); +void SwapStr(char *str, int begin, int end); +char* IpTstr(unsigned int ipint); +ATAgentType GetATAgent(const char *agent_name); +int InitATAgent(const char *agent_name, int fd, uint32 maintain_max); +int DeleteATAgent(ATAgentType agent); +int ParseATReply(char* str, const char *format, ...); +void DeleteATReply(ATReplyType reply); pthread_t at_handler; diff --git a/APP_Framework/Framework/connection/bluetooth/SConscript b/APP_Framework/Framework/connection/bluetooth/SConscript new file mode 100644 index 000000000..3fecfb61c --- /dev/null +++ b/APP_Framework/Framework/connection/bluetooth/SConscript @@ -0,0 +1,18 @@ +import os +Import('RTT_ROOT') +from building import * +SOURCES = [] +SOURCES = ['adapter_bluetooth.c'] + SOURCES +objs = [] +cwd = GetCurrentDir() +path = [cwd] +group = DefineGroup('bluetooth', SOURCES, depend = [], CPPPATH = [cwd]) +objs = objs + group +list = os.listdir(cwd) + +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(path, 'SConscript')) + +Return('objs') \ No newline at end of file diff --git a/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c b/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c index b8cc0694e..8b2c87bbb 100644 --- a/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c +++ b/APP_Framework/Framework/connection/bluetooth/adapter_bluetooth.c @@ -78,13 +78,13 @@ int AdapterBlueToothInit(void) return ret; } -/******************4G TEST*********************/ +/******************BT TEST*********************/ int AdapterBlueToothTest(void) { const char *bluetooth_msg = "BT Adapter Test"; char bluetooth_recv_msg[128]; int len; - int baud_rate = BAUD_RATE_115200; + int baud_rate = BAUD_RATE_9600; struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_BLUETOOTH_NAME); @@ -99,7 +99,7 @@ int AdapterBlueToothTest(void) printf("bluetooth_recv_msg %s\n", bluetooth_recv_msg); AdapterDeviceSend(adapter, bluetooth_msg, len); printf("send %s after recv\n", bluetooth_msg); - PrivTaskDelay(100); + PrivTaskDelay(1000); memset(bluetooth_recv_msg, 0, 128); } @@ -107,4 +107,9 @@ int AdapterBlueToothTest(void) return 0; } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterBlueToothTest, AdapterBlueToothTest, show adapter BT information); +#ifdef ADD_RTTHREAD_FETURES +MSH_CMD_EXPORT(AdapterBlueToothTest,a bt adpter sample); +#endif +#ifdef ADD_XIZI_FETURES +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterWifiTest, AdapterWifiTest, show adapter wifi information); +#endif \ No newline at end of file diff --git a/APP_Framework/Framework/connection/bluetooth/hc08/Kconfig b/APP_Framework/Framework/connection/bluetooth/hc08/Kconfig index 49a84ed96..8b17e83dd 100644 --- a/APP_Framework/Framework/connection/bluetooth/hc08/Kconfig +++ b/APP_Framework/Framework/connection/bluetooth/hc08/Kconfig @@ -36,5 +36,9 @@ if ADD_NUTTX_FETURES endif if ADD_RTTHREAD_FETURES - + config ADAPTER_HC08_DRIVER + string "HC08 device uart driver path" + default "/dev/uart4" + config ADAPTER_HC08_WORK_ROLE + string "HC08 work role M(MASTER) or S(SLAVER)" endif diff --git a/APP_Framework/Framework/connection/bluetooth/hc08/SConscript b/APP_Framework/Framework/connection/bluetooth/hc08/SConscript new file mode 100644 index 000000000..5f904f361 --- /dev/null +++ b/APP_Framework/Framework/connection/bluetooth/hc08/SConscript @@ -0,0 +1,10 @@ +from building import * +import os + +cwd = GetCurrentDir() +src = [] +if GetDepend(['ADAPTER_HC08']): + src += ['hc08.c'] +group = DefineGroup('connection bluetooth hc08', src, depend = [], CPPPATH = [cwd]) + +Return('group') \ 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 ddba196ab..bc20ef8bc 100644 --- a/APP_Framework/Framework/connection/bluetooth/hc08/hc08.c +++ b/APP_Framework/Framework/connection/bluetooth/hc08/hc08.c @@ -92,7 +92,7 @@ static int Hc08AtConfigure(ATAgentType agent, enum Hc08AtCmd hc08_at_cmd, void * ATReplyType reply = CreateATReply(64); if (NULL == reply) { printf("Hc08AtConfigure CreateATReply failed !\n"); - return -ENOMEMORY; + return -5; } switch (hc08_at_cmd) @@ -152,20 +152,20 @@ static int Hc08AtConfigure(ATAgentType agent, enum Hc08AtCmd hc08_at_cmd, void * ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_ROLE_CMD); reply_ok_flag = 0; break; - // case HC08_AT_CMD_SET_ADDR: - // ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_SET_ROLE_CMD); - // break; - // case HC08_AT_CMD_GET_ADDR: - // ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_ROLE_CMD); - // reply_ok_flag = 0; - // break; - // case HC08_AT_CMD_SET_NAME: - // ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_SET_NAME_CMD); - // break; - // case HC08_AT_CMD_GET_NAME: - // ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_NAME_CMD); - // reply_ok_flag = 0; - // break; + case HC08_AT_CMD_SET_ADDR: + ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_SET_ROLE_CMD); + break; + case HC08_AT_CMD_GET_ADDR: + ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_ROLE_CMD); + reply_ok_flag = 0; + break; + case HC08_AT_CMD_SET_NAME: + ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_SET_NAME_CMD); + break; + case HC08_AT_CMD_GET_NAME: + ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_NAME_CMD); + reply_ok_flag = 0; + break; default: printf("hc08 do not support no.%d cmd\n", hc08_at_cmd); DeleteATReply(reply); @@ -209,7 +209,7 @@ static int Hc08Open(struct Adapter *adapter) if (!adapter->agent) { char *agent_name = "bluetooth_uart_client"; printf("InitATAgent agent_name %s fd %u\n", agent_name, adapter->fd); - if (EOK != InitATAgent(agent_name, adapter->fd, 512)) { + if (0 != InitATAgent(agent_name, adapter->fd, 512)) { printf("at agent init failed !\n"); return -1; } @@ -343,7 +343,7 @@ static int Hc08Connect(struct Adapter *adapter, enum NetRoleType net_role, const static int Hc08Send(struct Adapter *adapter, const void *buf, size_t len) { - x_err_t result = EOK; + long result = 0; if (adapter->agent) { EntmSend(adapter->agent, (const char *)buf, len); } else { diff --git a/APP_Framework/Framework/connection/wifi/SConscript b/APP_Framework/Framework/connection/wifi/SConscript new file mode 100644 index 000000000..49378ad9f --- /dev/null +++ b/APP_Framework/Framework/connection/wifi/SConscript @@ -0,0 +1,18 @@ +import os +Import('RTT_ROOT') +from building import * +SOURCES = [] +SOURCES = ['adapter_wifi.c'] + SOURCES +objs = [] +cwd = GetCurrentDir() +path = [cwd] +group = DefineGroup('wifi', SOURCES, depend = [], CPPPATH = [cwd]) +objs = objs + group +list = os.listdir(cwd) + +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(path, 'SConscript')) + +Return('objs') \ No newline at end of file diff --git a/APP_Framework/Framework/connection/wifi/adapter_wifi.c b/APP_Framework/Framework/connection/wifi/adapter_wifi.c index 2b9dddc76..6e4a8c1be 100644 --- a/APP_Framework/Framework/connection/wifi/adapter_wifi.c +++ b/APP_Framework/Framework/connection/wifi/adapter_wifi.c @@ -22,6 +22,7 @@ #include "adapter_wifi.h" #include + #ifdef ADAPTER_HFA21_WIFI extern AdapterProductInfoType Hfa21WifiAttach(struct Adapter *adapter); #endif @@ -107,30 +108,30 @@ int AdapterwifiTest(void) #ifdef ADAPTER_HFA21_DRIVER_EXT_PORT - // static BusType ch438_pin; - // ch438_pin = PinBusInitGet(); - // struct PinParam pin_cfg; - // int ret = 0; + static BusType ch438_pin; + ch438_pin = PinBusInitGet(); + struct PinParam pin_cfg; + int ret = 0; - // struct BusConfigureInfo configure_info; - // configure_info.configure_cmd = OPE_CFG; - // configure_info.private_data = (void *)&pin_cfg; + struct BusConfigureInfo configure_info; + configure_info.configure_cmd = OPE_CFG; + configure_info.private_data = (void *)&pin_cfg; - // pin_cfg.cmd = GPIO_CONFIG_MODE; - // pin_cfg.pin = 22; - // pin_cfg.mode = GPIO_CFG_OUTPUT; + pin_cfg.cmd = GPIO_CONFIG_MODE; + pin_cfg.pin = 22; + pin_cfg.mode = GPIO_CFG_OUTPUT; - // ret = BusDrvConfigure(ch438_pin->owner_driver, &configure_info); + ret = BusDrvConfigure(ch438_pin->owner_driver, &configure_info); - // struct PinStat pin_stat; - // struct BusBlockWriteParam write_param; - // struct BusBlockReadParam read_param; - // write_param.buffer = (void *)&pin_stat; + struct PinStat pin_stat; + struct BusBlockWriteParam write_param; + struct BusBlockReadParam read_param; + write_param.buffer = (void *)&pin_stat; - // pin_stat.val = GPIO_HIGH; + pin_stat.val = GPIO_HIGH; - // pin_stat.pin = 22; - // BusDevWriteData(ch438_pin->owner_haldev, &write_param); + pin_stat.pin = 22; + BusDevWriteData(ch438_pin->owner_haldev, &write_param); int pin_fd; pin_fd = PrivOpen("/dev/pin_dev", O_RDWR); @@ -168,7 +169,7 @@ int AdapterwifiTest(void) enum IpType ip_type = IPV4; AdapterDeviceConnect(adapter, net_role, ip, port, ip_type); - const char *wifi_msg = "LiuKai Test"; + const char *wifi_msg = "Wifi Test"; int len = strlen(wifi_msg); for(int i = 0;i < 10; ++i) { AdapterDeviceSend(adapter, wifi_msg, len); @@ -176,12 +177,19 @@ int AdapterwifiTest(void) } char wifi_recv_msg[128]; - while (1) { + for(int j=0;j<10;++j){ AdapterDeviceRecv(adapter, wifi_recv_msg, 128); + PrivTaskDelay(1000); } } -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterwifiTest, AdapterwifiTest, show adapter wifi information); + +#ifdef ADD_RTTHREAD_FETURES +MSH_CMD_EXPORT(AdapterWifiTest,a wifi adpter sample); +#endif +#ifdef ADD_XIZI_FETURES +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterWifiTest, AdapterWifiTest, show adapter wifi information); +#endif int wifiopen(void) { diff --git a/APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig b/APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig index b4fff97ac..cc248bd79 100755 --- a/APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig +++ b/APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig @@ -29,5 +29,7 @@ if ADD_NUTTX_FETURES endif if ADD_RTTHREAD_FETURES - + config ADAPTER_HFA21_DRIVER + string "HFA21 device uart driver path" + default "/dev/uart3" endif diff --git a/APP_Framework/Framework/connection/wifi/hfa21_wifi/SConscript b/APP_Framework/Framework/connection/wifi/hfa21_wifi/SConscript new file mode 100644 index 000000000..093664350 --- /dev/null +++ b/APP_Framework/Framework/connection/wifi/hfa21_wifi/SConscript @@ -0,0 +1,10 @@ +from building import * +import os + +cwd = GetCurrentDir() +src = [] +if GetDepend(['ADAPTER_HFA21_WIFI']): + src += ['hfa21_wifi.c'] +group = DefineGroup('connection wifi hfa21', src, depend = [], CPPPATH = [cwd]) + +Return('group') \ No newline at end of file diff --git a/APP_Framework/Framework/connection/wifi/hfa21_wifi/hfa21_wifi.c b/APP_Framework/Framework/connection/wifi/hfa21_wifi/hfa21_wifi.c index 1d1ad2df4..2cc263416 100755 --- a/APP_Framework/Framework/connection/wifi/hfa21_wifi/hfa21_wifi.c +++ b/APP_Framework/Framework/connection/wifi/hfa21_wifi/hfa21_wifi.c @@ -20,7 +20,8 @@ #include #include - +#include +#include #define LEN_PARA_BUF 128 static int Hfa21WifiSetDown(struct Adapter *adapter_at); @@ -28,10 +29,11 @@ static int Hfa21WifiSetDown(struct Adapter *adapter_at); /** * @description: enter AT command mode * @param at_agent - wifi device agent pointer - * @return success: EOK + * @return success: 0 */ static int Hfa21WifiInitAtCmd(ATAgentType at_agent) { + ATOrderSend(at_agent, REPLY_TIME_OUT, NULL, "+++"); PrivTaskDelay(100); @@ -44,7 +46,7 @@ static int Hfa21WifiInitAtCmd(ATAgentType at_agent) /** * @description: Open wifi * @param adapter - wifi device pointer - * @return success: EOK, failure: ENOMEMORY + * @return success: 0, failure: 5 */ static int Hfa21WifiOpen(struct Adapter *adapter) { @@ -58,7 +60,7 @@ static int Hfa21WifiOpen(struct Adapter *adapter) /*step2: init AT agent*/ if (!adapter->agent) { char *agent_name = "wifi_uart_client"; - if (EOK != InitATAgent(agent_name, adapter->fd, 512)) { + if (0 != InitATAgent(agent_name, adapter->fd, 512)) { printf("at agent init failed !\n"); return -1; } @@ -75,7 +77,7 @@ static int Hfa21WifiOpen(struct Adapter *adapter) /** * @description: Close wifi * @param adapter - wifi device pointer - * @return success: EOK + * @return success: 0 */ static int Hfa21WifiClose(struct Adapter *adapter) { @@ -87,11 +89,11 @@ static int Hfa21WifiClose(struct Adapter *adapter) * @param adapter - wifi device pointer * @param data - data buffer * @param data - data length - * @return success: EOK + * @return success: 0 */ static int Hfa21WifiSend(struct Adapter *adapter, const void *data, size_t len) { - x_err_t result = EOK; + long result = 0; if (adapter->agent) { EntmSend(adapter->agent, (const char *)data, len); }else { @@ -108,11 +110,11 @@ __exit: * @param adapter - wifi device pointer * @param data - data buffer * @param data - data length - * @return success: EOK + * @return success: 0 */ static int Hfa21WifiReceive(struct Adapter *adapter, void *rev_buffer, size_t buffer_len) { - x_err_t result = EOK; + long result = 0; printf("hfa21 receive waiting ... \n"); if (adapter->agent) { @@ -129,20 +131,19 @@ __exit: /** * @description: connnect wifi to internet * @param adapter - wifi device pointer - * @return success: EOK + * @return success: 0 */ static int Hfa21WifiSetUp(struct Adapter *adapter) { uint8 wifi_ssid[LEN_PARA_BUF] = "AIIT-Guest"; uint8 wifi_pwd[LEN_PARA_BUF] = ""; char cmd[LEN_PARA_BUF]; - + struct ATAgent *agent = adapter->agent; - + /* wait hfa21 device startup finish */ PrivTaskDelay(5000); - - Hfa21WifiInitAtCmd(agent); + Hfa21WifiInitAtCmd(agent);//err memset(cmd,0,sizeof(cmd)); strcpy(cmd,"AT+FCLR\r"); @@ -181,7 +182,7 @@ static int Hfa21WifiSetUp(struct Adapter *adapter) /** * @description: disconnnect wifi from internet * @param adapter - wifi device pointer - * @return success: EOK + * @return success: 0 */ static int Hfa21WifiSetDown(struct Adapter *adapter) { @@ -199,7 +200,7 @@ static int Hfa21WifiSetDown(struct Adapter *adapter) * @param ip - ip address * @param gateway - gateway address * @param netmask - netmask address - * @return success: EOK, failure: ENOMEMORY + * @return success: 0, failure: 5 */ static int Hfa21WifiSetAddr(struct Adapter *adapter, const char *ip, const char *gateway, const char *netmask) { @@ -216,12 +217,12 @@ static int Hfa21WifiSetAddr(struct Adapter *adapter, const char *ip, const char Hfa21WifiInitAtCmd(adapter->agent); - x_err_t result = EOK; + long result = 0; ATReplyType reply = CreateATReply(64); if (NULL == reply) { printf("at_create_resp failed ! \n"); - result = ENOMEMORY; + result = 5; goto __exit; } @@ -253,12 +254,12 @@ __exit: * @description: wifi ping function * @param adapter - wifi device pointer * @param destination - domain name or ip address - * @return success: EOK, failure: ENOMEMORY + * @return success: 0, failure: 5 */ static int Hfa21WifiPing(struct Adapter *adapter, const char *destination) { - char *ping_result = NONE; - char *dst = NONE; + char *ping_result = (0); + char *dst = (0); ping_result = (char *) PrivCalloc(1, 17); dst = (char *) PrivCalloc(1, 17); strcpy(dst, destination); @@ -266,12 +267,12 @@ static int Hfa21WifiPing(struct Adapter *adapter, const char *destination) Hfa21WifiInitAtCmd(adapter->agent); - uint32 result = EOK; + uint32 result = 0; ATReplyType reply = CreateATReply(64); if (NULL == reply) { printf("at_create_resp failed ! \n"); - result = ENOMEMORY; + result = 5; goto __exit; } @@ -302,7 +303,7 @@ __exit: /** * @description: display wifi network configuration * @param adapter - wifi device pointer - * @return success: EOK, failure: ENOMEMORY + * @return success: 0, failure: 5 */ static int Hfa21WifiNetstat(struct Adapter *adapter) { @@ -334,7 +335,7 @@ static int Hfa21WifiNetstat(struct Adapter *adapter) reply = CreateATReply(HFA21_NETSTAT_RESP_SIZE); if (reply == NULL) { - result = ENOMEMORY; + result = 5; goto __exit; } @@ -384,7 +385,7 @@ static int Hfa21WifiNetstat(struct Adapter *adapter) else printf("local ip: %s\nnetmask: %s\n", local_ipaddr, netmask); - return EOK; + return 0; __exit: if (reply) @@ -410,15 +411,15 @@ __exit: */ static int Hfa21WifiConnect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type) { - int result = EOK; - ATReplyType reply = NONE; + int result = 0; + ATReplyType reply = (0); char cmd[LEN_PARA_BUF]; struct ATAgent *agent = adapter->agent; reply = CreateATReply(64); - if (reply == NONE) { + if (reply == (0)) { printf("no memory for reply struct."); - return ENOMEMORY; + return 5; } Hfa21WifiInitAtCmd(adapter->agent); @@ -505,7 +506,7 @@ static const struct IpProtocolDone hfa21_wifi_done = /** * @description: Register wifi device hfa21 - * @return success: EOK, failure: ERROR + * @return success: 0, failure: ERROR */ AdapterProductInfoType Hfa21WifiAttach(struct Adapter *adapter) { diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/.config b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/.config index aa3ade701..a6863efd4 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/.config +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/.config @@ -285,8 +285,8 @@ CONFIG_BSP_USING_GPIO=y CONFIG_BSP_USING_UART=y CONFIG_BSP_USING_UART1=y # CONFIG_BSP_USING_UART2 is not set -# CONFIG_BSP_USING_UART3 is not set -# CONFIG_BSP_USING_UART4 is not set +CONFIG_BSP_USING_UART3=y +CONFIG_BSP_USING_UART4=y # CONFIG_BSP_USING_I2C1 is not set # CONFIG_BSP_USING_SPI is not set # CONFIG_BSP_USING_CH438 is not set @@ -317,11 +317,27 @@ CONFIG_USB_DEVICE_NAME="usb_dev" # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -CONFIG_ADD_XIZI_FETURES=y +# CONFIG_ADD_XIZI_FETURES is not set # CONFIG_ADD_NUTTX_FETURES is not set -# CONFIG_ADD_RTTHREAD_FETURES is not set +CONFIG_ADD_RTTHREAD_FETURES=y # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set -# CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set +CONFIG_SUPPORT_CONNECTION_FRAMEWORK=y +CONFIG_CONNECTION_FRAMEWORK_DEBUG=y +# CONFIG_CONNECTION_INDUSTRIAL_ETHERNET is not set +# CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS is not set +# CONFIG_CONNECTION_INDUSTRIAL_WLAN is not set +# CONFIG_CONNECTION_ADAPTER_LORA is not set +# CONFIG_CONNECTION_ADAPTER_4G is not set +# CONFIG_CONNECTION_ADAPTER_NB is not set +# CONFIG_CONNECTION_ADAPTER_WIFI is not set +# CONFIG_CONNECTION_ADAPTER_ETHERNET is not set +CONFIG_CONNECTION_ADAPTER_BLUETOOTH=y +CONFIG_ADAPTER_HC08=y +CONFIG_ADAPTER_BLUETOOTH_HC08="hc08" +CONFIG_ADAPTER_HC08_WORK_ROLE="M" +CONFIG_ADAPTER_HC08_DRIVER="/dev/uart4" +# CONFIG_CONNECTION_ADAPTER_ZIGBEE is not set +# CONFIG_CONNECTION_ADAPTER_5G is not set # CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set # CONFIG_SUPPORT_CONTROL_FRAMEWORK is not set diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/rtconfig.h b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/rtconfig.h index da4679060..8d36278d9 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/rtconfig.h +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/rtconfig.h @@ -174,6 +174,8 @@ #define BSP_USING_GPIO #define BSP_USING_UART #define BSP_USING_UART1 +#define BSP_USING_UART3 +#define BSP_USING_UART4 #define BSP_USING_USB #define BSP_USING_STM32_USBH #define USB_BUS_NAME "usb" @@ -191,7 +193,14 @@ /* Framework */ #define TRANSFORM_LAYER_ATTRIUBUTE -#define ADD_XIZI_FETURES +#define ADD_RTTHREAD_FETURES +#define SUPPORT_CONNECTION_FRAMEWORK +#define CONNECTION_FRAMEWORK_DEBUG +#define CONNECTION_ADAPTER_BLUETOOTH +#define ADAPTER_HC08 +#define ADAPTER_BLUETOOTH_HC08 "hc08" +#define ADAPTER_HC08_WORK_ROLE "M" +#define ADAPTER_HC08_DRIVER "/dev/uart4" /* Security */ diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/test/IMG_1079.HEIC.JPG.JPG b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/test/IMG_1079.HEIC.JPG.JPG new file mode 100644 index 000000000..798ad1893 Binary files /dev/null and b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/test/IMG_1079.HEIC.JPG.JPG differ diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/test/IMG_1080.PNG.JPG b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/test/IMG_1080.PNG.JPG new file mode 100644 index 000000000..f8379df87 Binary files /dev/null and b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/test/IMG_1080.PNG.JPG differ diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/.config b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/.config index d47741477..a10457d8d 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/.config +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/.config @@ -149,7 +149,7 @@ CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512 CONFIG_RT_DFS_ELM_REENTRANT=y CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 CONFIG_RT_USING_DFS_DEVFS=y -# CONFIG_RT_USING_DFS_ROMFS is not set +CONFIG_RT_USING_DFS_ROMFS=y # CONFIG_RT_USING_DFS_RAMFS is not set # CONFIG_RT_USING_DFS_NFS is not set diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/SConscript b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/SConscript index bf9a14de1..805811108 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/SConscript +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/SConscript @@ -15,6 +15,9 @@ if GetDepend('BSP_USING_PHY') and GetDepend('PHY_USING_8720A'): src += ['./ports/LAN8720A.c'] if GetDepend('BSP_USING_SDCARD'): src += ['./ports/sdcard_port.c'] +if GetDepend(['RT_USING_DFS_ROMFS']): + src += ['ports/romfs.c'] + src += ['ports/mnt_romfs.c'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) Return('group') diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/board.c b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/board.c index 93659f924..48db851df 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/board.c +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/board.c @@ -1093,3 +1093,10 @@ void rt_hw_us_delay(rt_uint32_t usec) { ; } + +static int reboot(void) +{ + NVIC_SystemReset(); + return 0; +} +MSH_CMD_EXPORT(reboot, reboot system); \ No newline at end of file diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/linker_scripts/link.lds b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/linker_scripts/link.lds index b8c229ae3..f8cc5f191 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/linker_scripts/link.lds +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/linker_scripts/link.lds @@ -226,7 +226,7 @@ SECTIONS __noncachedata_init_end__ = .; /* create a global symbol at initialized ncache data end */ } > m_nocache . = __noncachedata_init_end__; - .ncache : + .ncache(NOLOAD): { *(NonCacheable) . = ALIGN(4); diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/ports/mnt_romfs.c b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/ports/mnt_romfs.c new file mode 100644 index 000000000..64e931584 --- /dev/null +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/ports/mnt_romfs.c @@ -0,0 +1,20 @@ +#include +#if defined RT_USING_DFS && defined RT_USING_DFS_ROMFS +#include +#include "dfs_romfs.h" + +int mnt_init(void) +{ + if (dfs_mount(RT_NULL, "/", "rom", 0, &(romfs_root)) == 0) + { + rt_kprintf("ROM file system initializated!\n"); + } + else + { + rt_kprintf("ROM file system initializate failed!\n"); + } + + return 0; +} +INIT_ENV_EXPORT(mnt_init); +#endif \ No newline at end of file diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/ports/romfs.c b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/ports/romfs.c new file mode 100644 index 000000000..deaa3c6bc --- /dev/null +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/ports/romfs.c @@ -0,0 +1,18 @@ +/* Generated by mkromfs. Edit with caution. */ +#include +#include + + + +static const rt_uint8_t _romfs_root_romfstest_txt[] = { +0x68,0x65,0x6c,0x6c,0x6f,0x20,0x78,0x69,0x64,0x61,0x74,0x6f,0x6e,0x67,0x0d,0x0a +}; + +static const struct romfs_dirent _romfs_root[] = { + {ROMFS_DIRENT_DIR, "SD", RT_NULL, 0}, + {ROMFS_DIRENT_FILE, "romfstest.txt", (rt_uint8_t *)_romfs_root_romfstest_txt, sizeof(_romfs_root_romfstest_txt)/sizeof(_romfs_root_romfstest_txt[0])} +}; + +const struct romfs_dirent romfs_root = { + ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root)/sizeof(_romfs_root[0]) +}; diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/ports/sdcard_port.c b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/ports/sdcard_port.c index 084394790..62cf5deda 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/ports/sdcard_port.c +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/board/ports/sdcard_port.c @@ -1,4 +1,3 @@ - #include #include #include "drv_gpio.h" @@ -15,7 +14,11 @@ int sd_mount() if (result == MMCSD_HOST_PLUGED) { /* mount sd card fat partition 1 as root directory */ - if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) + #ifdef RT_USING_DFS_ROMFS + if(dfs_mount("sd0", "/SD", "elm", 0, 0) == 0) + #else + if(dfs_mount("sd0", "/", "elm", 0, 0) == 0) + #endif { LOG_I("File System initialized!\n"); return RT_EOK; diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/rtconfig.h b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/rtconfig.h index 565db313f..e8716b183 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/rtconfig.h +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/rtconfig.h @@ -101,6 +101,7 @@ #define RT_DFS_ELM_REENTRANT #define RT_DFS_ELM_MUTEX_TIMEOUT 3000 #define RT_USING_DFS_DEVFS +#define RT_USING_DFS_ROMFS /* Device Drivers */ diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/rtconfig.py b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/rtconfig.py index 02b8e1933..098d3bbdc 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/rtconfig.py +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong/rtconfig.py @@ -53,6 +53,9 @@ if PLATFORM == 'gcc': CPATH = '' LPATH = '' + AFLAGS += ' -D__STARTUP_INITIALIZE_NONCACHEDATA' + AFLAGS += ' -D__STARTUP_CLEAR_BSS' + if BUILD == 'debug': CFLAGS += ' -gdwarf-2' AFLAGS += ' -gdwarf-2'