diff options
| author | JasonJiaJie <[email protected]> | 2017-11-09 13:57:01 +0800 |
|---|---|---|
| committer | JasonJiaJie <[email protected]> | 2017-11-09 13:57:01 +0800 |
| commit | 4eb8121bae6b25f7d9cd1cf83f2a609f5ec96a94 (patch) | |
| tree | aeac288bdff66cf62fa10d281e185eabc63b1e9a /components | |
| parent | 20dbd2dd0aefa5b69c848c78de87e7fa6470b242 (diff) | |
| parent | 024e3ea8f692fd7ecd9c36dad544fd69ea70c4bd (diff) | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'components')
| -rw-r--r-- | components/drivers/include/drivers/pin.h | 2 | ||||
| -rw-r--r-- | components/drivers/misc/pin.c | 2 | ||||
| -rw-r--r-- | components/drivers/wlan/wlan_cmd.c | 69 | ||||
| -rw-r--r-- | components/libc/compilers/armlibc/dirent.h | 54 |
4 files changed, 89 insertions, 38 deletions
diff --git a/components/drivers/include/drivers/pin.h b/components/drivers/include/drivers/pin.h index 9745aafdf7..a4ac39c75b 100644 --- a/components/drivers/include/drivers/pin.h +++ b/components/drivers/include/drivers/pin.h @@ -96,7 +96,7 @@ int rt_pin_read(rt_base_t pin); rt_err_t rt_pin_attach_irq(rt_int32_t pin, rt_uint32_t mode, void (*hdr)(void *args), void *args); rt_err_t rt_pin_dettach_irq(rt_int32_t pin); -rt_err_t pin_irq_enable(rt_base_t pin, rt_uint32_t enabled); +rt_err_t rt_pin_irq_enable(rt_base_t pin, rt_uint32_t enabled); int rt_device_pin_irq_register(const char *name, const struct rt_pin_ops *ops, void *user_data); diff --git a/components/drivers/misc/pin.c b/components/drivers/misc/pin.c index 9cbe47089e..9ed827f0b5 100644 --- a/components/drivers/misc/pin.c +++ b/components/drivers/misc/pin.c @@ -117,7 +117,7 @@ rt_err_t rt_pin_dettach_irq(rt_int32_t pin) } return RT_ENOSYS; } -rt_err_t pin_irq_enable(rt_base_t pin, rt_uint32_t enabled) +rt_err_t rt_pin_irq_enable(rt_base_t pin, rt_uint32_t enabled) { RT_ASSERT(_hw_pin.ops != RT_NULL); if(_hw_pin.ops->pin_irq_enable) diff --git a/components/drivers/wlan/wlan_cmd.c b/components/drivers/wlan/wlan_cmd.c index 2ff0db903d..273061fada 100644 --- a/components/drivers/wlan/wlan_cmd.c +++ b/components/drivers/wlan/wlan_cmd.c @@ -41,8 +41,11 @@ struct rt_wlan_info info; #define WIFI_SETTING_FN "/appfs/setting.json" #endif -#ifndef WIFI_DEVICE_NAME -#define WIFI_DEVICE_NAME "w0" +#ifndef WIFI_DEVICE_STA_NAME +#define WIFI_DEVICE_STA_NAME "w0" +#endif +#ifndef WIFI_DEVICE_AP_NAME +#define WIFI_DEVICE_AP_NAME "ap" #endif #ifdef RT_USING_DFS @@ -304,53 +307,43 @@ int wifi_default(void) /* read default setting for wifi */ wifi_read_cfg(WIFI_SETTING_FN); - /* get wlan device */ - wlan = (struct rt_wlan_device*)rt_device_find(WIFI_DEVICE_NAME); - if (!wlan) - { - rt_kprintf("no wlan:%s device\n", WIFI_DEVICE_NAME); - return -1; - } - if (network_mode == WIFI_STATION) { - struct rt_wlan_info *info; - - info = (struct rt_wlan_info *)rt_malloc (sizeof(struct rt_wlan_info)); - if (!info) + /* get wlan device */ + wlan = (struct rt_wlan_device*)rt_device_find(WIFI_DEVICE_STA_NAME); + if (!wlan) { - rt_kprintf("wifi: out of memory\n"); + rt_kprintf("no wlan:%s device\n", WIFI_DEVICE_STA_NAME); return -1; } /* wifi station */ - rt_wlan_info_init(info, WIFI_STATION, SECURITY_WPA2_MIXED_PSK, wifi_ssid); + rt_wlan_info_init(&info, WIFI_STATION, SECURITY_WPA2_MIXED_PSK, wifi_ssid); result =rt_wlan_init(wlan, WIFI_STATION); if (result == RT_EOK) { - result = rt_wlan_connect(wlan, info, wifi_key); + result = rt_wlan_connect(wlan, &info, wifi_key); } } else { /* wifi AP */ - struct rt_wlan_info *info; - - info = (struct rt_wlan_info *)rt_malloc (sizeof(struct rt_wlan_info)); - if (!info) + /* get wlan device */ + wlan = (struct rt_wlan_device*)rt_device_find(WIFI_DEVICE_AP_NAME); + if (!wlan) { - rt_kprintf("wifi: out of memory\n"); + rt_kprintf("no wlan:%s device\n", WIFI_DEVICE_AP_NAME); return -1; } - rt_wlan_info_init(info, WIFI_AP, SECURITY_WPA2_AES_PSK, wifi_ssid); - info->channel = 11; + rt_wlan_info_init(&info, WIFI_AP, SECURITY_WPA2_AES_PSK, wifi_ssid); + info.channel = 11; /* wifi soft-AP */ result =rt_wlan_init(wlan, WIFI_AP); if (result == RT_EOK) { - result = rt_wlan_softap(wlan, info, wifi_key); + result = rt_wlan_softap(wlan, &info, wifi_key); } } @@ -417,6 +410,7 @@ int wifi(int argc, char** argv) if (strcmp(argv[2], "join") == 0) { rt_wlan_init(wlan, WIFI_STATION); + network_mode = WIFI_STATION; /* TODO: use easy-join to replace */ rt_wlan_info_init(&info, WIFI_STATION, SECURITY_WPA2_MIXED_PSK, argv[3]); @@ -471,34 +465,37 @@ int wifi(int argc, char** argv) else if (strcmp(argv[2], "ap") == 0) { rt_err_t result = RT_EOK; - struct rt_wlan_info *info; - info = (struct rt_wlan_info*)rt_malloc(sizeof(struct rt_wlan_info)); if (argc == 4) { // open soft-AP - rt_wlan_info_init(info, WIFI_AP, SECURITY_OPEN, argv[3]); - info->channel = 11; + rt_wlan_info_init(&info, WIFI_AP, SECURITY_OPEN, argv[3]); + info.channel = 11; result =rt_wlan_init(wlan, WIFI_AP); /* start soft ap */ - result = rt_wlan_softap(wlan, info, NULL); + result = rt_wlan_softap(wlan, &info, NULL); + if (result == RT_EOK) + { + network_mode = WIFI_AP; + } } else if (argc == 5) { // WPA2 with password - rt_wlan_info_init(info, WIFI_AP, SECURITY_WPA2_AES_PSK, argv[3]); - info->channel = 11; + rt_wlan_info_init(&info, WIFI_AP, SECURITY_WPA2_AES_PSK, argv[3]); + info.channel = 11; result =rt_wlan_init(wlan, WIFI_AP); /* start soft ap */ - result = rt_wlan_softap(wlan, info, argv[4]); + result = rt_wlan_softap(wlan, &info, argv[4]); + if (result == RT_EOK) + { + network_mode = WIFI_AP; + } } else { - /* release information */ - rt_free(info); - wifi_usage(); } diff --git a/components/libc/compilers/armlibc/dirent.h b/components/libc/compilers/armlibc/dirent.h new file mode 100644 index 0000000000..1adf952031 --- /dev/null +++ b/components/libc/compilers/armlibc/dirent.h @@ -0,0 +1,54 @@ +#ifndef __RTT_DIRENT_H__ +#define __RTT_DIRENT_H__ + +#include <rtthread.h> +#include <rtlibc.h> + +/* +* dirent.h - format of directory entries + * Ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html + */ + +/* File types */ +#define FT_REGULAR 0 /* regular file */ +#define FT_SOCKET 1 /* socket file */ +#define FT_DIRECTORY 2 /* directory */ +#define FT_USER 3 /* user defined */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef HAVE_DIR_STRUCTURE +typedef struct +{ + int fd; /* directory file */ + char buf[512]; + int num; + int cur; +} DIR; +#endif + +#ifndef HAVE_DIRENT_STRUCTURE +struct dirent +{ + rt_uint8_t d_type; /* The type of the file */ + rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */ + rt_uint16_t d_reclen; /* length of this record */ + char d_name[256]; /* The null-terminated file name */ +}; +#endif + +int closedir(DIR *); +DIR *opendir(const char *); +struct dirent *readdir(DIR *); +int readdir_r(DIR *, struct dirent *, struct dirent **); +void rewinddir(DIR *); +void seekdir(DIR *, long int); +long telldir(DIR *); + +#ifdef __cplusplus +} +#endif + +#endif |
