mirror of
https://github.com/drasko/open-ameba.git
synced 2024-11-21 21:44:19 +00:00
update
This commit is contained in:
parent
d156fdcd7f
commit
f8449c5ae3
14 changed files with 2429 additions and 2422 deletions
|
@ -69,8 +69,8 @@ extern struct netif xnetif[NET_IF_NUM];
|
|||
/******************************************************
|
||||
* Variables Definitions
|
||||
******************************************************/
|
||||
static internal_scan_handler_t scan_result_handler_ptr = { 0, 0, 0, RTW_FALSE,
|
||||
0, 0, 0, 0, 0 };
|
||||
static internal_scan_handler_t scan_result_handler_ptr = {
|
||||
0, 0, 0, RTW_FALSE, 0, 0, 0, 0, 0 };
|
||||
static internal_join_result_t* join_user_data;
|
||||
rtw_mode_t wifi_mode = RTW_MODE_NONE;
|
||||
//extern rtw_mode_t wifi_mode;
|
||||
|
@ -1479,8 +1479,7 @@ int wifi_scan_networks_with_ssid(
|
|||
return ret;
|
||||
}
|
||||
|
||||
int wifi_scan_networks(rtw_scan_result_handler_t results_handler,
|
||||
void* user_data) {
|
||||
int wifi_scan_networks(rtw_scan_result_handler_t results_handler, void* user_data) {
|
||||
unsigned int max_ap_size = 64;
|
||||
|
||||
#if SCAN_USE_SEMAPHORE
|
||||
|
|
|
@ -142,7 +142,7 @@ int wifi_connect(
|
|||
unsigned char bssid[ETH_ALEN],
|
||||
char use_bssid,
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
rtw_security_t security_type,
|
||||
char *password,
|
||||
int key_id,
|
||||
void *semaphore);
|
||||
|
@ -172,13 +172,12 @@ int wifi_disconnect(void);
|
|||
* RTW_FALSE : If it's not
|
||||
*/
|
||||
int wifi_is_connected_to_ap(void);
|
||||
|
||||
/*check if wifi has connected to AP before dhcp
|
||||
*
|
||||
* @return RTW_SUCCESS:if conneced
|
||||
RTW_ERROR :if not connect
|
||||
*/
|
||||
|
||||
|
||||
int wifi_is_up(rtw_interface_t interface);
|
||||
|
||||
/** Determines if a particular interface is ready to transceive ethernet packets
|
||||
|
@ -412,7 +411,6 @@ int wifi_set_tdma_param(unsigned char slot_period, unsigned char rfon_period_len
|
|||
* RTW_ERROR otherwise
|
||||
*/
|
||||
int wifi_set_lps_dtim(unsigned char dtim);
|
||||
|
||||
/**
|
||||
* Get LPS DTIM
|
||||
*
|
||||
|
@ -522,9 +520,9 @@ int wifi_start_ap_with_hidden_ssid(
|
|||
*
|
||||
* @return RTW_SUCCESS or RTW_ERROR
|
||||
*/
|
||||
int wifi_scan(rtw_scan_type_t scan_type,
|
||||
rtw_bss_type_t bss_type,
|
||||
void* result_ptr);
|
||||
int wifi_scan(rtw_scan_type_t scan_type,
|
||||
rtw_bss_type_t bss_type,
|
||||
void* result_ptr);
|
||||
|
||||
/** Initiates a scan to search for 802.11 networks, a higher
|
||||
* level API based on wifi_scan to simplify the scan
|
||||
|
|
|
@ -524,16 +524,16 @@ int wifi_run(rtw_mode_t mode) {
|
|||
};
|
||||
if (mode != RTW_MODE_NONE) {
|
||||
if(wifi_set_country(wifi_cfg.country_code) != RTW_SUCCESS) {
|
||||
error_printf("Error set tx country_code (%d)!", wifi_cfg.country_code);
|
||||
error_printf("WiFi: Error set tx country_code (%d)!", wifi_cfg.country_code);
|
||||
};
|
||||
// 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);
|
||||
error_printf("WiFi: Error set tx power (%d)!", wifi_cfg.tx_pwr);
|
||||
};
|
||||
}
|
||||
if(wifi_set_network_mode(wifi_cfg.bgn) != RTW_SUCCESS) {
|
||||
error_printf("Error set network mode (%d)!", wifi_cfg.bgn);
|
||||
error_printf("WiFi: Error set network mode (%d)!", wifi_cfg.bgn);
|
||||
}
|
||||
debug_printf("mode == wifi_mode? (%d == %d?)\n", mode, wifi_mode);
|
||||
switch(wifi_mode) {
|
||||
|
@ -556,7 +556,7 @@ int wifi_run(rtw_mode_t mode) {
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
error_printf("Error WiFi mode(%d)\n", wifi_mode);
|
||||
error_printf("WiFi: Error mode(%d)\n", wifi_mode);
|
||||
}
|
||||
#if CONFIG_INTERACTIVE_MODE
|
||||
/* Initial uart rx swmaphore*/
|
||||
|
@ -564,6 +564,11 @@ int wifi_run(rtw_mode_t mode) {
|
|||
xSemaphoreTake(uart_rx_interrupt_sema, 1/portTICK_RATE_MS);
|
||||
start_interactive_mode();
|
||||
#endif
|
||||
if(wifi_cfg.sleep) {
|
||||
if(wext_enable_powersave(WLAN0_NAME, 1, 1) != RTW_SUCCESS) {
|
||||
error_printf("WiFi: Error set powersave mode!");
|
||||
};
|
||||
}
|
||||
ret = 1;
|
||||
} else {
|
||||
ret = 1;
|
||||
|
@ -594,32 +599,65 @@ void wifi_init(void) {
|
|||
wifi_run(wifi_cfg.mode);
|
||||
}
|
||||
|
||||
uint32 tab_rtw_security[] = {
|
||||
RTW_SECURITY_OPEN, //0 Open security
|
||||
RTW_SECURITY_WEP_PSK, //1 WEP Security with open authentication
|
||||
RTW_SECURITY_WEP_SHARED, //2 WEP Security with shared authentication
|
||||
RTW_SECURITY_WPA_TKIP_PSK, //3 WPA Security with TKIP
|
||||
RTW_SECURITY_WPA_AES_PSK, //4 WPA Security with AES
|
||||
RTW_SECURITY_WPA2_AES_PSK, //5 WPA2 Security with AES
|
||||
RTW_SECURITY_WPA2_TKIP_PSK, //6 WPA2 Security with TKIP
|
||||
RTW_SECURITY_WPA2_MIXED_PSK,//7 WPA2 Security with AES & TKIP
|
||||
RTW_SECURITY_WPA_WPA2_MIXED //8 WPA/WPA2 Security
|
||||
unsigned char *tab_txt_rtw_secyrity[] = {
|
||||
"OPEN", //0 Open security
|
||||
"WEP", //1 WEP Security with open authentication
|
||||
"WEP SHARED", //2 WEP Security with shared authentication
|
||||
"WPA TKIP", //3 WPA Security with TKIP
|
||||
"WPA AES", //4 WPA Security with AES
|
||||
"WPA2 AES", //5 WPA2 Security with TKIP
|
||||
"WPA2 TKIP", //6 WPA2 Security with AES
|
||||
"WPA2 Mixed", //7 WPA2 Security with AES & TKIP
|
||||
"WPA/WPA2 AES", //8 WPA/WPA2 Security
|
||||
"Unknown" //9
|
||||
};
|
||||
|
||||
unsigned int tab_code_rtw_secyrity[] = {
|
||||
RTW_SECURITY_OPEN, //0 Open security
|
||||
RTW_SECURITY_WEP_PSK, //1 WEP Security with open authentication
|
||||
RTW_SECURITY_WEP_SHARED, //2 WEP Security with shared authentication
|
||||
RTW_SECURITY_WPA_TKIP_PSK, //3 WPA Security with TKIP
|
||||
RTW_SECURITY_WPA_AES_PSK, //4 WPA Security with AES
|
||||
RTW_SECURITY_WPA2_TKIP_PSK, //5 WPA2 Security with TKIP
|
||||
RTW_SECURITY_WPA2_AES_PSK, //6 WPA2 Security with AES
|
||||
RTW_SECURITY_WPA2_MIXED_PSK, //7 WPA2 Security with AES & TKIP
|
||||
RTW_SECURITY_WPA_WPA2_MIXED, //8 WPA/WPA2 Security
|
||||
RTW_SECURITY_UNKNOWN //9
|
||||
};
|
||||
|
||||
unsigned char *tab_txt_rtw_eccryption[] = {
|
||||
"Unknown",
|
||||
"OPEN",
|
||||
"WEP40",
|
||||
"WPA_TKIP",
|
||||
"WPA_AES",
|
||||
"WPA2_TKIP",
|
||||
"WPA2_AES",
|
||||
"WPA2_MIXED",
|
||||
"???",
|
||||
"WEP104",
|
||||
"Udef" // 0xff
|
||||
};
|
||||
|
||||
|
||||
rtw_security_t translate_val_to_rtw_security(uint8 security_type)
|
||||
rtw_security_t idx_to_rtw_security(unsigned char idx)
|
||||
{
|
||||
if(security_type > 8) security_type = 5;
|
||||
return (rtw_security_t)tab_rtw_security[security_type];
|
||||
if(idx > 8) idx = 5;
|
||||
return (rtw_security_t)tab_code_rtw_secyrity[idx];
|
||||
}
|
||||
|
||||
uint8 translate_rtw_security_to_val(rtw_security_t security_type)
|
||||
unsigned char rtw_security_to_idx(rtw_security_t rtw_sec_type)
|
||||
{
|
||||
uint8 i = 0;
|
||||
while(i < 9 && tab_rtw_security[i] != security_type) i++;
|
||||
unsigned char i = 0;
|
||||
for(; rtw_sec_type != tab_code_rtw_secyrity[i] && tab_code_rtw_secyrity[i] != RTW_SECURITY_UNKNOWN; i++);
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
unsigned char * rtw_security_to_str(rtw_security_t rtw_sec_type)
|
||||
{
|
||||
return tab_txt_rtw_secyrity[rtw_security_to_idx(rtw_sec_type)];
|
||||
}
|
||||
|
||||
void show_wifi_ap_ip(void) {
|
||||
printf("SoftAP ip: " IPSTR "\n", IP2STR(&xnetif[WLAN_AP_NETIF_NUM].ip_addr));
|
||||
|
|
|
@ -122,8 +122,10 @@ uint32 write_wifi_cfg(uint32 flg);
|
|||
int wifi_run(rtw_mode_t mode);
|
||||
void wifi_init(void);
|
||||
|
||||
rtw_security_t translate_val_to_rtw_security(uint8 security_type);
|
||||
uint8 translate_rtw_security_to_val(rtw_security_t security_type);
|
||||
extern unsigned char *tab_txt_rtw_eccryption[];
|
||||
rtw_security_t idx_to_rtw_security(unsigned char idx);
|
||||
unsigned char rtw_security_to_idx(rtw_security_t rtw_sec_type);
|
||||
unsigned char * rtw_security_to_str(rtw_security_t rtw_sec_type);
|
||||
|
||||
void _LwIP_Init(void);
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ typedef struct rtw_network_info {
|
|||
int key_id;
|
||||
}rtw_network_info_t;
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__)
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
|
@ -94,16 +94,16 @@ typedef struct rtw_network_info {
|
|||
* @brief The structure is used to describe the scan result of the AP.
|
||||
*/
|
||||
typedef struct rtw_scan_result {
|
||||
rtw_ssid_t SSID; /**< Service Set Identification (i.e. Name of Access Point) */
|
||||
rtw_mac_t BSSID; /**< Basic Service Set Identification (i.e. MAC address of Access Point) */
|
||||
signed short signal_strength; /**< Receive Signal Strength Indication in dBm. <-90=Very poor, >-30=Excellent */
|
||||
rtw_bss_type_t bss_type; /**< Network type */
|
||||
rtw_security_t security; /**< Security type */
|
||||
rtw_wps_type_t wps_type; /**< WPS type */
|
||||
unsigned int channel; /**< Radio channel that the AP beacon was received on */
|
||||
rtw_802_11_band_t band; /**< Radio band */
|
||||
rtw_ssid_t SSID; /**< Service Set Identification (i.e. Name of Access Point) */
|
||||
rtw_mac_t BSSID; /**< Basic Service Set Identification (i.e. MAC address of Access Point) */
|
||||
signed short signal_strength; /**< Receive Signal Strength Indication in dBm. <-90=Very poor, >-30=Excellent */
|
||||
rtw_bss_type_t bss_type; /**< Network type */
|
||||
rtw_security_t security; /**< Security type */
|
||||
rtw_wps_type_t wps_type; /**< WPS type */
|
||||
unsigned int channel; /**< Radio channel that the AP beacon was received on */
|
||||
rtw_802_11_band_t band; /**< Radio band */
|
||||
} rtw_scan_result_t;
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__)
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
|
@ -117,7 +117,7 @@ typedef struct rtw_scan_handler_result {
|
|||
|
||||
} rtw_scan_handler_result_t;
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__)
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
|
@ -132,7 +132,7 @@ typedef struct rtw_wifi_setting {
|
|||
unsigned char password[65];
|
||||
unsigned char key_idx;
|
||||
}rtw_wifi_setting_t;
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__)
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4688
build/obj/build.nmap
4688
build/obj/build.nmap
File diff suppressed because it is too large
Load diff
|
@ -194,7 +194,7 @@
|
|||
=3 errors + warning + info,
|
||||
=4 errors + warning + info + debug,
|
||||
=5 full */
|
||||
#define CONFIG_DEBUG_LOG 4
|
||||
#define CONFIG_DEBUG_LOG 2
|
||||
#if CONFIG_DEBUG_LOG > 0
|
||||
//#define CONFIG_DEBUG_ERR_MSG 1
|
||||
#define CONFIG_DEBUG_LOG_ADC_HAL 1
|
||||
|
|
|
@ -52,7 +52,7 @@ LOCAL void fATPN(int argc, char *argv[]){
|
|||
}
|
||||
if(argc > 3) {
|
||||
if(pswlen > 7) {
|
||||
wifi_st_cfg.security_type = translate_val_to_rtw_security(atoi(argv[3]));
|
||||
wifi_st_cfg.security_type = idx_to_rtw_security(atoi(argv[3]));
|
||||
}
|
||||
else {
|
||||
printf("password len < 8!\n");
|
||||
|
@ -213,31 +213,7 @@ LOCAL void fATSF(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* -------- WiFi Scan ------------------------------- */
|
||||
unsigned char *tab_txt_rtw_secyrity[] = {
|
||||
"OPEN ",
|
||||
"WEP ",
|
||||
"WPA TKIP",
|
||||
"WPA AES",
|
||||
"WPA2 AES",
|
||||
"WPA2 TKIP",
|
||||
"WPA2 Mixed",
|
||||
"WPA/WPA2 AES",
|
||||
"Unknown"
|
||||
};
|
||||
int *tab_code_rtw_secyrity[] = {
|
||||
RTW_SECURITY_OPEN,
|
||||
RTW_SECURITY_WEP_PSK,
|
||||
RTW_SECURITY_WPA_TKIP_PSK,
|
||||
RTW_SECURITY_WPA_AES_PSK,
|
||||
RTW_SECURITY_WPA2_AES_PSK,
|
||||
RTW_SECURITY_WPA2_TKIP_PSK,
|
||||
RTW_SECURITY_WPA2_MIXED_PSK,
|
||||
RTW_SECURITY_WPA_WPA2_MIXED,
|
||||
RTW_SECURITY_UNKNOWN
|
||||
};
|
||||
|
||||
volatile uint8_t scan_end;
|
||||
|
||||
/* -------- WiFi Scan ------------------------------- */
|
||||
LOCAL rtw_result_t _scan_result_handler( rtw_scan_handler_result_t* malloced_scan_result )
|
||||
{
|
||||
|
@ -254,9 +230,11 @@ LOCAL rtw_result_t _scan_result_handler( rtw_scan_handler_result_t* malloced_sca
|
|||
printf("\t%d\t", record->signal_strength);
|
||||
printf("%d\t", record->channel);
|
||||
printf("%d\t", record->wps_type);
|
||||
int i = 0;
|
||||
for(; record->security != tab_code_rtw_secyrity[i] && tab_code_rtw_secyrity[i] != RTW_SECURITY_UNKNOWN; i++);
|
||||
printf("%s \t", tab_txt_rtw_secyrity[i]);
|
||||
{
|
||||
uint8 * s = rtw_security_to_str(record->security);
|
||||
printf("%s\t", s);
|
||||
if(strlen(s) < 8) printf("\t");
|
||||
}
|
||||
printf("%s\n", record->SSID.val);
|
||||
} else {
|
||||
scan_end = 0;
|
||||
|
|
Loading…
Reference in a new issue