summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authoryangjie <[email protected]>2019-07-27 18:08:11 +0800
committeryangjie <[email protected]>2019-07-27 18:08:11 +0800
commit66abaa3818dc6fddb6b505e336e33890ea037bf3 (patch)
treeb2bfa8026338252398daa273b9bac6d620a061eb /components
parentc794ac0255b0347cfd98b5751155cbfba1edc6b0 (diff)
parent5180262010f5ed76f757125a75d54d37c289d022 (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread into dma
Diffstat (limited to 'components')
-rwxr-xr-xcomponents/drivers/Kconfig6
-rw-r--r--components/drivers/serial/serial.c8
-rw-r--r--components/drivers/wlan/wlan_cmd.c4
-rw-r--r--components/drivers/wlan/wlan_dev.c12
-rw-r--r--components/drivers/wlan/wlan_lwip.c31
-rw-r--r--components/drivers/wlan/wlan_mgnt.c8
-rw-r--r--components/drivers/wlan/wlan_mgnt.h4
-rw-r--r--components/libc/compilers/dlib/sys/errno.h16
-rw-r--r--components/libc/compilers/dlib/sys/signal.h16
-rw-r--r--components/libc/compilers/dlib/sys/unistd.h8
-rw-r--r--components/net/sal_socket/impl/af_inet_lwip.c2
11 files changed, 85 insertions, 30 deletions
diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig
index 56e5b8373a..4aceee3b4e 100755
--- a/components/drivers/Kconfig
+++ b/components/drivers/Kconfig
@@ -471,6 +471,12 @@ menuconfig RT_USING_WIFI
select RT_WLAN_CFG_ENABLE
select RT_WLAN_WORK_THREAD_ENABLE
default y
+
+ if RT_WLAN_AUTO_CONNECT_ENABLE
+ config AUTO_CONNECTION_PERIOD_MS
+ int "Auto connect period(ms)"
+ default 2000
+ endif
endif
config RT_WLAN_CFG_ENABLE
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index 04034e8c44..e1d606557b 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -428,12 +428,10 @@ static void rt_dma_recv_update_put_index(struct rt_serial_device *serial, rt_siz
}
}
- if(rx_fifo->is_full == RT_TRUE)
+ if(rx_fifo->is_full == RT_TRUE)
{
- rx_fifo->get_index = rx_fifo->put_index;
- }
-
- if (rx_fifo->get_index >= serial->config.bufsz) rx_fifo->get_index = 0;
+ rx_fifo->get_index = rx_fifo->put_index;
+ }
}
/*
diff --git a/components/drivers/wlan/wlan_cmd.c b/components/drivers/wlan/wlan_cmd.c
index 7a24d5a7e7..fead6a8bf2 100644
--- a/components/drivers/wlan/wlan_cmd.c
+++ b/components/drivers/wlan/wlan_cmd.c
@@ -468,6 +468,10 @@ static int wifi_debug_set_mode(int argc, char *argv[])
{
mode = RT_WLAN_AP;
}
+ else if (rt_strcmp("none", argv[1]) == 0)
+ {
+ mode = RT_WLAN_NONE;
+ }
else
return -1;
diff --git a/components/drivers/wlan/wlan_dev.c b/components/drivers/wlan/wlan_dev.c
index e0f9eff279..2490c2c456 100644
--- a/components/drivers/wlan/wlan_dev.c
+++ b/components/drivers/wlan/wlan_dev.c
@@ -535,8 +535,16 @@ rt_err_t rt_wlan_dev_scan(struct rt_wlan_device *device, struct rt_wlan_info *in
}
rt_memcpy(&scan_info.ssid, &info->ssid, sizeof(rt_wlan_ssid_t));
rt_memcpy(scan_info.bssid, info->bssid, RT_WLAN_BSSID_MAX_LENGTH);
- scan_info.channel_min = -1;
- scan_info.channel_max = -1;
+ if (info->channel > 0)
+ {
+ scan_info.channel_min = info->channel;
+ scan_info.channel_max = info->channel;
+ }
+ else
+ {
+ scan_info.channel_min = -1;
+ scan_info.channel_max = -1;
+ }
p_scan_info = &scan_info;
}
result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_SCAN, p_scan_info);
diff --git a/components/drivers/wlan/wlan_lwip.c b/components/drivers/wlan/wlan_lwip.c
index ce8dff2953..797dd823fb 100644
--- a/components/drivers/wlan/wlan_lwip.c
+++ b/components/drivers/wlan/wlan_lwip.c
@@ -56,12 +56,16 @@ static void netif_is_ready(struct rt_work *work, void *parameter)
ip_addr_t ip_addr_zero = { 0 };
struct rt_wlan_device *wlan = parameter;
struct lwip_prot_des *lwip_prot = (struct lwip_prot_des *)wlan->prot;
- struct eth_device *eth_dev = &lwip_prot->eth;
+ struct eth_device *eth_dev;
rt_base_t level;
struct rt_wlan_buff buff;
rt_uint32_t ip_addr[4];
char str[IPADDR_STRLEN_MAX];
+ if (lwip_prot == RT_NULL)
+ return;
+
+ eth_dev = &lwip_prot->eth;
rt_timer_stop(&lwip_prot->timer);
if (ip_addr_cmp(&(eth_dev->netif->ip_addr), &ip_addr_zero) != 0)
{
@@ -122,9 +126,13 @@ static void timer_callback(void *parameter)
struct rt_workqueue *workqueue;
struct rt_wlan_device *wlan = parameter;
struct lwip_prot_des *lwip_prot = (struct lwip_prot_des *)wlan->prot;
- struct rt_work *work = &lwip_prot->work;
+ struct rt_work *work;
rt_base_t level;
+ if (lwip_prot == RT_NULL)
+ return;
+
+ work = &lwip_prot->work;
workqueue = rt_wlan_get_workqueue();
if (workqueue != RT_NULL)
{
@@ -148,7 +156,12 @@ static void netif_set_connected(void *parameter)
{
struct rt_wlan_device *wlan = parameter;
struct lwip_prot_des *lwip_prot = wlan->prot;
- struct eth_device *eth_dev = &lwip_prot->eth;
+ struct eth_device *eth_dev;
+
+ if (lwip_prot == RT_NULL)
+ return;
+
+ eth_dev = &lwip_prot->eth;
if (lwip_prot->connected_flag)
{
@@ -209,6 +222,9 @@ static void rt_wlan_lwip_event_handle(struct rt_wlan_prot *port, struct rt_wlan_
struct lwip_prot_des *lwip_prot = (struct lwip_prot_des *)wlan->prot;
rt_bool_t flag_old;
+ if (lwip_prot == RT_NULL)
+ return;
+
flag_old = lwip_prot->connected_flag;
switch (event)
@@ -472,12 +488,9 @@ static struct rt_wlan_prot *rt_wlan_lwip_protocol_register(struct rt_wlan_prot *
return RT_NULL;
}
rt_memcpy(&lwip_prot->prot, prot, sizeof(struct rt_wlan_prot));
- if (wlan->mode == RT_WLAN_STATION)
- {
- rt_sprintf(timer_name, "timer_%s", eth_name);
- rt_timer_init(&lwip_prot->timer, timer_name, timer_callback, wlan, rt_tick_from_millisecond(1000),
- RT_TIMER_FLAG_SOFT_TIMER | RT_TIMER_FLAG_ONE_SHOT);
- }
+ rt_sprintf(timer_name, "timer_%s", eth_name);
+ rt_timer_init(&lwip_prot->timer, timer_name, timer_callback, wlan, rt_tick_from_millisecond(1000),
+ RT_TIMER_FLAG_SOFT_TIMER | RT_TIMER_FLAG_ONE_SHOT);
netif_set_up(eth->netif);
LOG_I("eth device init ok name:%s", eth_name);
#ifdef RT_USING_NETDEV
diff --git a/components/drivers/wlan/wlan_mgnt.c b/components/drivers/wlan/wlan_mgnt.c
index 5dc0119abd..e0ee67e06c 100644
--- a/components/drivers/wlan/wlan_mgnt.c
+++ b/components/drivers/wlan/wlan_mgnt.c
@@ -58,10 +58,6 @@
#define TIME_START()
#endif
-#ifndef DISCONNECT_RESPONSE_MS
-#define DISCONNECT_RESPONSE_MS (2000)
-#endif
-
#if RT_WLAN_EBOX_NUM < 1
#error "event box num Too few"
#endif
@@ -532,7 +528,7 @@ static void rt_wlan_auto_connect_run(struct rt_work *work, void *parameter)
if (id >= rt_wlan_cfg_get_num()) id = 0;
- if ((cfg_info.key.len > 0) && (cfg_info.key.len < RT_WLAN_PASSWORD_MAX_LENGTH))
+ if ((cfg_info.key.len > 0) && (cfg_info.key.len <= RT_WLAN_PASSWORD_MAX_LENGTH))
{
cfg_info.key.val[cfg_info.key.len] = '\0';
password = (char *)(&cfg_info.key.val[0]);
@@ -2020,7 +2016,7 @@ int rt_wlan_init(void)
rt_mutex_init(&complete_mutex, "complete", RT_IPC_FLAG_FIFO);
#ifdef RT_WLAN_AUTO_CONNECT_ENABLE
rt_timer_init(&reconnect_time, "wifi_tim", rt_wlan_cyclic_check, RT_NULL,
- rt_tick_from_millisecond(DISCONNECT_RESPONSE_MS),
+ rt_tick_from_millisecond(AUTO_CONNECTION_PERIOD_MS),
RT_TIMER_FLAG_PERIODIC | RT_TIMER_FLAG_SOFT_TIMER);
#endif
_init_flag = 1;
diff --git a/components/drivers/wlan/wlan_mgnt.h b/components/drivers/wlan/wlan_mgnt.h
index 57d8dd9d78..df0827bb7b 100644
--- a/components/drivers/wlan/wlan_mgnt.h
+++ b/components/drivers/wlan/wlan_mgnt.h
@@ -41,6 +41,10 @@ extern "C" {
#define RT_WLAN_SCAN_RETRY_CNT (3)
#endif
+#ifndef AUTO_CONNECTION_PERIOD_MS
+#define AUTO_CONNECTION_PERIOD_MS (2000)
+#endif
+
/*state fot station*/
#define RT_WLAN_STATE_CONNECT (1UL << 0)
#define RT_WLAN_STATE_CONNECTING (1UL << 1)
diff --git a/components/libc/compilers/dlib/sys/errno.h b/components/libc/compilers/dlib/sys/errno.h
new file mode 100644
index 0000000000..1ad4c8acc0
--- /dev/null
+++ b/components/libc/compilers/dlib/sys/errno.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2019-07-08 Bernard The first version
+ */
+
+#ifndef SYS_ERRNO_H__
+#define SYS_ERRNO_H__
+
+#include <errno.h>
+
+#endif
diff --git a/components/libc/compilers/dlib/sys/signal.h b/components/libc/compilers/dlib/sys/signal.h
new file mode 100644
index 0000000000..22adb1228b
--- /dev/null
+++ b/components/libc/compilers/dlib/sys/signal.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2019-07-08 Bernard The first version
+ */
+
+#ifndef SYS_SIGNAL_H__
+#define SYS_SIGNAL_H__
+
+#include <libc/libc_signal.h>
+
+#endif
diff --git a/components/libc/compilers/dlib/sys/unistd.h b/components/libc/compilers/dlib/sys/unistd.h
index 5985a42996..29f68f24f8 100644
--- a/components/libc/compilers/dlib/sys/unistd.h
+++ b/components/libc/compilers/dlib/sys/unistd.h
@@ -34,14 +34,6 @@
#define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */
#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
-#define O_RDONLY 0 /* +1 == FREAD */
-#define O_WRONLY 1 /* +1 == FWRITE */
-#define O_RDWR 2 /* +1 == FREAD|FWRITE */
-#define O_APPEND _FAPPEND
-#define O_CREAT _FCREAT
-#define O_TRUNC _FTRUNC
-#define O_EXCL _FEXCL
-#define O_SYNC _FSYNC
#endif
#endif /* _SYS_UNISTD_H */
diff --git a/components/net/sal_socket/impl/af_inet_lwip.c b/components/net/sal_socket/impl/af_inet_lwip.c
index e53aa845cc..56df735ab9 100644
--- a/components/net/sal_socket/impl/af_inet_lwip.c
+++ b/components/net/sal_socket/impl/af_inet_lwip.c
@@ -273,6 +273,8 @@ static int inet_poll(struct dfs_fd *file, struct rt_pollreq *req)
if (sock->errevent)
{
mask |= POLLERR;
+ /* clean error event */
+ sock->errevent = 0;
}
rt_hw_interrupt_enable(level);
}