open-ameba/RTL00_SDKV35a/component/common/api/wifi_api.h

134 lines
4.6 KiB
C
Raw Normal View History

2017-03-09 08:23:37 +00:00
/*
* wifi_user_set.h
*
* Created on: 01/04/2017
* Author: pvvx
*/
#ifndef _WIFI_API_H_
#define _WIFI_API_H_
2017-04-03 07:32:32 +00:00
#include "wifi_constants.h"
2017-03-09 08:23:37 +00:00
2017-04-03 07:32:32 +00:00
#define ip4_addr1(ipaddr) (((uint8_t*)(ipaddr))[0])
#define ip4_addr2(ipaddr) (((uint8_t*)(ipaddr))[1])
#define ip4_addr3(ipaddr) (((uint8_t*)(ipaddr))[2])
#define ip4_addr4(ipaddr) (((uint8_t*)(ipaddr))[3])
2017-03-09 08:23:37 +00:00
#define IPSTR "%d.%d.%d.%d"
#define IP2STR(ipaddr) \
ip4_addr1(ipaddr), \
ip4_addr2(ipaddr), \
ip4_addr3(ipaddr), \
ip4_addr4(ipaddr)
2017-03-10 02:09:27 +00:00
extern char str_rom_57ch3Dch0A[]; // "=========================================================\n" 57
2017-03-09 08:23:37 +00:00
#define BID_WIFI_AP_CFG (1 << 0)
#define BID_WIFI_ST_CFG (1 << 1)
#define BID_AP_DHCP_CFG (1 << 2)
#define BID_ST_DHCP_CFG (1 << 3)
#define BID_WIFI_CFG (1 << 4)
2017-04-24 14:03:34 +00:00
#define BID_ALL_WIFI_CFG (BID_WIFI_AP_CFG|BID_WIFI_ST_CFG|BID_AP_DHCP_CFG|BID_ST_DHCP_CFG)
2017-03-09 08:23:37 +00:00
#define WLAN_ST_NETIF_NUM wlan_st_netifn
#define WLAN_AP_NETIF_NUM wlan_ap_netifn
//==== FEEP_ID ===========================
#define FEEP_ID_WIFI_CFG 0x4347 // id:'GC'
#define FEEP_ID_WIFI_AP_CFG 0x5041 // id:'AP'
#define FEEP_ID_WIFI_ST_CFG 0x5453 // id:'ST'
#define FEEP_ID_AP_DHCP_CFG 0x4144 // id:'DA'
#define FEEP_ID_ST_DHCP_CFG 0x5344 // id:'DS'
#define FEEP_ID_UART_CFG 0x5530 // id:'0U', type: UART_LOG_CONF
#define FEEP_ID_LWIP_CFG 0x4C30 // id:'0L', type: struct atcmd_lwip_conf
#define FEEP_ID_DHCP_CFG 0x4430 // id:'0D', type: struct
//=========================================
#define IW_PASSPHRASE_MAX_SIZE 64
#define NDIS_802_11_LENGTH_SSID 32
#define IP4ADDR(a,b,c,d) (((unsigned int)((d) & 0xff) << 24) | \
((unsigned int)((c) & 0xff) << 16) | \
((unsigned int)((b) & 0xff) << 8) | \
(unsigned int)((a) & 0xff))
//=========================================
//--- Wlan Config struct-------------------
typedef struct _wifi_config {
unsigned char mode; // rtw_mode_t
unsigned char sleep;
unsigned char country_code; // rtw_country_code_t
unsigned char tx_pwr; // rtw_tx_pwr_percentage_t
unsigned char bgn; // 802.11 rtw_network_mode_t
unsigned char load_flg;
unsigned char save_flg;
} WIFI_CONFIG, *PWIFI_CONFIG;
//---- Interface 0 - wlan0 - AP - struct --
typedef struct _softap_config {
unsigned char ssid[NDIS_802_11_LENGTH_SSID];
unsigned char password[IW_PASSPHRASE_MAX_SIZE];
2017-04-23 09:27:41 +00:00
rtw_security_t security_type; // RTW_SECURITY_WPA2_AES_PSK or RTW_SECURITY_OPEN
2017-04-22 13:44:33 +00:00
uint16 beacon_interval; // Note: support 100 ~ 60000 ms, default 100
2017-03-09 08:23:37 +00:00
unsigned char channel; // 1..14
unsigned char ssid_hidden; // Note: default 0
unsigned char max_sta; // 1..3
2017-04-22 13:44:33 +00:00
} SOFTAP_CONFIG, *PSOFTAP_CONFIG;
2017-03-09 08:23:37 +00:00
//---- 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;
2017-04-22 13:44:33 +00:00
unsigned char bssid[6]; // Note: If bssid set is not ff.ff.ff.ff.ff.ff || 00:00:00:00:00:00
2017-03-09 08:23:37 +00:00
unsigned char autoreconnect; // 0 - none, 1..254 - count, 255 - all
2017-04-22 13:44:33 +00:00
unsigned char reconnect_pause; // in sec
unsigned char flg; // station will connect to the router with both ssid[], else if set flg - bssid[] matched.
2017-03-09 08:23:37 +00:00
// rtw_adaptivity_mode_t
} STATION_CONFIG, *PSTATION_CONFIG;
//--- LwIP Config -------------------------
struct lwip_conn_info {
int32_t role; //client, server or seed
unsigned int protocol; //tcp or udp
unsigned int remote_addr; //remote ip
unsigned int remote_port; //remote port
unsigned int local_addr; //locale ip, not used yet
unsigned int local_port; //locale port, not used yet
unsigned int reserved; //reserve for further use
};
//--- DHCP Config -------------------------
typedef struct _dhcp_config {
unsigned int ip;
unsigned int mask;
unsigned int gw;
unsigned char mode; // =0 dhcp off, =1 - dhcp on, =2 Static ip, =3 - auto
} DHCP_CONFIG, *PDHCP_CONFIG;
2017-04-03 07:32:32 +00:00
extern WIFI_CONFIG wifi_cfg;
extern SOFTAP_CONFIG wifi_ap_cfg;
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;
2017-04-22 13:44:33 +00:00
extern rtw_mode_t wifi_mode;
2017-04-03 07:32:32 +00:00
extern char wlan_st_name[];
extern char wlan_ap_name[];
extern char wlan_st_netifn;
extern char wlan_ap_netifn;
2017-03-09 08:23:37 +00:00
void show_wifi_ap_ip(void);
void show_wifi_st_ip(void);
void show_wifi_cfg(void);
void show_wifi_st_cfg(void);
void show_wifi_ap_cfg(void);
uint32 read_wifi_cfg(uint32 flg);
uint32 write_wifi_cfg(uint32 flg);
int wifi_run(rtw_mode_t mode);
2017-04-03 07:32:32 +00:00
void wifi_init(void);
2017-04-23 15:12:51 +00:00
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);
2017-04-23 09:27:41 +00:00
2017-04-03 07:32:32 +00:00
void _LwIP_Init(void);
2017-03-09 08:23:37 +00:00
#endif // _WIFI_API_H_