mirror of
https://github.com/pvvx/RTL00MP3.git
synced 2025-07-31 12:41:06 +00:00
update
This commit is contained in:
parent
cf7a2d9683
commit
f7b901aa27
76 changed files with 3753 additions and 3990 deletions
|
@ -948,13 +948,16 @@ void fATWC(void *arg){
|
|||
|
||||
if(assoc_by_bssid){
|
||||
printf("Joining BSS by BSSID "MAC_FMT" ...\n", MAC_ARG(wifi.bssid.octet));
|
||||
ret = wifi_connect_bssid(wifi.bssid.octet, (char*)wifi.ssid.val, wifi.security_type, (char*)wifi.password,
|
||||
ETH_ALEN, wifi.ssid.len, wifi.password_len, wifi.key_id, NULL);
|
||||
} else {
|
||||
printf("Joining BSS by SSID %s...\n", (char*)wifi.ssid.val);
|
||||
ret = wifi_connect((char*)wifi.ssid.val, wifi.security_type, (char*)wifi.password, wifi.ssid.len,
|
||||
wifi.password_len, wifi.key_id, NULL);
|
||||
}
|
||||
ret = wifi_connect(wifi.bssid.octet,
|
||||
assoc_by_bssid,
|
||||
(char*)wifi.ssid.val,
|
||||
wifi.security_type,
|
||||
(char*)wifi.password,
|
||||
wifi.key_id,
|
||||
NULL);
|
||||
|
||||
if(ret!= RTW_SUCCESS){
|
||||
printf("ERROR: Can't connect to AP\n");
|
||||
|
@ -1652,19 +1655,10 @@ void fATPA(void *arg)
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if(hidden_ssid){
|
||||
if(wifi_start_ap_with_hidden_ssid((char*)ap.ssid.val, ap.security_type, (char*)ap.password, ap.ssid.len, ap.password_len, ap.channel) < 0) {
|
||||
if(wifi_start_ap((char*)ap.ssid.val, ap.security_type, (char*)ap.password, ap.channel, hidden_ssid) < 0) {
|
||||
//at_printf("\r\n[ATPA] ERROR : Start AP failed");
|
||||
error_no = 4;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(wifi_start_ap((char*)ap.ssid.val, ap.security_type, (char*)ap.password, ap.ssid.len, ap.password_len, ap.channel) < 0) {
|
||||
//at_printf("\r\n[ATPA] ERROR : Start AP failed");
|
||||
error_no = 4;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
while(1) {
|
||||
|
@ -1906,13 +1900,14 @@ void fATPN(void *arg)
|
|||
wifi_set_pscan_chan(&connect_channel, &pscan_config, 1);
|
||||
#endif
|
||||
|
||||
if(assoc_by_bssid){
|
||||
ret = wifi_connect_bssid(wifi.bssid.octet, (char*)wifi.ssid.val, wifi.security_type, (char*)wifi.password,
|
||||
ETH_ALEN, wifi.ssid.len, wifi.password_len, wifi.key_id, NULL);
|
||||
} else {
|
||||
ret = wifi_connect((char*)wifi.ssid.val, wifi.security_type, (char*)wifi.password, wifi.ssid.len,
|
||||
wifi.password_len, wifi.key_id, NULL);
|
||||
}
|
||||
ret = wifi_connect(
|
||||
wifi.bssid.octet,
|
||||
assoc_by_bssid,
|
||||
(char*)wifi.ssid.val,
|
||||
wifi.security_type,
|
||||
(char*)wifi.password,
|
||||
wifi.key_id,
|
||||
NULL);
|
||||
|
||||
if(ret!= RTW_SUCCESS){
|
||||
//at_printf("\r\n[ATPN] ERROR: Can't connect to AP");
|
||||
|
@ -2345,8 +2340,14 @@ int atcmd_wifi_restore_from_flash(void)
|
|||
break;
|
||||
}
|
||||
|
||||
ret = wifi_connect((char*)wifi.ssid.val, wifi.security_type, (char*)wifi.password, wifi.ssid.len,
|
||||
wifi.password_len, wifi.key_id, NULL);
|
||||
ret = wifi_connect(
|
||||
NULL,
|
||||
0,
|
||||
(char*)wifi.ssid.val,
|
||||
wifi.security_type,
|
||||
(char*)wifi.password,
|
||||
wifi.key_id,
|
||||
NULL);
|
||||
if(ret == RTW_SUCCESS){
|
||||
LwIP_DHCP(0, DHCP_START);
|
||||
ret = 0;
|
||||
|
|
|
@ -7,17 +7,18 @@
|
|||
#define ICACHE_FLASH_ATTR
|
||||
#define ICACHE_RODATA_ATTR
|
||||
#define DATA_IRAM_ATTR
|
||||
#define ICACHE_RAM_ATTR
|
||||
|
||||
#define os_printf(...) rtl_printf(__VA_ARGS__)
|
||||
#define os_printf_plus(...) rtl_printf(__VA_ARGS__)
|
||||
#define os_sprintf_fd(...) rtl_sprintf(__VA_ARGS__)
|
||||
#define ets_sprintf(...) rtl_sprintf(__VA_ARGS__)
|
||||
/*
|
||||
#ifndef os_malloc
|
||||
#define os_malloc pvPortMalloc
|
||||
#define os_zalloc pvPortZalloc
|
||||
#define os_calloc pvPortCalloc
|
||||
#define os_realloc pvPortRealloc
|
||||
*/
|
||||
#endif
|
||||
#undef os_free
|
||||
#define os_free vPortFree
|
||||
#define system_get_free_heap_size xPortGetFreeHeapSize
|
||||
|
@ -51,6 +52,7 @@
|
|||
#define os_strncpy rtl_strncpy
|
||||
#define os_strstr rtl_strstr
|
||||
#define os_random Rand
|
||||
|
||||
//extern uint32 phy_get_rand(void);
|
||||
#define system_get_os_print() 1
|
||||
|
||||
|
@ -102,7 +104,6 @@ extern SpiFlashChip * flashchip; // in RAM-BIOS: 0x3fffc714
|
|||
#define spi_flash_read(faddr, pbuf, size) flash_stream_read(&flashobj, faddr, size, (uint8_t *)pbuf)
|
||||
#define spi_flash_erase_block(blk) flash_erase_block(&flashobj, (blk)<<16);
|
||||
|
||||
|
||||
#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0])
|
||||
#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1])
|
||||
#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2])
|
||||
|
@ -121,6 +122,13 @@ extern SpiFlashChip * flashchip; // in RAM-BIOS: 0x3fffc714
|
|||
|
||||
#define IPSTR "%d.%d.%d.%d"
|
||||
|
||||
#ifndef MAC2STR
|
||||
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
|
||||
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef DEBUGSOO
|
||||
/* CONFIG_DEBUG_LOG:
|
||||
=0 Off all diag/debug msg,
|
||||
=1 Only errors,
|
||||
|
@ -135,5 +143,12 @@ extern SpiFlashChip * flashchip; // in RAM-BIOS: 0x3fffc714
|
|||
#else
|
||||
#define DEBUGSOO CONFIG_DEBUG_LOG
|
||||
#endif
|
||||
#endif //#ifndef DEBUGSOO
|
||||
|
||||
//#define system_get_sdk_version() "3.5.3"
|
||||
|
||||
//#define system_get_time xTaskGetTickCount
|
||||
//#define ets_get_cpu_frequency HalGetCpuClk
|
||||
|
||||
|
||||
#endif // _INCLUDE_ESP_COMP_H_
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <PinNames.h>
|
||||
#include <pinmap.h>
|
||||
#include <gpio_api.h>
|
||||
#include <rtw_wowlan/wifi_wowlan.h>
|
||||
#include <wifi_wowlan.h>
|
||||
#include <freertos_pmu.h>
|
||||
#include <wifi_conf.h>
|
||||
|
||||
|
|
|
@ -212,16 +212,16 @@ struct rtw_wowlan_rx_filter {
|
|||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack(1)
|
||||
#else
|
||||
//#error "this structure needs to be packed!"
|
||||
#error "this structure needs to be packed!"
|
||||
#endif
|
||||
struct rtw_wowlan {
|
||||
struct rtw_wowlan_status {
|
||||
u32 wakeup_reasons; //record wake up reason
|
||||
u32 filter_id; //record which pattern is matched
|
||||
} _status __attribute__ ((__packed__));
|
||||
};
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack()
|
||||
#else
|
||||
//#error "this structure needs to be packed!"
|
||||
#error "this structure needs to be packed!"
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
#include <lwip/netif.h>
|
||||
#include "wifi/wifi_conf.h"
|
||||
#include <platform/platform_stdlib.h>
|
||||
#ifdef CONFIG_ENABLE_EAP
|
||||
#include <polarssl/ssl.h>
|
||||
#include <polarssl/memory.h>
|
||||
#endif
|
||||
|
||||
#define WLAN0_NAME "wlan0"
|
||||
#ifndef ENABLE
|
||||
|
@ -21,6 +23,21 @@
|
|||
#define DISABLE (0)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ENABLE_EAP
|
||||
int get_eap_phase(void){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_eap_method(void){
|
||||
return 0;
|
||||
}
|
||||
|
||||
void eap_autoreconnect_hdl(u8 method_id)
|
||||
{
|
||||
(void) method_id;
|
||||
}
|
||||
#else
|
||||
|
||||
u8 eap_phase = 0;
|
||||
u8 eap_method = 0;
|
||||
|
||||
|
@ -42,9 +59,6 @@ void eap_eapol_recvd_hdl(char *buf, int buf_len, int flags, void* handler_user_d
|
|||
void eap_eapol_start_hdl(char *buf, int buf_len, int flags, void* handler_user_data);
|
||||
#endif
|
||||
|
||||
void set_eap_phase(unsigned char is_trigger_eap){
|
||||
eap_phase = is_trigger_eap;
|
||||
}
|
||||
|
||||
int get_eap_phase(void){
|
||||
return eap_phase;
|
||||
|
@ -54,6 +68,10 @@ int get_eap_method(void){
|
|||
return eap_method;
|
||||
}
|
||||
|
||||
void set_eap_phase(unsigned char is_trigger_eap){
|
||||
eap_phase = is_trigger_eap;
|
||||
}
|
||||
|
||||
void reset_config(void){
|
||||
eap_target_ssid = NULL;
|
||||
eap_identity = NULL;
|
||||
|
@ -64,6 +82,8 @@ void reset_config(void){
|
|||
eap_client_key_pwd = NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ENABLE_EAP
|
||||
|
||||
void judge_station_disconnect(void)
|
||||
{
|
||||
int mode = 0;
|
||||
|
@ -82,7 +102,7 @@ void judge_station_disconnect(void)
|
|||
wifi_disconnect();
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_ENABLE_EAP
|
||||
|
||||
void eap_disconnected_hdl(char *buf, int buf_len, int flags, void* handler_user_data){
|
||||
// printf("disconnected\n");
|
||||
wifi_unreg_event_handler(WIFI_EVENT_EAPOL_RECVD, eap_eapol_recvd_hdl);
|
||||
|
@ -258,11 +278,12 @@ static int connect_by_open_system(char *target_ssid)
|
|||
if (target_ssid != NULL) {
|
||||
while (1) {
|
||||
rtw_msleep_os(500); //wait scan complete.
|
||||
ret = wifi_connect(target_ssid,
|
||||
ret = wifi_connect(
|
||||
NULL,
|
||||
0,
|
||||
target_ssid,
|
||||
RTW_SECURITY_OPEN,
|
||||
NULL,
|
||||
strlen(target_ssid),
|
||||
0,
|
||||
0,
|
||||
NULL);
|
||||
if (ret == RTW_SUCCESS) {
|
||||
|
@ -451,3 +472,5 @@ int eap_cert_setup(ssl_context *ssl)
|
|||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif //#ifdef CONFIG_ENABLE_EAP
|
||||
|
|
|
@ -303,11 +303,12 @@ static int wps_connect_to_AP_by_certificate(rtw_network_info_t *wifi)
|
|||
printf("ssid_len = %d\n", wifi->ssid.len);
|
||||
printf("password_len = %d\n", wifi->password_len);
|
||||
while (1) {
|
||||
ret = wifi_connect((char*)wifi->ssid.val,
|
||||
ret = wifi_connect(
|
||||
NULL,
|
||||
0,
|
||||
(char*)wifi->ssid.val,
|
||||
wifi->security_type,
|
||||
(char*)wifi->password,
|
||||
wifi->ssid.len,
|
||||
wifi->password_len,
|
||||
wifi->key_id,
|
||||
NULL);
|
||||
if (ret == RTW_SUCCESS) {
|
||||
|
@ -336,11 +337,11 @@ static int wps_connect_to_AP_by_open_system(char *target_ssid)
|
|||
if (target_ssid != NULL) {
|
||||
rtw_msleep_os(500); //wait scan complete.
|
||||
while (1) {
|
||||
ret = wifi_connect(target_ssid,
|
||||
RTW_SECURITY_OPEN,
|
||||
ret = wifi_connect(
|
||||
NULL,
|
||||
strlen(target_ssid),
|
||||
0,
|
||||
target_ssid,
|
||||
RTW_SECURITY_OPEN,
|
||||
0,
|
||||
NULL);
|
||||
if (ret == RTW_SUCCESS) {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <wifi/wifi_conf.h>
|
||||
#include <wifi/wifi_util.h>
|
||||
#include <wifi/wifi_ind.h>
|
||||
#include <wifi_api.h>
|
||||
#include "tcpip.h"
|
||||
#include <osdep_service.h>
|
||||
|
||||
|
@ -22,8 +23,6 @@
|
|||
extern int inic_start(void);
|
||||
extern int inic_stop(void);
|
||||
#endif
|
||||
#include "wifi_api.h"
|
||||
|
||||
#include "wlan_lib.h"
|
||||
|
||||
#if CONFIG_DEBUG_LOG > 0
|
||||
|
@ -429,8 +428,18 @@ void restore_wifi_info_to_flash() {
|
|||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
int wifi_connect(char *ssid, rtw_security_t security_type, char *password,
|
||||
int ssid_len, int password_len, int key_id, void *semaphore) {
|
||||
int wifi_connect(
|
||||
unsigned char bssid[ETH_ALEN],
|
||||
char use_bssid, // flag
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
char *password,
|
||||
int key_id,
|
||||
void *semaphore) {
|
||||
|
||||
int ssid_len = 0;
|
||||
int password_len = 0;
|
||||
int bssid_len = 6;
|
||||
xSemaphoreHandle join_semaphore;
|
||||
rtw_result_t result = RTW_SUCCESS;
|
||||
u8 wep_hex = 0;
|
||||
|
@ -441,7 +450,34 @@ int wifi_connect(char *ssid, rtw_security_t security_type, char *password,
|
|||
return RTW_ERROR;
|
||||
}
|
||||
|
||||
if(ssid) {
|
||||
ssid_len = rtl_strlen(ssid);
|
||||
if(ssid_len > NDIS_802_11_LENGTH_SSID)
|
||||
ssid_len = NDIS_802_11_LENGTH_SSID;
|
||||
}
|
||||
if(password) {
|
||||
password_len = rtl_strlen(password);
|
||||
if(password_len > IW_PASSPHRASE_MAX_SIZE)
|
||||
password_len = IW_PASSPHRASE_MAX_SIZE;
|
||||
}
|
||||
|
||||
rtw_join_status = 0; //clear for last connect status
|
||||
error_flag = RTW_UNKNOWN; //clear for last connect status
|
||||
internal_join_result_t *join_result =
|
||||
(internal_join_result_t *) rtw_zmalloc(
|
||||
sizeof(internal_join_result_t));
|
||||
if (!join_result) {
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
error_printf("%s: Can't malloc memory!\n", __func__);
|
||||
#endif
|
||||
return RTW_NOMEM;
|
||||
}
|
||||
if (ssid_len && ssid) {
|
||||
join_result->network_info.ssid.len = ssid_len > 32 ? 32 : ssid_len;
|
||||
rtw_memcpy(join_result->network_info.ssid.val, ssid, ssid_len);
|
||||
}
|
||||
if(bssid) rtw_memcpy(join_result->network_info.bssid.octet, bssid, ETH_ALEN);
|
||||
|
||||
error_flag = RTW_UNKNOWN; //clear for last connect status
|
||||
if ((((password_len > RTW_MAX_PSK_LEN) || (password_len < RTW_MIN_PSK_LEN))
|
||||
&& ((security_type == RTW_SECURITY_WPA_TKIP_PSK)
|
||||
|
@ -463,24 +499,24 @@ int wifi_connect(char *ssid, rtw_security_t security_type, char *password,
|
|||
|
||||
if (password_len == 10) {
|
||||
|
||||
u32 p[5] = { 0 };
|
||||
u32 g[5] = { 0 };
|
||||
u8 i = 0;
|
||||
sscanf((const char*) password, "%02x%02x%02x%02x%02x", &p[0],
|
||||
&p[1], &p[2], &p[3], &p[4]);
|
||||
sscanf((const char*) password, "%02x%02x%02x%02x%02x", &g[0],
|
||||
&g[1], &g[2], &g[3], &g[4]);
|
||||
for (i = 0; i < 5; i++)
|
||||
wep_pwd[i] = (u8) p[i];
|
||||
wep_pwd[i] = (u8) g[i];
|
||||
wep_pwd[5] = '\0';
|
||||
password_len = 5;
|
||||
wep_hex = 1;
|
||||
} else if (password_len == 26) {
|
||||
u32 p[13] = { 0 };
|
||||
u32 g[13] = { 0 };
|
||||
u8 i = 0;
|
||||
sscanf((const char*) password, "%02x%02x%02x%02x%02x%02x%02x"
|
||||
"%02x%02x%02x%02x%02x%02x", &p[0], &p[1], &p[2], &p[3],
|
||||
&p[4], &p[5], &p[6], &p[7], &p[8], &p[9], &p[10],
|
||||
&p[11], &p[12]);
|
||||
"%02x%02x%02x%02x%02x%02x", &g[0], &g[1], &g[2], &g[3],
|
||||
&g[4], &g[5], &g[6], &g[7], &g[8], &g[9], &g[10],
|
||||
&g[11], &g[12]);
|
||||
for (i = 0; i < 13; i++)
|
||||
wep_pwd[i] = (u8) p[i];
|
||||
wep_pwd[i] = (u8) g[i];
|
||||
wep_pwd[13] = '\0';
|
||||
password_len = 13;
|
||||
wep_hex = 1;
|
||||
|
@ -488,20 +524,8 @@ int wifi_connect(char *ssid, rtw_security_t security_type, char *password,
|
|||
}
|
||||
}
|
||||
|
||||
internal_join_result_t *join_result =
|
||||
(internal_join_result_t *) rtw_zmalloc(
|
||||
sizeof(internal_join_result_t));
|
||||
if (!join_result) {
|
||||
#if CONFIG_DEBUG_LOG > 3
|
||||
error_printf("%s: Can't malloc memory!\n", __func__);
|
||||
#endif
|
||||
return RTW_NOMEM;
|
||||
}
|
||||
|
||||
join_result->network_info.ssid.len = ssid_len > 32 ? 32 : ssid_len;
|
||||
rtw_memcpy(join_result->network_info.ssid.val, ssid, ssid_len);
|
||||
|
||||
join_result->network_info.password_len = password_len;
|
||||
|
||||
if (password_len) {
|
||||
/* add \0 to the end */
|
||||
join_result->network_info.password = rtw_zmalloc(password_len + 1);
|
||||
|
@ -542,9 +566,33 @@ int wifi_connect(char *ssid, rtw_security_t security_type, char *password,
|
|||
#if DD_WIFI_CONN // дублирование с wifi_connect_bssid_local()
|
||||
wifi_connect_local(&join_result->network_info);
|
||||
#else
|
||||
if (wifi_connect_local(&join_result->network_info) == 0)
|
||||
wext_set_ssid(WLAN0_NAME, join_result->network_info.ssid.val,
|
||||
join_result->network_info.ssid.len);
|
||||
rtw_network_info_t *pWifi = &join_result->network_info;
|
||||
|
||||
if (wifi_connect_local(pWifi) == 0) {
|
||||
uint16 flg = 0;
|
||||
if(use_bssid) {
|
||||
struct {
|
||||
u8 bssid[ETH_ALEN + 2];
|
||||
void * p;
|
||||
} bs = { 0 };
|
||||
memcpy(bs.bssid, pWifi->bssid.octet, ETH_ALEN);
|
||||
for(int i = 0; i < ETH_ALEN; i++) {
|
||||
flg += bs.bssid[i];
|
||||
}
|
||||
if(flg == 0x5FA || flg == 0) { // 0x5FA = 6*0xff
|
||||
use_bssid = 0;
|
||||
flg = 0;
|
||||
}
|
||||
else {
|
||||
use_bssid = 1;
|
||||
wext_set_bssid(WLAN0_NAME, bs.bssid);
|
||||
}
|
||||
}
|
||||
if(!use_bssid) {
|
||||
wext_set_ssid(WLAN0_NAME, join_result->network_info.ssid.val,
|
||||
join_result->network_info.ssid.len);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
join_user_data = join_result;
|
||||
|
||||
|
@ -604,10 +652,18 @@ int wifi_connect(char *ssid, rtw_security_t security_type, char *password,
|
|||
wifi_handshake_done_hdl);
|
||||
return result;
|
||||
}
|
||||
/*
|
||||
|
||||
int wifi_connect_bssid(unsigned char bssid[ETH_ALEN], char *ssid,
|
||||
rtw_security_t security_type, char *password, int bssid_len,
|
||||
int ssid_len, int password_len, int key_id, void *semaphore) {
|
||||
int wifi_connect_bssid(
|
||||
unsigned char bssid[ETH_ALEN],
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
char *password,
|
||||
int bssid_len,
|
||||
int ssid_len,
|
||||
int password_len,
|
||||
int key_id,
|
||||
void *semaphore) {
|
||||
xSemaphoreHandle join_semaphore;
|
||||
rtw_result_t result = RTW_SUCCESS;
|
||||
|
||||
|
@ -643,7 +699,7 @@ int wifi_connect_bssid(unsigned char bssid[ETH_ALEN], char *ssid,
|
|||
}
|
||||
join_result->network_info.password_len = password_len;
|
||||
if (password_len) {
|
||||
/* add \0 to the end */
|
||||
// add \0 to the end
|
||||
join_result->network_info.password = rtw_zmalloc(password_len + 1);
|
||||
if (!join_result->network_info.password) {
|
||||
return RTW_NOMEM;
|
||||
|
@ -726,6 +782,7 @@ int wifi_connect_bssid(unsigned char bssid[ETH_ALEN], char *ssid,
|
|||
wifi_handshake_done_hdl);
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
int wifi_disconnect(void) {
|
||||
int ret = 0;
|
||||
|
@ -740,7 +797,6 @@ int wifi_disconnect(void) {
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
int wifi_is_connected_to_ap(void) {
|
||||
return rltk_wlan_is_connected_to_ap();
|
||||
|
@ -874,17 +930,23 @@ int wifi_get_drv_ability(uint32_t *ability) {
|
|||
|
||||
//----------------------------------------------------------------------------//
|
||||
int wifi_set_country(rtw_country_code_t country_code) {
|
||||
return wext_set_country(WLAN0_NAME, country_code);
|
||||
int ret;
|
||||
|
||||
ret = wext_set_country(WLAN0_NAME, country_code);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
int wifi_set_channel_plan(uint8_t channel_plan) {
|
||||
const char * ifname = WLAN0_NAME;
|
||||
int ret = 0;
|
||||
char buf[24];
|
||||
|
||||
rtw_memset(buf, 0, sizeof(buf));
|
||||
snprintf(buf, 24, "set_ch_plan %x", channel_plan);
|
||||
return wext_private_command(ifname, buf, SHOW_PRIVATE_OUT);
|
||||
ret = wext_private_command(ifname, buf, SHOW_PRIVATE_OUT);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
@ -918,12 +980,16 @@ void wifi_set_mib(void) {
|
|||
|
||||
//----------------------------------------------------------------------------//
|
||||
int wifi_rf_on(void) {
|
||||
return rltk_wlan_rf_on();
|
||||
int ret;
|
||||
ret = rltk_wlan_rf_on();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
int wifi_rf_off(void) {
|
||||
return rltk_wlan_rf_off();
|
||||
int ret;
|
||||
ret = rltk_wlan_rf_off();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
@ -1070,63 +1136,21 @@ int wifi_get_last_error(void) {
|
|||
int wpas_wps_init(const char* ifname);
|
||||
#endif
|
||||
|
||||
int wifi_start_ap_s(PSOFTAP_CONFIG p) {
|
||||
const char *ifname = WLAN0_NAME;
|
||||
int ret = 0;
|
||||
|
||||
if (wifi_mode == RTW_MODE_STA_AP) {
|
||||
ifname = WLAN1_NAME;
|
||||
}
|
||||
|
||||
if (is_promisc_enabled())
|
||||
promisc_set(0, NULL, 0);
|
||||
|
||||
wifi_reg_event_handler(WIFI_EVENT_STA_ASSOC, wifi_ap_sta_assoc_hdl, NULL);
|
||||
wifi_reg_event_handler(WIFI_EVENT_STA_DISASSOC, wifi_ap_sta_disassoc_hdl,
|
||||
NULL);
|
||||
|
||||
ret = wext_set_mode(ifname, IW_MODE_MASTER);
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
ret = wext_set_channel(ifname, p->channel); //Set channel before starting ap
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
|
||||
switch (p->security_type) {
|
||||
case RTW_SECURITY_OPEN:
|
||||
break;
|
||||
case RTW_SECURITY_WPA2_AES_PSK:
|
||||
ret = wext_set_auth_param(ifname, IW_AUTH_80211_AUTH_ALG,
|
||||
IW_AUTH_ALG_OPEN_SYSTEM);
|
||||
if (ret == 0)
|
||||
ret = wext_set_key_ext(ifname, IW_ENCODE_ALG_CCMP, NULL, 0, 0, 0, 0,
|
||||
NULL, 0);
|
||||
if (ret == 0)
|
||||
ret = wext_set_passphrase(ifname, (u8*) p->password, strlen(p->password));
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
printf("WIFICONF: security type is not supported\n");
|
||||
break;
|
||||
}
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
if(p->ssid_hidden) {
|
||||
ret = set_hidden_ssid(ifname, 1);
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
}
|
||||
ret = wext_set_ap_ssid(ifname, (u8*) p->ssid, strlen(p->ssid));
|
||||
#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP
|
||||
wpas_wps_init(ifname);
|
||||
#endif
|
||||
exit: return ret;
|
||||
}
|
||||
|
||||
int wifi_start_ap(char *ssid, rtw_security_t security_type, char *password,
|
||||
int ssid_len, int password_len, int channel) {
|
||||
int wifi_start_ap(char *ssid, rtw_security_t security_type, char *password, int channel, char ssid_hidden) {
|
||||
const char *ifname = WLAN0_NAME;
|
||||
int ssid_len = 0;
|
||||
int password_len = 0;
|
||||
int ret = 0;
|
||||
if(ssid) {
|
||||
ssid_len = rtl_strlen(ssid);
|
||||
if(ssid_len > NDIS_802_11_LENGTH_SSID)
|
||||
ssid_len = NDIS_802_11_LENGTH_SSID;
|
||||
}
|
||||
if(password) {
|
||||
password_len = rtl_strlen(password);
|
||||
if(password_len > IW_PASSPHRASE_MAX_SIZE)
|
||||
password_len = IW_PASSPHRASE_MAX_SIZE;
|
||||
}
|
||||
|
||||
if (wifi_mode == RTW_MODE_STA_AP) {
|
||||
ifname = WLAN1_NAME;
|
||||
|
@ -1142,6 +1166,7 @@ int wifi_start_ap(char *ssid, rtw_security_t security_type, char *password,
|
|||
ret = wext_set_mode(ifname, IW_MODE_MASTER);
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
// if(!channel) channel = 1;
|
||||
ret = wext_set_channel(ifname, channel); //Set channel before starting ap
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
|
@ -1166,13 +1191,19 @@ int wifi_start_ap(char *ssid, rtw_security_t security_type, char *password,
|
|||
if (ret < 0)
|
||||
goto exit;
|
||||
|
||||
if(ssid_hidden) {
|
||||
ret = set_hidden_ssid(ifname, 1);
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = wext_set_ap_ssid(ifname, (u8*) ssid, ssid_len);
|
||||
#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP
|
||||
wpas_wps_init(ifname);
|
||||
#endif
|
||||
exit: return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
int wifi_start_ap_with_hidden_ssid(char *ssid, rtw_security_t security_type,
|
||||
char *password, int ssid_len, int password_len, int channel) {
|
||||
const char *ifname = WLAN0_NAME;
|
||||
|
@ -1226,6 +1257,7 @@ int wifi_start_ap_with_hidden_ssid(char *ssid, rtw_security_t security_type,
|
|||
#endif
|
||||
exit: return ret;
|
||||
}
|
||||
*/
|
||||
|
||||
void wifi_scan_each_report_hdl(char* buf, int buf_len, int flags,
|
||||
void* userdata) {
|
||||
|
@ -1710,7 +1742,7 @@ void wifi_enter_promisc_mode() {
|
|||
}
|
||||
|
||||
int wifi_restart_ap(unsigned char *ssid, rtw_security_t security_type,
|
||||
unsigned char *password, int ssid_len, int password_len, int channel) {
|
||||
unsigned char *password, int channel) {
|
||||
unsigned char idx = 0;
|
||||
struct ip_addr ipaddr;
|
||||
struct ip_addr netmask;
|
||||
|
@ -1747,8 +1779,7 @@ int wifi_restart_ap(unsigned char *ssid, rtw_security_t security_type,
|
|||
wifi_on(RTW_MODE_AP);
|
||||
}
|
||||
// start ap
|
||||
if (wifi_start_ap((char*) ssid, security_type, (char*) password, ssid_len,
|
||||
password_len, channel) < 0) {
|
||||
if (wifi_start_ap((char*) ssid, security_type, (char*) password, channel, 0) < 0) {
|
||||
printf("ERROR: Operation failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -3,16 +3,18 @@
|
|||
#define __WIFI_CONF_API_H
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "wifi_constants.h"
|
||||
#include "wifi_constants.h"
|
||||
#include "wifi_structures.h"
|
||||
#include "wifi_util.h"
|
||||
#include "wifi_ind.h"
|
||||
#include "wifi_ind.h"
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include "wifi_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
@ -137,14 +139,14 @@ int wifi_manager_init(void);
|
|||
* RTW_ERROR : if an error occurred
|
||||
*/
|
||||
int wifi_connect(
|
||||
unsigned char bssid[ETH_ALEN],
|
||||
char use_bssid,
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
char *password,
|
||||
int ssid_len,
|
||||
int password_len,
|
||||
int key_id,
|
||||
void *semaphore);
|
||||
|
||||
/*
|
||||
int wifi_connect_bssid(
|
||||
unsigned char bssid[ETH_ALEN],
|
||||
char *ssid,
|
||||
|
@ -155,7 +157,7 @@ int wifi_connect_bssid(
|
|||
int password_len,
|
||||
int key_id,
|
||||
void *semaphore);
|
||||
|
||||
*/
|
||||
/** Disassociates from a Wi-Fi network.
|
||||
*
|
||||
* @return RTW_SUCCESS : On successful disassociation from
|
||||
|
@ -446,6 +448,8 @@ int wifi_get_lps_dtim(unsigned char *dtim);
|
|||
* @return RTW_SUCCESS : if successfully creates an AP
|
||||
* RTW_ERROR : if an error occurred
|
||||
*/
|
||||
int wifi_start_ap(char *ssid, rtw_security_t security_type, char *password, int channel, char ssid_hidden);
|
||||
/*
|
||||
int wifi_start_ap(
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
|
@ -453,7 +457,7 @@ int wifi_start_ap(
|
|||
int ssid_len,
|
||||
int password_len,
|
||||
int channel);
|
||||
|
||||
*/
|
||||
/** Starts an infrastructure WiFi network with hidden SSID
|
||||
*
|
||||
* @warning If a STA interface is active when this function is called, the softAP will\n
|
||||
|
@ -478,6 +482,7 @@ int wifi_start_ap(
|
|||
* @return RTW_SUCCESS : if successfully creates an AP
|
||||
* RTW_ERROR : if an error occurred
|
||||
*/
|
||||
/*
|
||||
int wifi_start_ap_with_hidden_ssid(
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
|
@ -485,7 +490,7 @@ int wifi_start_ap_with_hidden_ssid(
|
|||
int ssid_len,
|
||||
int password_len,
|
||||
int channel);
|
||||
|
||||
*/
|
||||
/** Initiates a scan to search for 802.11 networks.
|
||||
*
|
||||
* The scan progressively accumulates results over time, and
|
||||
|
@ -638,8 +643,6 @@ int wifi_restart_ap(
|
|||
unsigned char *ssid,
|
||||
rtw_security_t security_type,
|
||||
unsigned char *password,
|
||||
int ssid_len,
|
||||
int password_len,
|
||||
int channel);
|
||||
|
||||
int wifi_config_autoreconnect(__u8 mode, __u8 retyr_times, __u16 timeout);
|
||||
|
|
|
@ -530,8 +530,13 @@ enum sc_result SC_parse_scan_result_and_connect(scan_buf_arg* scan_buf, rtw_netw
|
|||
ret = SC_TARGET_CHANNEL_SCAN_FAIL;
|
||||
goto sc_connect_wifi_fail;
|
||||
}
|
||||
ret = wifi_connect_bssid(scan_result.mac, (char*)wifi->ssid.val, SC_translate_iw_security_mode(scan_result.sec_mode),
|
||||
(char*)wifi->password, ETH_ALEN, wifi->ssid.len, wifi->password_len, 0, NULL);
|
||||
ret = wifi_connect(
|
||||
scan_result.mac,
|
||||
1,
|
||||
(char*)wifi->ssid.val,
|
||||
SC_translate_iw_security_mode(scan_result.sec_mode),
|
||||
(char*)wifi->password,
|
||||
0, NULL);
|
||||
if (ret == RTW_SUCCESS)
|
||||
goto sc_connect_wifi_success;
|
||||
}
|
||||
|
@ -691,8 +696,13 @@ enum sc_result SC_connect_to_AP(void)
|
|||
goto wifi_connect_fail;
|
||||
}
|
||||
rtw_join_status = 0;//clear simple config status
|
||||
ret = wifi_connect_bssid(g_bssid, (char*)wifi.ssid.val, wifi.security_type, (char*)wifi.password,
|
||||
ETH_ALEN, wifi.ssid.len, wifi.password_len, wifi.key_id, NULL);
|
||||
ret = wifi_connect(g_bssid,
|
||||
1,
|
||||
(char*)wifi.ssid.val,
|
||||
wifi.security_type,
|
||||
(char*)wifi.password,
|
||||
wifi.key_id,
|
||||
NULL);
|
||||
|
||||
if (ret == RTW_SUCCESS)
|
||||
goto wifi_connect_success;
|
||||
|
|
|
@ -68,15 +68,13 @@ struct simple_config_lib_config {
|
|||
|
||||
};
|
||||
|
||||
|
||||
#pragma pack(push, 1)
|
||||
#pragma pack(1)
|
||||
struct rtk_test_sc {
|
||||
/* API exposed to user */
|
||||
unsigned char ssid[32];
|
||||
unsigned char password[65];
|
||||
unsigned int ip_addr;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
/* expose data */
|
||||
extern s32 is_promisc_callback_unlock;
|
||||
|
|
|
@ -36,6 +36,11 @@
|
|||
#include "wifi_api.h"
|
||||
#include "wifi_user_set.h"
|
||||
|
||||
#ifdef CONFIG_ENABLE_WPS
|
||||
extern void cmd_ap_wps(int argc, char **argv);
|
||||
extern int wpas_wps_dev_config(u8 *dev_addr, u8 bregistrar);
|
||||
#endif //CONFIG_WPS_AP
|
||||
|
||||
//=========================================
|
||||
//--- Wlan Config Init-------------------
|
||||
WIFI_CONFIG wifi_cfg = {
|
||||
|
@ -68,6 +73,7 @@ STATION_CONFIG wifi_st_cfg = {
|
|||
.ssid = DEF_ST_SSID,
|
||||
.password = DEF_ST_PASSWORD,
|
||||
.bssid = DEF_ST_BSSID,
|
||||
.flg = DEF_ST_BSSID,
|
||||
.security_type = DEF_ST_SECURITY,
|
||||
.autoreconnect = DEF_ST_AUTORECONNECT,
|
||||
.reconnect_pause = DEF_ST_RECONNECT_PAUSE
|
||||
|
@ -115,9 +121,10 @@ uint32 write_wifi_cfg(uint32 flg)
|
|||
uint32 ret = 0;
|
||||
PFEEP_ELEMENT p = feep_tab;
|
||||
for(int m = 1; m && p->id != 0; m <<= 1, p++) {
|
||||
if((flg & m)
|
||||
&& flash_write_cfg(p->obj, p->id, p->size) < p->size) {
|
||||
ret |= m;
|
||||
if(flg & m) {
|
||||
if(!flash_write_cfg(p->obj, p->id, p->size)) {
|
||||
ret |= m;
|
||||
};
|
||||
};
|
||||
};
|
||||
return ret;
|
||||
|
@ -173,8 +180,6 @@ uint8 chk_ap_netif_num(void)
|
|||
return wlan_ap_netifn;
|
||||
}
|
||||
|
||||
extern int wifi_start_ap_s(PSOFTAP_CONFIG p);
|
||||
|
||||
rtw_result_t wifi_run_ap(void) {
|
||||
chk_ap_netif_num();
|
||||
|
||||
|
@ -186,7 +191,18 @@ rtw_result_t wifi_run_ap(void) {
|
|||
if(wext_set_sta_num(wifi_ap_cfg.max_sta) != 0) { // Max number of STAs, should be 1..3, default is 3
|
||||
error_printf("AP not set max connections %d!\n", wifi_ap_cfg.max_sta);
|
||||
};
|
||||
ret = wifi_start_ap_s(&wifi_ap_cfg);
|
||||
#if defined(CONFIG_ENABLE_WPS_AP) && CONFIG_ENABLE_WPS_AP
|
||||
// todo: ветка не доделана
|
||||
wpas_wps_dev_config(xnetif[WLAN_AP_NETIF_NUM].hwaddr, 1);
|
||||
#endif //CONFIG_WPS_AP
|
||||
if(wifi_ap_cfg.channel == 0 || wifi_ap_cfg.channel > 14) {
|
||||
wifi_ap_cfg.channel = 1;
|
||||
}
|
||||
ret = wifi_start_ap(wifi_ap_cfg.ssid, //char *ssid,
|
||||
wifi_ap_cfg.security_type, //rtw_security_t ecurity_type,
|
||||
wifi_ap_cfg.password, //char *password,
|
||||
wifi_ap_cfg.channel, //int channel
|
||||
wifi_ap_cfg.ssid_hidden); //
|
||||
wifi_run_mode |= RTW_MODE_AP;
|
||||
if (ret != RTW_SUCCESS) {
|
||||
error_printf("Error(%d): Start AP failed!\n\n", ret);;
|
||||
|
@ -233,13 +249,13 @@ rtw_result_t StartStDHCPClient(void)
|
|||
struct netif * pnetif = &xnetif[WLAN_ST_NETIF_NUM];
|
||||
DHCP_CONFIG *p = (dhcp_cfg *)&wifi_st_dhcp;
|
||||
unsigned char mode = p->mode;
|
||||
if((mode == 3)
|
||||
&& (p->ip == IP4ADDR(255,255,255,255)
|
||||
|| p->ip == IP4ADDR(0,0,0,0))) {
|
||||
mode = 2;
|
||||
if((mode == 3) // Auto fix
|
||||
&& p->ip != IP4ADDR(255,255,255,255)
|
||||
&& p->ip != IP4ADDR(0,0,0,0)) {
|
||||
// mode = 2; // fixed ip
|
||||
}
|
||||
else mode = 1;
|
||||
if(mode == 2) {
|
||||
else mode = 1; // DHCP On
|
||||
if(mode == 2) { // fixed ip
|
||||
netif_set_addr(pnetif, (ip_addr_t *)&p->ip, (ip_addr_t *)&p->mask, (ip_addr_t *)&p->gw);
|
||||
// dhcps_init(pnetif);
|
||||
}
|
||||
|
@ -254,8 +270,8 @@ rtw_result_t StartStDHCPClient(void)
|
|||
p->ip = pnetif->ip_addr.addr;
|
||||
p->gw = pnetif->gw.addr;
|
||||
p->mask = pnetif->netmask.addr;
|
||||
if(p->mode == 3) {
|
||||
p->mode = 2;
|
||||
if(p->mode == 3) { // Auto fix
|
||||
p->mode = 2; // fixed ip
|
||||
write_wifi_cfg(BID_ST_DHCP_CFG);
|
||||
}
|
||||
ret = RTW_SUCCESS;
|
||||
|
@ -282,9 +298,14 @@ rtw_result_t wifi_run_st(void) {
|
|||
}
|
||||
#endif
|
||||
info_printf("Connected to AP (%s, netif%d)...\n", wlan_st_name, wlan_st_netifn);
|
||||
ret = wifi_connect(wifi_st_cfg.ssid, wifi_st_cfg.security_type,
|
||||
wifi_st_cfg.password, strlen(wifi_st_cfg.ssid),
|
||||
strlen(wifi_st_cfg.password), -1, NULL);
|
||||
ret = wifi_connect(
|
||||
wifi_st_cfg.bssid,
|
||||
wifi_st_cfg.flg,
|
||||
wifi_st_cfg.ssid,
|
||||
wifi_st_cfg.security_type,
|
||||
wifi_st_cfg.password,
|
||||
-1,
|
||||
NULL);
|
||||
wifi_run_mode |= RTW_MODE_STA;
|
||||
if (ret != RTW_SUCCESS) {
|
||||
error_printf("%s: Operation failed! Error(%d)\n", __func__, ret);
|
||||
|
@ -328,7 +349,7 @@ int _wifi_on(rtw_mode_t mode) {
|
|||
// wext_set_adaptivity(RTW_ADAPTIVITY_NORMAL);
|
||||
// wext_set_adaptivity(RTW_ADAPTIVITY_CARRIER_SENSE);
|
||||
|
||||
devnum = (mode == RTW_MODE_STA_AP);
|
||||
devnum = (mode == RTW_MODE_STA_AP); // flag use 2 netif
|
||||
|
||||
ret = rltk_wlan_init(0, mode);
|
||||
if (ret < 0) return ret;
|
||||
|
@ -390,8 +411,9 @@ void _LwIP_Init(void)
|
|||
netif_set_up(&xnetif[idx]);
|
||||
}
|
||||
info_printf("interface %d is initialized\n", idx);
|
||||
wifi_mode = 0;
|
||||
lwip_init_done = 1;
|
||||
// для отслеживания первого старта ?
|
||||
// wifi_mode = RTW_MODE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,9 +422,6 @@ int wifi_run(rtw_mode_t mode) {
|
|||
#if CONFIG_DEBUG_LOG > 4
|
||||
debug_printf("\n%s(%d), %d\n", __func__, mode, wifi_run_mode);
|
||||
#endif
|
||||
if(mode != RTW_MODE_NONE) {
|
||||
_LwIP_Init();
|
||||
};
|
||||
if(wifi_run_mode & RTW_MODE_AP) {
|
||||
info_printf("Deinit old AP...\n");
|
||||
LwIP_DHCP(WLAN_AP_NETIF_NUM, DHCP_STOP);
|
||||
|
@ -435,25 +454,37 @@ int wifi_run(rtw_mode_t mode) {
|
|||
if(wifi_set_country(wifi_cfg.country_code) != RTW_SUCCESS) {
|
||||
error_printf("Error set tx country_code (%d)!", wifi_cfg.country_code);
|
||||
};
|
||||
// extern uint8_t rtw_power_percentage_idx; // rtw_tx_pwr_percentage_t
|
||||
#if 1 // rltk_set_tx_power_percentage() return all = 0 !
|
||||
rltk_set_tx_power_percentage(wifi_cfg.tx_pwr);
|
||||
#else
|
||||
// extern uint8_t rtw_power_percentage_idx;
|
||||
if(rtw_power_percentage_idx != wifi_cfg.tx_pwr) {
|
||||
if(rltk_set_tx_power_percentage(wifi_cfg.tx_pwr) != RTW_SUCCESS) {
|
||||
error_printf("Error set tx power (%d)!", wifi_cfg.tx_pwr);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
debug_printf("mode == wifi_mode? (%d == %d?)\n", mode, wifi_mode);
|
||||
// if(mode == wifi_mode)
|
||||
{
|
||||
if((wifi_mode == RTW_MODE_AP) || (wifi_mode == RTW_MODE_STA_AP)) {
|
||||
wifi_run_ap();
|
||||
};
|
||||
if((wifi_mode == RTW_MODE_STA) || (wifi_mode == RTW_MODE_STA_AP)) {
|
||||
wifi_run_st();
|
||||
};
|
||||
switch(wifi_mode) {
|
||||
case RTW_MODE_STA_AP:
|
||||
wifi_run_ap();
|
||||
wifi_run_st();
|
||||
break;
|
||||
case RTW_MODE_STA:
|
||||
wifi_run_st();
|
||||
break;
|
||||
case RTW_MODE_AP:
|
||||
wifi_run_ap();
|
||||
break;
|
||||
#if 0// CONFIG_ENABLE_??
|
||||
case RTW_MODE_PROMISC:
|
||||
break;
|
||||
#endif
|
||||
#if CONFIG_ENABLE_P2P
|
||||
case RTW_MODE_P2P:
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
error_printf("Error WiFi mode(%d)\n", wifi_mode);
|
||||
}
|
||||
#if CONFIG_INTERACTIVE_MODE
|
||||
/* Initial uart rx swmaphore*/
|
||||
vSemaphoreCreateBinary(uart_rx_interrupt_sema);
|
||||
|
@ -475,6 +506,7 @@ error_end:
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Load cfg, init WiFi + LwIP init, WiFi start if wifi_cfg.mode != RTW_MODE_NONE */
|
||||
void wifi_init(void) {
|
||||
debug_printf("\nLoad Config\n");
|
||||
read_wifi_cfg(wifi_cfg.load_flg); // DEF_LOAD_CFG
|
||||
|
@ -483,13 +515,12 @@ void wifi_init(void) {
|
|||
// Call back from application layer after wifi_connection success
|
||||
// p_write_reconnect_ptr = wlan_write_reconnect_data_to_flash;
|
||||
p_wlan_autoreconnect_hdl = NULL;
|
||||
if (wifi_cfg.mode != RTW_MODE_NONE) {
|
||||
wifi_mode = wifi_cfg.mode;
|
||||
_LwIP_Init();
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
wifi_manager_init();
|
||||
wifi_manager_init();
|
||||
#endif
|
||||
wifi_run(wifi_cfg.mode);
|
||||
}
|
||||
// wifi_cfg.mode = RTW_MODE_PROMISC; //RTW_MODE_P2P;
|
||||
wifi_run(wifi_cfg.mode);
|
||||
}
|
||||
|
||||
rtw_security_t translate_rtw_security(u8 security_type)
|
||||
|
@ -519,6 +550,7 @@ rtw_security_t translate_rtw_security(u8 security_type)
|
|||
return security_mode;
|
||||
}
|
||||
|
||||
|
||||
void show_wifi_ap_ip(void) {
|
||||
printf("SoftAP ip: " IPSTR "\n", IP2STR(&xnetif[WLAN_AP_NETIF_NUM].ip_addr));
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#ifndef _WIFI_API_H_
|
||||
#define _WIFI_API_H_
|
||||
#include "wifi_constants.h"
|
||||
#include "wifi_conf.h"
|
||||
|
||||
#define ip4_addr1(ipaddr) (((uint8_t*)(ipaddr))[0])
|
||||
#define ip4_addr2(ipaddr) (((uint8_t*)(ipaddr))[1])
|
||||
|
@ -64,21 +63,21 @@ typedef struct _wifi_config {
|
|||
typedef struct _softap_config {
|
||||
unsigned char ssid[NDIS_802_11_LENGTH_SSID];
|
||||
unsigned char password[IW_PASSPHRASE_MAX_SIZE];
|
||||
rtw_security_t security_type; // Only: RTW_SECURITY_OPEN, RTW_SECURITY_WPA2_AES_PSK
|
||||
unsigned short beacon_interval; // default 100
|
||||
rtw_security_t security_type; // RTW_SECURITY_OPEN, RTW_SECURITY_WEP_PSK
|
||||
uint16 beacon_interval; // Note: support 100 ~ 60000 ms, default 100
|
||||
unsigned char channel; // 1..14
|
||||
unsigned char ssid_hidden; // Note: default 0
|
||||
unsigned char max_sta; // 1..3
|
||||
} SOFTAP_CONFIG, * PSOFTAP_CONFIG;
|
||||
} SOFTAP_CONFIG, *PSOFTAP_CONFIG;
|
||||
//---- Interface 1 - wlan1 - ST - struct -
|
||||
typedef struct _station_config {
|
||||
unsigned char ssid[NDIS_802_11_LENGTH_SSID];
|
||||
unsigned char password[IW_PASSPHRASE_MAX_SIZE];
|
||||
rtw_security_t security_type;
|
||||
unsigned char bssid[6]; // Note: If bssid set is not ff.ff.ff.ff.ff.ff,
|
||||
// station will connect to the router with both ssid[] and bssid[] matched.
|
||||
unsigned char bssid[6]; // Note: If bssid set is not ff.ff.ff.ff.ff.ff || 00:00:00:00:00:00
|
||||
unsigned char autoreconnect; // 0 - none, 1..254 - count, 255 - all
|
||||
unsigned char reconnect_pause; // in sec
|
||||
unsigned char reconnect_pause; // in sec
|
||||
unsigned char flg; // station will connect to the router with both ssid[], else if set flg - bssid[] matched.
|
||||
// rtw_adaptivity_mode_t
|
||||
} STATION_CONFIG, *PSTATION_CONFIG;
|
||||
//--- LwIP Config -------------------------
|
||||
|
@ -106,6 +105,7 @@ extern DHCP_CONFIG wifi_ap_dhcp;
|
|||
extern STATION_CONFIG wifi_st_cfg;
|
||||
extern DHCP_CONFIG wifi_st_dhcp;
|
||||
extern rtw_mode_t wifi_run_mode;
|
||||
extern rtw_mode_t wifi_mode;
|
||||
extern char wlan_st_name[];
|
||||
extern char wlan_ap_name[];
|
||||
extern char wlan_st_netifn;
|
||||
|
|
|
@ -124,9 +124,9 @@ extern void cmd_googlenest(int argc, char **argv);
|
|||
extern void cmd_jd_smart(int argc, char **argv);
|
||||
#endif
|
||||
#if CONFIG_WLAN
|
||||
static void cmd_wifi_on(int argc, char **argv);
|
||||
static void cmd_wifi_off(int argc, char **argv);
|
||||
static void cmd_wifi_disconnect(int argc, char **argv);
|
||||
void cmd_wifi_on(int argc, char **argv);
|
||||
void cmd_wifi_off(int argc, char **argv);
|
||||
void cmd_wifi_disconnect(int argc, char **argv);
|
||||
extern void cmd_promisc(int argc, char **argv);
|
||||
extern void cmd_simple_config(int argc, char **argv);
|
||||
|
||||
|
@ -222,9 +222,8 @@ static void cmd_wifi_sta_and_ap(int argc, char **argv)
|
|||
if(wifi_start_ap(argv[1],
|
||||
RTW_SECURITY_WPA2_AES_PSK,
|
||||
argv[3],
|
||||
strlen((const char *)argv[1]),
|
||||
strlen((const char *)argv[3]),
|
||||
channel
|
||||
channel,
|
||||
0
|
||||
) != RTW_SUCCESS) {
|
||||
printf("ERROR: Operation failed!\n\n");
|
||||
return;
|
||||
|
@ -234,9 +233,8 @@ static void cmd_wifi_sta_and_ap(int argc, char **argv)
|
|||
if(wifi_start_ap(argv[1],
|
||||
RTW_SECURITY_OPEN,
|
||||
NULL,
|
||||
strlen((const char *)argv[1]),
|
||||
0,
|
||||
channel
|
||||
channel,
|
||||
0
|
||||
) != RTW_SUCCESS) {
|
||||
printf("ERROR: Operation failed!\n");
|
||||
return;
|
||||
|
@ -332,9 +330,8 @@ static void cmd_wifi_ap(int argc, char **argv)
|
|||
if(wifi_start_ap(argv[1],
|
||||
RTW_SECURITY_WPA2_AES_PSK,
|
||||
argv[3],
|
||||
strlen((const char *)argv[1]),
|
||||
strlen((const char *)argv[3]),
|
||||
channel
|
||||
channel,
|
||||
0
|
||||
) != RTW_SUCCESS) {
|
||||
printf("ERROR: Operation failed!\n");
|
||||
return;
|
||||
|
@ -344,9 +341,8 @@ static void cmd_wifi_ap(int argc, char **argv)
|
|||
if(wifi_start_ap(argv[1],
|
||||
RTW_SECURITY_OPEN,
|
||||
NULL,
|
||||
strlen((const char *)argv[1]),
|
||||
0,
|
||||
channel
|
||||
channel,
|
||||
0
|
||||
) != RTW_SUCCESS) {
|
||||
printf("ERROR: Operation failed!\n");
|
||||
return;
|
||||
|
@ -443,11 +439,12 @@ static void cmd_wifi_connect(int argc, char **argv)
|
|||
semaphore = NULL;
|
||||
}
|
||||
|
||||
ret = wifi_connect(ssid,
|
||||
security_type,
|
||||
password,
|
||||
ssid_len,
|
||||
password_len,
|
||||
ret = wifi_connect(
|
||||
NULL,
|
||||
0,
|
||||
ssid,
|
||||
security_type,
|
||||
password,
|
||||
key_id,
|
||||
semaphore);
|
||||
|
||||
|
@ -480,7 +477,6 @@ static void cmd_wifi_connect_bssid(int argc, char **argv)
|
|||
char *ssid = NULL;
|
||||
rtw_security_t security_type;
|
||||
char *password;
|
||||
int bssid_len;
|
||||
int ssid_len = 0;
|
||||
int password_len;
|
||||
int key_id;
|
||||
|
@ -525,21 +521,18 @@ static void cmd_wifi_connect_bssid(int argc, char **argv)
|
|||
if(argc == 3 + index){
|
||||
security_type = RTW_SECURITY_OPEN;
|
||||
password = NULL;
|
||||
bssid_len = ETH_ALEN;
|
||||
password_len = 0;
|
||||
key_id = 0;
|
||||
semaphore = NULL;
|
||||
}else if(argc ==4 + index){
|
||||
security_type = RTW_SECURITY_WPA2_AES_PSK;
|
||||
password = argv[3 + index];
|
||||
bssid_len = ETH_ALEN;
|
||||
password_len = strlen((const char *)argv[3 + index]);
|
||||
key_id = 0;
|
||||
semaphore = NULL;
|
||||
}else{
|
||||
security_type = RTW_SECURITY_WEP_PSK;
|
||||
password = argv[3 + index];
|
||||
bssid_len = ETH_ALEN;
|
||||
password_len = strlen((const char *)argv[3 + index]);
|
||||
key_id = atoi(argv[4 + index]);
|
||||
if(( password_len != 5) && (password_len != 13)) {
|
||||
|
@ -553,13 +546,12 @@ static void cmd_wifi_connect_bssid(int argc, char **argv)
|
|||
semaphore = NULL;
|
||||
}
|
||||
|
||||
ret = wifi_connect_bssid(bssid,
|
||||
ret = wifi_connect(
|
||||
bssid,
|
||||
1,
|
||||
ssid,
|
||||
security_type,
|
||||
password,
|
||||
bssid_len,
|
||||
ssid_len,
|
||||
password_len,
|
||||
security_type,
|
||||
password,
|
||||
key_id,
|
||||
semaphore);
|
||||
|
||||
|
@ -578,7 +570,7 @@ static void cmd_wifi_connect_bssid(int argc, char **argv)
|
|||
printf("Got IP after %dms.\n", (tick3-tick1));
|
||||
}
|
||||
|
||||
static void cmd_wifi_disconnect(int argc, char **argv)
|
||||
void cmd_wifi_disconnect(int argc, char **argv)
|
||||
{
|
||||
int timeout = 20;
|
||||
char essid[33];
|
||||
|
@ -714,14 +706,14 @@ static void cmd_wifi_info(int argc, char **argv)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void cmd_wifi_on(int argc, char **argv)
|
||||
void cmd_wifi_on(int argc, char **argv)
|
||||
{
|
||||
if(wifi_on(RTW_MODE_STA)<0){
|
||||
printf("ERROR: Wifi on failed!\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_wifi_off(int argc, char **argv)
|
||||
void cmd_wifi_off(int argc, char **argv)
|
||||
{
|
||||
#if CONFIG_WEBSERVER
|
||||
stop_web_server();
|
||||
|
@ -1059,7 +1051,7 @@ static const cmd_entry cmd_table[] = {
|
|||
{"wifi_wps", cmd_wps},
|
||||
#endif
|
||||
#ifdef CONFIG_WPS_AP
|
||||
//pvvx {"wifi_ap_wps", cmd_ap_wps},
|
||||
{"wifi_ap_wps", cmd_ap_wps},
|
||||
#endif
|
||||
#if CONFIG_ENABLE_P2P
|
||||
{"wifi_p2p_start", cmd_wifi_p2p_start},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue