mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-23 07:29:20 -08:00
Merged branch testing into testing
This commit is contained in:
14
README.md
14
README.md
@@ -100,12 +100,20 @@ It doesn’t matter which board you use, as long as it has an ESP8266 on it.
|
||||
|
||||
**don't forget to save!**
|
||||
|
||||
**12** Download and open `esp8266_deauther` > `esp8266_deauther.ino` in Arduino
|
||||
**12** Download the project
|
||||
|
||||
**13** Select your ESP8266 board at `Tools` > `Board` and the right port at `Tools` > `Port`
|
||||
**13** Go to the SDK_fix folder of this project
|
||||
|
||||
**14** Copy ESP8266WiFi.cpp and ESP8266WiFi.h
|
||||
|
||||
**15** Past these files here `packages` > `esp8266` > `hardware` > `esp8266` > `2.0.0` > `libraries` > `ESP8266WiFi` > `src`
|
||||
|
||||
**16** Open `esp8266_deauther` > `esp8266_deauther.ino` in Arduino
|
||||
|
||||
**17** Select your ESP8266 board at `Tools` > `Board` and the right port at `Tools` > `Port`
|
||||
If no port shows up you may have to reinstall the drivers.
|
||||
|
||||
**14** Upload!
|
||||
**18** Upload!
|
||||
|
||||
**Your ESP8266 Deauther is now ready!**
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ APScan::APScan(){
|
||||
bool APScan::start(){
|
||||
if(debug){
|
||||
Serial.println("starting AP scan...");
|
||||
Serial.println("MAC - Ch - RSSI - Encrypt. - SSID");// - Vendor");
|
||||
Serial.println("MAC - Ch - RSSI - Encrypt. - SSID - Hidden");// - Vendor");
|
||||
}
|
||||
aps._clear();
|
||||
for(int i=0;i<maxAPScanResults;i++) selected[i] = false;
|
||||
results = WiFi.scanNetworks();
|
||||
results = WiFi.scanNetworks(false, true); // lets scanNetworks return hidden APs. (async = false & show_hidden = true)
|
||||
|
||||
for(int i=0;i<results && i<maxAPScanResults;i++){
|
||||
Mac _ap;
|
||||
@@ -20,6 +20,7 @@ bool APScan::start(){
|
||||
channels[i] = WiFi.channel(i);
|
||||
rssi[i] = WiFi.RSSI(i);
|
||||
encryption[i] = WiFi.encryptionType(i);
|
||||
hidden[i] = WiFi.isHidden(i);
|
||||
String _ssid = WiFi.SSID(i);
|
||||
_ssid.replace("\"","\\\"");
|
||||
_ssid.toCharArray(names[i],33);
|
||||
@@ -34,6 +35,8 @@ bool APScan::start(){
|
||||
Serial.print(getEncryption(encryption[i]));
|
||||
Serial.print(" - ");
|
||||
Serial.print(names[i]);
|
||||
Serial.print(" - ");
|
||||
Serial.print(hidden[i]);
|
||||
//Serial.print(" - ");
|
||||
//Serial.print(vendors[i]);
|
||||
Serial.println();
|
||||
@@ -93,11 +96,15 @@ String APScan::getEncryption(int code){
|
||||
return "?";
|
||||
}
|
||||
|
||||
String APScan::getAPName(int num){ return names[num]; }
|
||||
String APScan::getAPName(int num){
|
||||
if(isHidden(num)) return "* Hidden SSID *";
|
||||
return names[num];
|
||||
}
|
||||
String APScan::getAPEncryption(int num){ return getEncryption(encryption[num]); }
|
||||
//String APScan::getAPVendor(int num){ return vendors[num]; }
|
||||
String APScan::getAPMac(int num){ return aps._get(num).toString(); }
|
||||
bool APScan::getAPSelected(int num){ return selected[num]; }
|
||||
bool APScan::isHidden(int num){ return hidden[num]; }
|
||||
int APScan::getAPRSSI(int num){ return rssi[num]; }
|
||||
int APScan::getAPChannel(int num){ return channels[num]; }
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ class APScan{
|
||||
//String getAPVendor(int num);
|
||||
String getAPMac(int num);
|
||||
bool getAPSelected(int num);
|
||||
bool isHidden(int num);
|
||||
int getAPRSSI(int num);
|
||||
int getAPChannel(int num);
|
||||
|
||||
@@ -37,7 +38,8 @@ class APScan{
|
||||
int rssi[maxAPScanResults];
|
||||
char names[maxAPScanResults][33];
|
||||
int encryption[maxAPScanResults];
|
||||
|
||||
bool hidden[maxAPScanResults];
|
||||
|
||||
String getEncryption(int code);
|
||||
|
||||
bool selected[maxAPScanResults];
|
||||
|
||||
@@ -154,7 +154,7 @@ void Attack::run(){
|
||||
prevTime[1] = millis();
|
||||
|
||||
for(int a=0;a<apScan.results;a++){
|
||||
if(apScan.isSelected(a)){
|
||||
if(apScan.isSelected(a) && !apScan.isHidden(a)){
|
||||
String _ssid = apScan.getAPName(a);
|
||||
int _ssidLen = _ssid.length();
|
||||
int _restSSIDLen = 32 - _ssidLen;
|
||||
|
||||
962
sdk_fix/ESP8266WiFi.cpp
Normal file
962
sdk_fix/ESP8266WiFi.cpp
Normal file
@@ -0,0 +1,962 @@
|
||||
/*
|
||||
ESP8266WiFi.cpp - WiFi library for esp8266
|
||||
|
||||
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
||||
This file is part of the esp8266 core for Arduino environment.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "ESP8266WiFi.h"
|
||||
|
||||
extern "C" {
|
||||
#include "c_types.h"
|
||||
#include "ets_sys.h"
|
||||
#include "os_type.h"
|
||||
#include "osapi.h"
|
||||
#include "mem.h"
|
||||
#include "user_interface.h"
|
||||
#include "smartconfig.h"
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/dns.h"
|
||||
}
|
||||
|
||||
#include "WiFiClient.h"
|
||||
#include "WiFiUdp.h"
|
||||
#include "debug.h"
|
||||
|
||||
extern "C" void esp_schedule();
|
||||
extern "C" void esp_yield();
|
||||
|
||||
ESP8266WiFiClass::ESP8266WiFiClass()
|
||||
: _smartConfigStarted(false)
|
||||
, _smartConfigDone(false)
|
||||
, _useStaticIp(false)
|
||||
, _persistent(true)
|
||||
{
|
||||
uint8 m = wifi_get_opmode();
|
||||
_useClientMode = (m & WIFI_STA);
|
||||
_useApMode = (m & WIFI_AP);
|
||||
wifi_set_event_handler_cb((wifi_event_handler_cb_t)&ESP8266WiFiClass::_eventCallback);
|
||||
}
|
||||
|
||||
void ESP8266WiFiClass::persistent(bool persistent)
|
||||
{
|
||||
_persistent = persistent;
|
||||
}
|
||||
|
||||
|
||||
void ESP8266WiFiClass::mode(WiFiMode m)
|
||||
{
|
||||
if(wifi_get_opmode() == (uint8)m) {
|
||||
return;
|
||||
}
|
||||
|
||||
if((m & WIFI_AP)) {
|
||||
_useApMode = true;
|
||||
} else {
|
||||
_useApMode = false;
|
||||
}
|
||||
|
||||
if((m & WIFI_STA)) {
|
||||
_useClientMode = true;
|
||||
} else {
|
||||
_useClientMode = false;
|
||||
}
|
||||
|
||||
_mode(m);
|
||||
}
|
||||
|
||||
WiFiMode ESP8266WiFiClass::getMode()
|
||||
{
|
||||
return (WiFiMode)wifi_get_opmode();
|
||||
}
|
||||
|
||||
void ESP8266WiFiClass::_mode(WiFiMode m)
|
||||
{
|
||||
if(wifi_get_opmode() == (uint8)m) {
|
||||
return;
|
||||
}
|
||||
|
||||
ETS_UART_INTR_DISABLE();
|
||||
if (_persistent)
|
||||
wifi_set_opmode(m);
|
||||
else
|
||||
wifi_set_opmode_current(m);
|
||||
ETS_UART_INTR_ENABLE();
|
||||
|
||||
}
|
||||
|
||||
static bool sta_config_equal(const station_config& lhs, const station_config& rhs)
|
||||
{
|
||||
if (strcmp(reinterpret_cast<const char*>(lhs.ssid), reinterpret_cast<const char*>(rhs.ssid)) != 0)
|
||||
return false;
|
||||
|
||||
if (strcmp(reinterpret_cast<const char*>(lhs.password), reinterpret_cast<const char*>(rhs.password)) != 0)
|
||||
return false;
|
||||
|
||||
if (lhs.bssid_set) {
|
||||
if (!rhs.bssid_set)
|
||||
return false;
|
||||
|
||||
if (memcmp(lhs.bssid, rhs.bssid, 6) != 0)
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (rhs.bssid_set)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int ESP8266WiFiClass::begin(char* ssid, char *passphrase, int32_t channel, const uint8_t* bssid)
|
||||
{
|
||||
return begin((const char*) ssid, (const char*) passphrase, channel, bssid);
|
||||
}
|
||||
|
||||
int ESP8266WiFiClass::begin(const char* ssid, const char *passphrase, int32_t channel, const uint8_t* bssid)
|
||||
{
|
||||
_useClientMode = true;
|
||||
|
||||
if(_useApMode) {
|
||||
// turn on AP+STA mode
|
||||
_mode(WIFI_AP_STA);
|
||||
} else {
|
||||
// turn on STA mode
|
||||
_mode(WIFI_STA);
|
||||
}
|
||||
|
||||
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
|
||||
// fail SSID too long or missing!
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
if(passphrase && strlen(passphrase) > 63) {
|
||||
// fail passphrase too long!
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
struct station_config conf;
|
||||
strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
|
||||
|
||||
if (passphrase) {
|
||||
strcpy(reinterpret_cast<char*>(conf.password), passphrase);
|
||||
} else {
|
||||
*conf.password = 0;
|
||||
}
|
||||
|
||||
if (bssid) {
|
||||
conf.bssid_set = 1;
|
||||
memcpy((void *) &conf.bssid[0], (void *) bssid, 6);
|
||||
} else {
|
||||
conf.bssid_set = 0;
|
||||
}
|
||||
|
||||
struct station_config current_conf;
|
||||
wifi_station_get_config(¤t_conf);
|
||||
if (sta_config_equal(current_conf, conf)) {
|
||||
DEBUGV("sta config unchanged");
|
||||
return status();
|
||||
}
|
||||
|
||||
ETS_UART_INTR_DISABLE();
|
||||
if (_persistent)
|
||||
wifi_station_set_config(&conf);
|
||||
else
|
||||
wifi_station_set_config_current(&conf);
|
||||
wifi_station_connect();
|
||||
ETS_UART_INTR_ENABLE();
|
||||
|
||||
if(channel > 0 && channel <= 13) {
|
||||
wifi_set_channel(channel);
|
||||
}
|
||||
|
||||
if(!_useStaticIp)
|
||||
wifi_station_dhcpc_start();
|
||||
return status();
|
||||
}
|
||||
|
||||
int ESP8266WiFiClass::begin()
|
||||
{
|
||||
ETS_UART_INTR_DISABLE();
|
||||
wifi_station_connect();
|
||||
ETS_UART_INTR_ENABLE();
|
||||
|
||||
if(!_useStaticIp)
|
||||
wifi_station_dhcpc_start();
|
||||
return status();
|
||||
}
|
||||
|
||||
uint8_t ESP8266WiFiClass::waitForConnectResult(){
|
||||
if ((wifi_get_opmode() & 1) == 0)//1 and 3 have STA enabled
|
||||
return WL_DISCONNECTED;
|
||||
while (status() == WL_DISCONNECTED)
|
||||
delay(100);
|
||||
return status();
|
||||
}
|
||||
|
||||
|
||||
// You will have to set the DNS-Server manually later since this will not enable DHCP2
|
||||
void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet)
|
||||
{
|
||||
struct ip_info info;
|
||||
info.ip.addr = static_cast<uint32_t>(local_ip);
|
||||
info.gw.addr = static_cast<uint32_t>(gateway);
|
||||
info.netmask.addr = static_cast<uint32_t>(subnet);
|
||||
|
||||
wifi_station_dhcpc_stop();
|
||||
wifi_set_ip_info(STATION_IF, &info);
|
||||
|
||||
_useStaticIp = true;
|
||||
}
|
||||
|
||||
void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns)
|
||||
{
|
||||
struct ip_info info;
|
||||
info.ip.addr = static_cast<uint32_t>(local_ip);
|
||||
info.gw.addr = static_cast<uint32_t>(gateway);
|
||||
info.netmask.addr = static_cast<uint32_t>(subnet);
|
||||
|
||||
wifi_station_dhcpc_stop();
|
||||
wifi_set_ip_info(STATION_IF, &info);
|
||||
|
||||
// Set DNS-Server
|
||||
ip_addr_t d;
|
||||
d.addr = static_cast<uint32_t>(dns);
|
||||
dns_setserver(0,&d);
|
||||
|
||||
_useStaticIp = true;
|
||||
}
|
||||
|
||||
int ESP8266WiFiClass::softAPdisconnect(bool wifioff)
|
||||
{
|
||||
struct softap_config conf;
|
||||
*conf.ssid = 0;
|
||||
*conf.password = 0;
|
||||
ETS_UART_INTR_DISABLE();
|
||||
if (_persistent)
|
||||
wifi_softap_set_config(&conf);
|
||||
else
|
||||
wifi_softap_set_config_current(&conf);
|
||||
ETS_UART_INTR_ENABLE();
|
||||
|
||||
if(wifioff) {
|
||||
_useApMode = false;
|
||||
|
||||
if( _useClientMode) {
|
||||
// turn on STA
|
||||
_mode(WIFI_STA);
|
||||
} else {
|
||||
// turn wifi off
|
||||
_mode(WIFI_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ESP8266WiFiClass::disconnect(bool wifioff)
|
||||
{
|
||||
struct station_config conf;
|
||||
*conf.ssid = 0;
|
||||
*conf.password = 0;
|
||||
ETS_UART_INTR_DISABLE();
|
||||
if (_persistent)
|
||||
wifi_station_set_config(&conf);
|
||||
else
|
||||
wifi_station_set_config_current(&conf);
|
||||
wifi_station_disconnect();
|
||||
ETS_UART_INTR_ENABLE();
|
||||
|
||||
if(wifioff) {
|
||||
_useClientMode = false;
|
||||
|
||||
if(_useApMode) {
|
||||
// turn on AP
|
||||
_mode(WIFI_AP);
|
||||
} else {
|
||||
// turn wifi off
|
||||
_mode(WIFI_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool softap_config_equal(const softap_config& lhs, const softap_config& rhs)
|
||||
{
|
||||
if (strcmp(reinterpret_cast<const char*>(lhs.ssid), reinterpret_cast<const char*>(rhs.ssid)) != 0)
|
||||
return false;
|
||||
if (strcmp(reinterpret_cast<const char*>(lhs.password), reinterpret_cast<const char*>(rhs.password)) != 0)
|
||||
return false;
|
||||
if (lhs.channel != rhs.channel)
|
||||
return false;
|
||||
if (lhs.ssid_hidden != rhs.ssid_hidden)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ESP8266WiFiClass::softAP(const char* ssid)
|
||||
{
|
||||
softAP(ssid, 0);
|
||||
}
|
||||
|
||||
|
||||
void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden)
|
||||
{
|
||||
_useApMode = true;
|
||||
if(_useClientMode) {
|
||||
// turn on AP+STA mode
|
||||
_mode(WIFI_AP_STA);
|
||||
} else {
|
||||
// turn on STA mode
|
||||
_mode(WIFI_AP);
|
||||
}
|
||||
|
||||
if(!ssid || *ssid == 0 || strlen(ssid) > 31) {
|
||||
// fail SSID too long or missing!
|
||||
return;
|
||||
}
|
||||
|
||||
if(passphrase && strlen(passphrase) > 63) {
|
||||
// fail passphrase to long!
|
||||
return;
|
||||
}
|
||||
|
||||
struct softap_config conf;
|
||||
wifi_softap_get_config(&conf);
|
||||
strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
|
||||
conf.channel = channel;
|
||||
conf.ssid_len = strlen(ssid);
|
||||
conf.ssid_hidden = ssid_hidden;
|
||||
conf.max_connection = 4;
|
||||
conf.beacon_interval = 100;
|
||||
|
||||
if (!passphrase || strlen(passphrase) == 0)
|
||||
{
|
||||
conf.authmode = AUTH_OPEN;
|
||||
*conf.password = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
conf.authmode = AUTH_WPA2_PSK;
|
||||
strcpy(reinterpret_cast<char*>(conf.password), passphrase);
|
||||
}
|
||||
|
||||
struct softap_config conf_current;
|
||||
wifi_softap_get_config(&conf_current);
|
||||
if (softap_config_equal(conf, conf_current))
|
||||
{
|
||||
DEBUGV("softap config unchanged");
|
||||
return;
|
||||
}
|
||||
|
||||
ETS_UART_INTR_DISABLE();
|
||||
if (_persistent)
|
||||
wifi_softap_set_config(&conf);
|
||||
else
|
||||
wifi_softap_set_config_current(&conf);
|
||||
ETS_UART_INTR_ENABLE();
|
||||
}
|
||||
|
||||
void ESP8266WiFiClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet)
|
||||
{
|
||||
struct ip_info info;
|
||||
info.ip.addr = static_cast<uint32_t>(local_ip);
|
||||
info.gw.addr = static_cast<uint32_t>(gateway);
|
||||
info.netmask.addr = static_cast<uint32_t>(subnet);
|
||||
wifi_softap_dhcps_stop();
|
||||
wifi_set_ip_info(SOFTAP_IF, &info);
|
||||
wifi_softap_dhcps_start();
|
||||
}
|
||||
|
||||
uint8_t* ESP8266WiFiClass::macAddress(uint8_t* mac)
|
||||
{
|
||||
wifi_get_macaddr(STATION_IF, mac);
|
||||
return mac;
|
||||
}
|
||||
|
||||
String ESP8266WiFiClass::macAddress(void)
|
||||
{
|
||||
uint8_t mac[6];
|
||||
char macStr[18] = {0};
|
||||
wifi_get_macaddr(STATION_IF, mac);
|
||||
|
||||
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
return String(macStr);
|
||||
}
|
||||
|
||||
uint8_t* ESP8266WiFiClass::softAPmacAddress(uint8_t* mac)
|
||||
{
|
||||
wifi_get_macaddr(SOFTAP_IF, mac);
|
||||
return mac;
|
||||
}
|
||||
|
||||
String ESP8266WiFiClass::softAPmacAddress(void)
|
||||
{
|
||||
uint8_t mac[6];
|
||||
char macStr[18] = {0};
|
||||
wifi_get_macaddr(SOFTAP_IF, mac);
|
||||
|
||||
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
return String(macStr);
|
||||
}
|
||||
|
||||
IPAddress ESP8266WiFiClass::localIP()
|
||||
{
|
||||
struct ip_info ip;
|
||||
wifi_get_ip_info(STATION_IF, &ip);
|
||||
return IPAddress(ip.ip.addr);
|
||||
}
|
||||
|
||||
IPAddress ESP8266WiFiClass::softAPIP()
|
||||
{
|
||||
struct ip_info ip;
|
||||
wifi_get_ip_info(SOFTAP_IF, &ip);
|
||||
return IPAddress(ip.ip.addr);
|
||||
}
|
||||
|
||||
IPAddress ESP8266WiFiClass::subnetMask()
|
||||
{
|
||||
struct ip_info ip;
|
||||
wifi_get_ip_info(STATION_IF, &ip);
|
||||
return IPAddress(ip.netmask.addr);
|
||||
}
|
||||
|
||||
IPAddress ESP8266WiFiClass::gatewayIP()
|
||||
{
|
||||
struct ip_info ip;
|
||||
wifi_get_ip_info(STATION_IF, &ip);
|
||||
return IPAddress(ip.gw.addr);
|
||||
}
|
||||
|
||||
IPAddress ESP8266WiFiClass::dnsIP(int dns_no)
|
||||
{
|
||||
ip_addr_t dns_ip = dns_getserver(dns_no);
|
||||
return IPAddress(dns_ip.addr);
|
||||
}
|
||||
|
||||
String ESP8266WiFiClass::SSID() const
|
||||
{
|
||||
static struct station_config conf;
|
||||
wifi_station_get_config(&conf);
|
||||
return String(reinterpret_cast<char*>(conf.ssid));
|
||||
}
|
||||
|
||||
String ESP8266WiFiClass::psk() const
|
||||
{
|
||||
static struct station_config conf;
|
||||
wifi_station_get_config(&conf);
|
||||
return String(reinterpret_cast<char*>(conf.password));
|
||||
}
|
||||
|
||||
uint8_t* ESP8266WiFiClass::BSSID(void)
|
||||
{
|
||||
static struct station_config conf;
|
||||
wifi_station_get_config(&conf);
|
||||
return reinterpret_cast<uint8_t*>(conf.bssid);
|
||||
}
|
||||
|
||||
String ESP8266WiFiClass::BSSIDstr(void)
|
||||
{
|
||||
static struct station_config conf;
|
||||
char mac[18] = {0};
|
||||
wifi_station_get_config(&conf);
|
||||
sprintf(mac,"%02X:%02X:%02X:%02X:%02X:%02X", conf.bssid[0], conf.bssid[1], conf.bssid[2], conf.bssid[3], conf.bssid[4], conf.bssid[5]);
|
||||
return String(mac);
|
||||
}
|
||||
|
||||
|
||||
int32_t ESP8266WiFiClass::channel(void) {
|
||||
return wifi_get_channel();
|
||||
}
|
||||
|
||||
|
||||
int32_t ESP8266WiFiClass::RSSI(void) {
|
||||
return wifi_station_get_rssi();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
typedef STAILQ_HEAD(, bss_info) bss_info_head_t;
|
||||
}
|
||||
|
||||
void ESP8266WiFiClass::_scanDone(void* result, int status)
|
||||
{
|
||||
if (status != OK)
|
||||
{
|
||||
ESP8266WiFiClass::_scanCount = 0;
|
||||
ESP8266WiFiClass::_scanResult = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
int i = 0;
|
||||
bss_info_head_t* head = reinterpret_cast<bss_info_head_t*>(result);
|
||||
|
||||
for (bss_info* it = STAILQ_FIRST(head); it; it = STAILQ_NEXT(it, next), ++i);
|
||||
ESP8266WiFiClass::_scanCount = i;
|
||||
if (i == 0)
|
||||
{
|
||||
ESP8266WiFiClass::_scanResult = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
bss_info* copied_info = new bss_info[i];
|
||||
i = 0;
|
||||
for (bss_info* it = STAILQ_FIRST(head); it; it = STAILQ_NEXT(it, next), ++i)
|
||||
{
|
||||
memcpy(copied_info + i, it, sizeof(bss_info));
|
||||
}
|
||||
|
||||
ESP8266WiFiClass::_scanResult = copied_info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ESP8266WiFiClass::_scanStarted = false;
|
||||
ESP8266WiFiClass::_scanComplete = true;
|
||||
|
||||
if(!ESP8266WiFiClass::_scanAsync) {
|
||||
esp_schedule();
|
||||
}
|
||||
}
|
||||
|
||||
int8_t ESP8266WiFiClass::scanComplete() {
|
||||
|
||||
if(_scanStarted) {
|
||||
return WIFI_SCAN_RUNNING;
|
||||
}
|
||||
|
||||
if(_scanComplete) {
|
||||
return ESP8266WiFiClass::_scanCount;
|
||||
}
|
||||
|
||||
return WIFI_SCAN_FAILED;
|
||||
}
|
||||
|
||||
void ESP8266WiFiClass::scanDelete()
|
||||
{
|
||||
if (ESP8266WiFiClass::_scanResult)
|
||||
{
|
||||
delete[] reinterpret_cast<bss_info*>(ESP8266WiFiClass::_scanResult);
|
||||
ESP8266WiFiClass::_scanResult = 0;
|
||||
ESP8266WiFiClass::_scanCount = 0;
|
||||
}
|
||||
_scanComplete = false;
|
||||
}
|
||||
|
||||
int8_t ESP8266WiFiClass::scanNetworks(bool async, bool show_hidden)
|
||||
{
|
||||
if(ESP8266WiFiClass::_scanStarted) {
|
||||
return WIFI_SCAN_RUNNING;
|
||||
}
|
||||
|
||||
ESP8266WiFiClass::_scanAsync = async;
|
||||
|
||||
if(_useApMode) {
|
||||
// turn on AP+STA mode
|
||||
_mode(WIFI_AP_STA);
|
||||
} else {
|
||||
// turn on STA mode
|
||||
_mode(WIFI_STA);
|
||||
}
|
||||
|
||||
int status = wifi_station_get_connect_status();
|
||||
if (status != STATION_GOT_IP && status != STATION_IDLE)
|
||||
{
|
||||
disconnect();
|
||||
}
|
||||
|
||||
scanDelete();
|
||||
|
||||
struct scan_config config;
|
||||
config.ssid = 0;
|
||||
config.bssid = 0;
|
||||
config.channel = 0;
|
||||
config.show_hidden = show_hidden;
|
||||
if(wifi_station_scan(&config, reinterpret_cast<scan_done_cb_t>(&ESP8266WiFiClass::_scanDone))) {
|
||||
ESP8266WiFiClass::_scanComplete = false;
|
||||
ESP8266WiFiClass::_scanStarted = true;
|
||||
|
||||
if(ESP8266WiFiClass::_scanAsync) {
|
||||
delay(0); // time for the OS to trigger the scan
|
||||
return WIFI_SCAN_RUNNING;
|
||||
}
|
||||
|
||||
esp_yield();
|
||||
return ESP8266WiFiClass::_scanCount;
|
||||
} else {
|
||||
return WIFI_SCAN_FAILED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void * ESP8266WiFiClass::_getScanInfoByIndex(int i)
|
||||
{
|
||||
if (!ESP8266WiFiClass::_scanResult || (size_t)i > ESP8266WiFiClass::_scanCount)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return reinterpret_cast<bss_info*>(ESP8266WiFiClass::_scanResult) + i;
|
||||
}
|
||||
|
||||
String ESP8266WiFiClass::SSID(uint8_t i)
|
||||
{
|
||||
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
|
||||
if (!it)
|
||||
return "";
|
||||
|
||||
return String(reinterpret_cast<const char*>(it->ssid));
|
||||
}
|
||||
|
||||
uint8_t * ESP8266WiFiClass::BSSID(uint8_t i)
|
||||
{
|
||||
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
|
||||
if (!it)
|
||||
return 0;
|
||||
|
||||
return it->bssid;
|
||||
}
|
||||
|
||||
String ESP8266WiFiClass::BSSIDstr(uint8_t i)
|
||||
{
|
||||
char mac[18] = {0};
|
||||
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
|
||||
if (!it)
|
||||
return String("");
|
||||
|
||||
sprintf(mac,"%02X:%02X:%02X:%02X:%02X:%02X", it->bssid[0], it->bssid[1], it->bssid[2], it->bssid[3], it->bssid[4], it->bssid[5]);
|
||||
return String(mac);
|
||||
}
|
||||
|
||||
int32_t ESP8266WiFiClass::channel(uint8_t i)
|
||||
{
|
||||
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
|
||||
if (!it)
|
||||
return 0;
|
||||
|
||||
return it->channel;
|
||||
}
|
||||
|
||||
bool ESP8266WiFiClass::isHidden(uint8_t i)
|
||||
{
|
||||
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
|
||||
if (!it)
|
||||
return false;
|
||||
|
||||
return (it->is_hidden != 0);
|
||||
}
|
||||
|
||||
bool ESP8266WiFiClass::getNetworkInfo(uint8_t i, String &ssid, uint8_t &encType, int32_t &rssi, uint8_t* &bssid, int32_t &channel, bool &isHidden)
|
||||
{
|
||||
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
|
||||
if (!it)
|
||||
return false;
|
||||
|
||||
ssid = (const char*)it->ssid;
|
||||
encType = encryptionType(i);
|
||||
rssi = it->rssi;
|
||||
bssid = it->bssid; // move ptr
|
||||
channel = it->channel;
|
||||
isHidden = (it->is_hidden != 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t ESP8266WiFiClass::RSSI(uint8_t i)
|
||||
{
|
||||
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
|
||||
if (!it)
|
||||
return 0;
|
||||
|
||||
return it->rssi;
|
||||
}
|
||||
|
||||
uint8_t ESP8266WiFiClass::encryptionType(uint8_t i)
|
||||
{
|
||||
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
|
||||
if (!it)
|
||||
return -1;
|
||||
|
||||
int authmode = it->authmode;
|
||||
if (authmode == AUTH_OPEN)
|
||||
return ENC_TYPE_NONE;
|
||||
if (authmode == AUTH_WEP)
|
||||
return ENC_TYPE_WEP;
|
||||
if (authmode == AUTH_WPA_PSK)
|
||||
return ENC_TYPE_TKIP;
|
||||
if (authmode == AUTH_WPA2_PSK)
|
||||
return ENC_TYPE_CCMP;
|
||||
if (authmode == AUTH_WPA_WPA2_PSK)
|
||||
return ENC_TYPE_AUTO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
wl_status_t ESP8266WiFiClass::status()
|
||||
{
|
||||
int status = wifi_station_get_connect_status();
|
||||
|
||||
if (status == STATION_GOT_IP)
|
||||
return WL_CONNECTED;
|
||||
else if (status == STATION_NO_AP_FOUND)
|
||||
return WL_NO_SSID_AVAIL;
|
||||
else if (status == STATION_CONNECT_FAIL || status == STATION_WRONG_PASSWORD)
|
||||
return WL_CONNECT_FAILED;
|
||||
else if (status == STATION_IDLE)
|
||||
return WL_IDLE_STATUS;
|
||||
else
|
||||
return WL_DISCONNECTED;
|
||||
}
|
||||
|
||||
void wifi_dns_found_callback(const char *name, ip_addr_t *ipaddr, void *callback_arg)
|
||||
{
|
||||
if (ipaddr)
|
||||
(*reinterpret_cast<IPAddress*>(callback_arg)) = ipaddr->addr;
|
||||
esp_schedule(); // resume the hostByName function
|
||||
}
|
||||
|
||||
int ESP8266WiFiClass::hostByName(const char* aHostname, IPAddress& aResult)
|
||||
{
|
||||
ip_addr_t addr;
|
||||
aResult = static_cast<uint32_t>(0);
|
||||
err_t err = dns_gethostbyname(aHostname, &addr, &wifi_dns_found_callback, &aResult);
|
||||
if (err == ERR_OK)
|
||||
{
|
||||
aResult = addr.addr;
|
||||
}
|
||||
else if (err == ERR_INPROGRESS)
|
||||
{
|
||||
esp_yield();
|
||||
// will return here when dns_found_callback fires
|
||||
}
|
||||
|
||||
return (aResult != 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
String ESP8266WiFiClass::hostname(void) {
|
||||
return String(wifi_station_get_hostname());
|
||||
}
|
||||
|
||||
bool ESP8266WiFiClass::hostname(char* aHostname) {
|
||||
if(strlen(aHostname) > 32) {
|
||||
return false;
|
||||
}
|
||||
return wifi_station_set_hostname(aHostname);
|
||||
}
|
||||
|
||||
bool ESP8266WiFiClass::hostname(const char* aHostname) {
|
||||
return hostname((char*) aHostname);
|
||||
}
|
||||
|
||||
bool ESP8266WiFiClass::hostname(String aHostname) {
|
||||
return hostname((char*) aHostname.c_str());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void wifi_wps_status_cb(wps_cb_status status)
|
||||
{
|
||||
DEBUGV("wps cb status: %d\r\n", status);
|
||||
switch (status) {
|
||||
case WPS_CB_ST_SUCCESS:
|
||||
if(!wifi_wps_disable()) {
|
||||
DEBUGV("wps disable failed\n");
|
||||
}
|
||||
wifi_station_connect();
|
||||
break;
|
||||
case WPS_CB_ST_FAILED:
|
||||
DEBUGV("wps FAILED\n");
|
||||
break;
|
||||
case WPS_CB_ST_TIMEOUT:
|
||||
DEBUGV("wps TIMEOUT\n");
|
||||
break;
|
||||
case WPS_CB_ST_WEP:
|
||||
DEBUGV("wps WEP\n");
|
||||
break;
|
||||
}
|
||||
// todo user function to get status
|
||||
|
||||
esp_schedule(); // resume the beginWPSConfig function
|
||||
}
|
||||
|
||||
bool ESP8266WiFiClass::beginWPSConfig(void) {
|
||||
|
||||
_useClientMode = true;
|
||||
|
||||
if(_useApMode) {
|
||||
// turn on AP+STA mode
|
||||
_mode(WIFI_AP_STA);
|
||||
} else {
|
||||
// turn on STA mode
|
||||
_mode(WIFI_STA);
|
||||
}
|
||||
|
||||
disconnect();
|
||||
|
||||
DEBUGV("wps begin\n");
|
||||
|
||||
if(!wifi_wps_disable()) {
|
||||
DEBUGV("wps disable failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// so far only WPS_TYPE_PBC is supported (SDK 1.2.0)
|
||||
if(!wifi_wps_enable(WPS_TYPE_PBC)) {
|
||||
DEBUGV("wps enable failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!wifi_set_wps_cb((wps_st_cb_t) &wifi_wps_status_cb)) {
|
||||
DEBUGV("wps cb failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!wifi_wps_start()) {
|
||||
DEBUGV("wps start failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
esp_yield();
|
||||
// will return here when wifi_wps_status_cb fires
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
void ESP8266WiFiClass::beginSmartConfig()
|
||||
{
|
||||
if (_smartConfigStarted)
|
||||
return;
|
||||
|
||||
if(_useApMode) {
|
||||
// turn on AP+STA mode
|
||||
_mode(WIFI_AP_STA);
|
||||
} else {
|
||||
// turn on STA mode
|
||||
_mode(WIFI_STA);
|
||||
}
|
||||
|
||||
_smartConfigStarted = true;
|
||||
_smartConfigDone = false;
|
||||
|
||||
//SC_TYPE_ESPTOUCH use ESPTOUCH for smartconfig, or use SC_TYPE_AIRKISS for AIRKISS
|
||||
smartconfig_start(reinterpret_cast<sc_callback_t>(&ESP8266WiFiClass::_smartConfigCallback), 1);
|
||||
}
|
||||
|
||||
void ESP8266WiFiClass::stopSmartConfig()
|
||||
{
|
||||
if (!_smartConfigStarted)
|
||||
return;
|
||||
|
||||
smartconfig_stop();
|
||||
_smartConfigStarted = false;
|
||||
}
|
||||
|
||||
bool ESP8266WiFiClass::smartConfigDone()
|
||||
{
|
||||
if (!_smartConfigStarted)
|
||||
return false;
|
||||
|
||||
return _smartConfigDone;
|
||||
}
|
||||
|
||||
void ESP8266WiFiClass::_smartConfigCallback(uint32_t st, void* result)
|
||||
{
|
||||
sc_status status = (sc_status) st;
|
||||
if (status == SC_STATUS_LINK) {
|
||||
station_config* sta_conf = reinterpret_cast<station_config*>(result);
|
||||
|
||||
wifi_station_set_config(sta_conf);
|
||||
wifi_station_disconnect();
|
||||
wifi_station_connect();
|
||||
|
||||
WiFi._smartConfigDone = true;
|
||||
}
|
||||
else if (status == SC_STATUS_LINK_OVER) {
|
||||
WiFi.stopSmartConfig();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void ESP8266WiFiClass::_eventCallback(void* arg)
|
||||
{
|
||||
System_Event_t* event = reinterpret_cast<System_Event_t*>(arg);
|
||||
DEBUGV("wifi evt: %d\r\n", event->event);
|
||||
|
||||
if (event->event == EVENT_STAMODE_DISCONNECTED) {
|
||||
WiFiClient::stopAll();
|
||||
}
|
||||
}
|
||||
|
||||
void ESP8266WiFiClass::printDiag(Print& p)
|
||||
{
|
||||
const char* modes[] = {"NULL", "STA", "AP", "STA+AP"};
|
||||
p.print("Mode: ");
|
||||
p.println(modes[wifi_get_opmode()]);
|
||||
|
||||
const char* phymodes[] = {"", "B", "G", "N"};
|
||||
p.print("PHY mode: ");
|
||||
p.println(phymodes[(int) wifi_get_phy_mode()]);
|
||||
|
||||
p.print("Channel: ");
|
||||
p.println(wifi_get_channel());
|
||||
|
||||
p.print("AP id: ");
|
||||
p.println(wifi_station_get_current_ap_id());
|
||||
|
||||
p.print("Status: ");
|
||||
p.println(wifi_station_get_connect_status());
|
||||
|
||||
p.print("Auto connect: ");
|
||||
p.println(wifi_station_get_auto_connect());
|
||||
|
||||
static struct station_config conf;
|
||||
wifi_station_get_config(&conf);
|
||||
|
||||
const char* ssid = reinterpret_cast<const char*>(conf.ssid);
|
||||
p.print("SSID (");
|
||||
p.print(strlen(ssid));
|
||||
p.print("): ");
|
||||
p.println(ssid);
|
||||
|
||||
const char* passphrase = reinterpret_cast<const char*>(conf.password);
|
||||
p.print("Passphrase (");
|
||||
p.print(strlen(passphrase));
|
||||
p.print("): ");
|
||||
p.println(passphrase);
|
||||
|
||||
p.print("BSSID set: ");
|
||||
p.println(conf.bssid_set);
|
||||
|
||||
}
|
||||
|
||||
bool ESP8266WiFiClass::_scanAsync = false;
|
||||
bool ESP8266WiFiClass::_scanStarted = false;
|
||||
bool ESP8266WiFiClass::_scanComplete = false;
|
||||
|
||||
size_t ESP8266WiFiClass::_scanCount = 0;
|
||||
void* ESP8266WiFiClass::_scanResult = 0;
|
||||
|
||||
|
||||
ESP8266WiFiClass WiFi;
|
||||
403
sdk_fix/ESP8266WiFi.h
Normal file
403
sdk_fix/ESP8266WiFi.h
Normal file
@@ -0,0 +1,403 @@
|
||||
/*
|
||||
ESP8266WiFi.h - esp8266 Wifi support.
|
||||
Based on WiFi.h from Ardiono WiFi shield library.
|
||||
Copyright (c) 2011-2014 Arduino. All right reserved.
|
||||
Modified by Ivan Grokhotkov, December 2014
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef WiFi_h
|
||||
#define WiFi_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C" {
|
||||
#include "include/wl_definitions.h"
|
||||
}
|
||||
|
||||
#include "IPAddress.h"
|
||||
#include "WiFiClient.h"
|
||||
#include "WiFiServer.h"
|
||||
#include "WiFiClientSecure.h"
|
||||
|
||||
#define WIFI_SCAN_RUNNING (-1)
|
||||
#define WIFI_SCAN_FAILED (-2)
|
||||
|
||||
enum WiFiMode { WIFI_OFF = 0, WIFI_STA = 1, WIFI_AP = 2, WIFI_AP_STA = 3 };
|
||||
|
||||
class ESP8266WiFiClass
|
||||
{
|
||||
public:
|
||||
|
||||
ESP8266WiFiClass();
|
||||
|
||||
void persistent(bool persistent);
|
||||
|
||||
void mode(WiFiMode);
|
||||
WiFiMode getMode();
|
||||
|
||||
/**
|
||||
* Start Wifi connection
|
||||
* if passphrase is set the most secure supported mode will be automatically selected
|
||||
* @param ssid const char* Pointer to the SSID string.
|
||||
* @param passphrase const char * Optional. Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal).
|
||||
* @param bssid uint8_t[6] Optional. BSSID / MAC of AP
|
||||
* @param channel Optional. Channel of AP
|
||||
* @return
|
||||
*/
|
||||
int begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL);
|
||||
int begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL);
|
||||
|
||||
// Use sdk config to connect.
|
||||
int begin();
|
||||
|
||||
|
||||
/* Wait for Wifi connection to reach a result
|
||||
* returns the status reached or disconnect if STA is off
|
||||
*/
|
||||
uint8_t waitForConnectResult();
|
||||
|
||||
/* Set up an open access point
|
||||
*
|
||||
* param ssid: Pointer to the SSID string.
|
||||
*/
|
||||
void softAP(const char* ssid);
|
||||
|
||||
|
||||
/* Set up a WPA2-secured access point
|
||||
*
|
||||
* param ssid: Pointer to the SSID string.
|
||||
* param passphrase: Pointer to passphrase, 8 characters min.
|
||||
* param channel: WiFi channel number, 1 - 13.
|
||||
* param ssid_hidden: Network cloaking? 0 = broadcast SSID, 1 = hide SSID
|
||||
*/
|
||||
void softAP(const char* ssid, const char* passphrase, int channel = 1, int ssid_hidden = 0);
|
||||
|
||||
/* Change Ip configuration settings disabling the dhcp client
|
||||
*
|
||||
* param local_ip: Static ip configuration
|
||||
* param gateway: Static gateway configuration
|
||||
* param subnet: Static Subnet mask
|
||||
*/
|
||||
void config(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
|
||||
|
||||
/* Change Ip configuration settings disabling the dhcp client
|
||||
*
|
||||
* param local_ip: Static ip configuration
|
||||
* param gateway: Static gateway configuration
|
||||
* param subnet: Static Subnet mask
|
||||
* param dns: Defined DNS
|
||||
*/
|
||||
void config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns);
|
||||
|
||||
/* Configure access point
|
||||
*
|
||||
* param local_ip: access point IP
|
||||
* param gateway: gateway IP
|
||||
* param subnet: subnet mask
|
||||
*/
|
||||
void softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
|
||||
|
||||
/*
|
||||
* Disconnect from the network (close AP)
|
||||
*
|
||||
* return: one value of wl_status_t enum
|
||||
*/
|
||||
int softAPdisconnect(bool wifioff = false);
|
||||
|
||||
/*
|
||||
* Disconnect from the network
|
||||
*
|
||||
* return: one value of wl_status_t enum
|
||||
*/
|
||||
int disconnect(bool wifioff = false);
|
||||
|
||||
/*
|
||||
* Get the station interface MAC address.
|
||||
*
|
||||
* return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
|
||||
* return: String
|
||||
*/
|
||||
uint8_t* macAddress(uint8_t* mac);
|
||||
String macAddress(void);
|
||||
|
||||
/*
|
||||
* Get the softAP interface MAC address.
|
||||
*
|
||||
* return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
|
||||
* return: String
|
||||
*/
|
||||
uint8_t* softAPmacAddress(uint8_t* mac);
|
||||
String softAPmacAddress(void);
|
||||
|
||||
/*
|
||||
* Get the station interface IP address.
|
||||
*
|
||||
* return: Ip address value
|
||||
*/
|
||||
IPAddress localIP();
|
||||
|
||||
/*
|
||||
* Get the softAP interface IP address.
|
||||
*
|
||||
* return: Ip address value
|
||||
*/
|
||||
IPAddress softAPIP();
|
||||
|
||||
/*
|
||||
* Get the interface subnet mask address.
|
||||
*
|
||||
* return: subnet mask address value
|
||||
*/
|
||||
IPAddress subnetMask();
|
||||
|
||||
/*
|
||||
* Get the gateway ip address.
|
||||
*
|
||||
* return: gateway ip address value
|
||||
*/
|
||||
IPAddress gatewayIP();
|
||||
|
||||
/*
|
||||
* Get the DNS ip address.
|
||||
*
|
||||
* return: DNS ip address value
|
||||
*/
|
||||
IPAddress dnsIP(int dns_no = 0);
|
||||
|
||||
/*
|
||||
* Return the current SSID associated with the network
|
||||
*
|
||||
* return: ssid string
|
||||
*/
|
||||
String SSID() const;
|
||||
|
||||
/*
|
||||
* Return the current pre shared key associated with the network
|
||||
*
|
||||
* return: psk string
|
||||
*/
|
||||
String psk() const;
|
||||
|
||||
/*
|
||||
* Return the current bssid / mac associated with the network if configured
|
||||
*
|
||||
* return: bssid uint8_t *
|
||||
*/
|
||||
uint8_t *BSSID(void);
|
||||
|
||||
/*
|
||||
* Return the current bssid / mac associated with the network if configured
|
||||
*
|
||||
* return: bssid string
|
||||
*/
|
||||
String BSSIDstr(void);
|
||||
|
||||
/*
|
||||
* Return the current channel associated with the network
|
||||
*
|
||||
* return: channel
|
||||
*/
|
||||
int32_t channel(void);
|
||||
|
||||
/*
|
||||
* Return the current network RSSI.
|
||||
*
|
||||
* return: RSSI value
|
||||
*/
|
||||
|
||||
int32_t RSSI();
|
||||
|
||||
|
||||
/*
|
||||
* called to get the scan state in Async mode
|
||||
*
|
||||
* return -1 if scan not fin
|
||||
* return -2 if scan not triggered
|
||||
*/
|
||||
int8_t scanComplete();
|
||||
|
||||
/*
|
||||
* delete last scan result from RAM
|
||||
*/
|
||||
void scanDelete();
|
||||
|
||||
/*
|
||||
* Start scan WiFi networks available
|
||||
*
|
||||
* return: Number of discovered networks
|
||||
*/
|
||||
int8_t scanNetworks(bool async = false, bool show_hidden = false);
|
||||
|
||||
/*
|
||||
* Return the SSID discovered during the network scan.
|
||||
*
|
||||
* param networkItem: specify from which network item want to get the information
|
||||
*
|
||||
* return: ssid string of the specified item on the networks scanned list
|
||||
*/
|
||||
String SSID(uint8_t networkItem);
|
||||
|
||||
/*
|
||||
* Return the encryption type of the networks discovered during the scanNetworks
|
||||
*
|
||||
* param networkItem: specify from which network item want to get the information
|
||||
*
|
||||
* return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
|
||||
*/
|
||||
uint8_t encryptionType(uint8_t networkItem);
|
||||
|
||||
/*
|
||||
* Return the RSSI of the networks discovered during the scanNetworks
|
||||
*
|
||||
* param networkItem: specify from which network item want to get the information
|
||||
*
|
||||
* return: signed value of RSSI of the specified item on the networks scanned list
|
||||
*/
|
||||
int32_t RSSI(uint8_t networkItem);
|
||||
|
||||
|
||||
/**
|
||||
* return MAC / BSSID of scanned wifi
|
||||
* @param networkItem specify from which network item want to get the information
|
||||
* @return uint8_t * MAC / BSSID of scanned wifi
|
||||
*/
|
||||
uint8_t * BSSID(uint8_t networkItem);
|
||||
|
||||
/**
|
||||
* return MAC / BSSID of scanned wifi
|
||||
* @param networkItem specify from which network item want to get the information
|
||||
* @return String MAC / BSSID of scanned wifi
|
||||
*/
|
||||
String BSSIDstr(uint8_t networkItem);
|
||||
|
||||
/**
|
||||
* return channel of scanned wifi
|
||||
* @param networkItem specify from which network item want to get the information
|
||||
* @return uint32_t channel of scanned wifi
|
||||
*/
|
||||
int32_t channel(uint8_t networkItem);
|
||||
|
||||
/**
|
||||
* return if the scanned wifi is Hidden (no SSID)
|
||||
* @param networkItem specify from which network item want to get the information
|
||||
* @return bool (true == hidden)
|
||||
*/
|
||||
bool isHidden(uint8_t networkItem);
|
||||
|
||||
/**
|
||||
* loads all infos from a scanned wifi in to the ptr parameters
|
||||
* @param networkItem uint8_t
|
||||
* @param ssid const char**
|
||||
* @param encryptionType uint8_t *
|
||||
* @param RSSI int32_t *
|
||||
* @param BSSID uint8_t **
|
||||
* @param channel int32_t *
|
||||
* @param isHidden bool *
|
||||
* @return (true if ok)
|
||||
*/
|
||||
bool getNetworkInfo(uint8_t networkItem, String &ssid, uint8_t &encryptionType, int32_t &RSSI, uint8_t* &BSSID, int32_t &channel, bool &isHidden);
|
||||
|
||||
|
||||
/*
|
||||
* Return Connection status.
|
||||
*
|
||||
* return: one of the value defined in wl_status_t
|
||||
*/
|
||||
wl_status_t status();
|
||||
|
||||
/*
|
||||
* Resolve the given hostname to an IP address.
|
||||
* param aHostname: Name to be resolved
|
||||
* param aResult: IPAddress structure to store the returned IP address
|
||||
* result: 1 if aIPAddrString was successfully converted to an IP address,
|
||||
* else error code
|
||||
*/
|
||||
int hostByName(const char* aHostname, IPAddress& aResult);
|
||||
|
||||
/*
|
||||
* Get ESP8266 station DHCP hostname
|
||||
*/
|
||||
String hostname(void);
|
||||
|
||||
/*
|
||||
* Set ESP8266 station DHCP hostname
|
||||
* hostname, max length:32
|
||||
*/
|
||||
bool hostname(char* aHostname);
|
||||
bool hostname(const char* aHostname);
|
||||
bool hostname(String aHostname);
|
||||
|
||||
|
||||
/**
|
||||
* WPS config
|
||||
* so far only WPS_TYPE_PBC is supported (SDK 1.2.0)
|
||||
*/
|
||||
bool beginWPSConfig(void);
|
||||
|
||||
/*
|
||||
* Output WiFi settings to an object derived from Print interface (like Serial).
|
||||
*
|
||||
*/
|
||||
void printDiag(Print& dest);
|
||||
|
||||
/*
|
||||
* Start SmartConfig
|
||||
*
|
||||
*/
|
||||
void beginSmartConfig();
|
||||
|
||||
/*
|
||||
* Query SmartConfig status, to decide when stop config
|
||||
*
|
||||
*/
|
||||
bool smartConfigDone();
|
||||
|
||||
/*
|
||||
* Stop SmartConfig
|
||||
*
|
||||
*/
|
||||
void stopSmartConfig();
|
||||
|
||||
friend class WiFiClient;
|
||||
friend class WiFiServer;
|
||||
|
||||
protected:
|
||||
void _mode(WiFiMode);
|
||||
static void _scanDone(void* result, int status);
|
||||
void * _getScanInfoByIndex(int i);
|
||||
static void _smartConfigCallback(uint32_t status, void* result);
|
||||
static void _eventCallback(void *event);
|
||||
bool _smartConfigStarted;
|
||||
bool _smartConfigDone;
|
||||
|
||||
bool _useApMode;
|
||||
bool _useClientMode;
|
||||
bool _useStaticIp;
|
||||
bool _persistent;
|
||||
|
||||
static bool _scanAsync;
|
||||
static bool _scanStarted;
|
||||
static bool _scanComplete;
|
||||
|
||||
static size_t _scanCount;
|
||||
static void* _scanResult;
|
||||
|
||||
};
|
||||
|
||||
extern ESP8266WiFiClass WiFi;
|
||||
|
||||
#endif
|
||||
4
sdk_fix/README.txt
Normal file
4
sdk_fix/README.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
Copy these files and past them at the location.
|
||||
|
||||
user_interface ---> \packages\esp8266\hardware\esp8266\2.0.0\tools\sdk\include
|
||||
ESP8266WiFi.cpp and ESP8266WiFi.h ---> \packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WiFi\src
|
||||
455
sdk_fix/user_interface.h
Normal file
455
sdk_fix/user_interface.h
Normal file
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
* Copyright (C) 2013 -2014 Espressif System
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __USER_INTERFACE_H__
|
||||
#define __USER_INTERFACE_H__
|
||||
|
||||
#include "os_type.h"
|
||||
#ifdef LWIP_OPEN_SRC
|
||||
#include "lwip/ip_addr.h"
|
||||
#else
|
||||
#include "ip_addr.h"
|
||||
#endif
|
||||
|
||||
#include "queue.h"
|
||||
#include "user_config.h"
|
||||
#include "spi_flash.h"
|
||||
|
||||
#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
|
||||
|
||||
enum rst_reason {
|
||||
REASON_DEFAULT_RST = 0,
|
||||
REASON_WDT_RST = 1,
|
||||
REASON_EXCEPTION_RST = 2,
|
||||
REASON_SOFT_WDT_RST = 3,
|
||||
REASON_SOFT_RESTART = 4,
|
||||
REASON_DEEP_SLEEP_AWAKE = 5,
|
||||
REASON_EXT_SYS_RST = 6
|
||||
};
|
||||
|
||||
struct rst_info{
|
||||
uint32 reason;
|
||||
uint32 exccause;
|
||||
uint32 epc1;
|
||||
uint32 epc2;
|
||||
uint32 epc3;
|
||||
uint32 excvaddr;
|
||||
uint32 depc;
|
||||
};
|
||||
|
||||
struct rst_info* system_get_rst_info(void);
|
||||
|
||||
#define UPGRADE_FW_BIN1 0x00
|
||||
#define UPGRADE_FW_BIN2 0x01
|
||||
|
||||
void system_restore(void);
|
||||
void system_restart(void);
|
||||
|
||||
bool system_deep_sleep_set_option(uint8 option);
|
||||
void system_deep_sleep(uint32 time_in_us);
|
||||
|
||||
uint8 system_upgrade_userbin_check(void);
|
||||
void system_upgrade_reboot(void);
|
||||
uint8 system_upgrade_flag_check();
|
||||
void system_upgrade_flag_set(uint8 flag);
|
||||
|
||||
void system_timer_reinit(void);
|
||||
uint32 system_get_time(void);
|
||||
|
||||
/* user task's prio must be 0/1/2 !!!*/
|
||||
enum {
|
||||
USER_TASK_PRIO_0 = 0,
|
||||
USER_TASK_PRIO_1,
|
||||
USER_TASK_PRIO_2,
|
||||
USER_TASK_PRIO_MAX
|
||||
};
|
||||
|
||||
bool system_os_task(os_task_t task, uint8 prio, os_event_t *queue, uint8 qlen);
|
||||
bool system_os_post(uint8 prio, os_signal_t sig, os_param_t par);
|
||||
|
||||
void system_print_meminfo(void);
|
||||
uint32 system_get_free_heap_size(void);
|
||||
|
||||
void system_set_os_print(uint8 onoff);
|
||||
uint8 system_get_os_print();
|
||||
|
||||
uint64 system_mktime(uint32 year, uint32 mon, uint32 day, uint32 hour, uint32 min, uint32 sec);
|
||||
|
||||
uint32 system_get_chip_id(void);
|
||||
|
||||
typedef void (* init_done_cb_t)(void);
|
||||
|
||||
void system_init_done_cb(init_done_cb_t cb);
|
||||
|
||||
uint32 system_rtc_clock_cali_proc(void);
|
||||
uint32 system_get_rtc_time(void);
|
||||
|
||||
bool system_rtc_mem_read(uint8 src_addr, void *des_addr, uint16 load_size);
|
||||
bool system_rtc_mem_write(uint8 des_addr, const void *src_addr, uint16 save_size);
|
||||
|
||||
void system_uart_swap(void);
|
||||
void system_uart_de_swap(void);
|
||||
|
||||
uint16 system_adc_read(void);
|
||||
uint16 system_get_vdd33(void);
|
||||
|
||||
const char *system_get_sdk_version(void);
|
||||
|
||||
#define SYS_BOOT_ENHANCE_MODE 0
|
||||
#define SYS_BOOT_NORMAL_MODE 1
|
||||
|
||||
#define SYS_BOOT_NORMAL_BIN 0
|
||||
#define SYS_BOOT_TEST_BIN 1
|
||||
|
||||
uint8 system_get_boot_version(void);
|
||||
uint32 system_get_userbin_addr(void);
|
||||
uint8 system_get_boot_mode(void);
|
||||
bool system_restart_enhance(uint8 bin_type, uint32 bin_addr);
|
||||
|
||||
#define SYS_CPU_80MHZ 80
|
||||
#define SYS_CPU_160MHZ 160
|
||||
|
||||
bool system_update_cpu_freq(uint8 freq);
|
||||
uint8 system_get_cpu_freq(void);
|
||||
|
||||
enum flash_size_map {
|
||||
FLASH_SIZE_4M_MAP_256_256 = 0,
|
||||
FLASH_SIZE_2M,
|
||||
FLASH_SIZE_8M_MAP_512_512,
|
||||
FLASH_SIZE_16M_MAP_512_512,
|
||||
FLASH_SIZE_32M_MAP_512_512,
|
||||
FLASH_SIZE_16M_MAP_1024_1024,
|
||||
FLASH_SIZE_32M_MAP_1024_1024
|
||||
};
|
||||
|
||||
enum flash_size_map system_get_flash_size_map(void);
|
||||
|
||||
void system_phy_set_max_tpw(uint8 max_tpw);
|
||||
void system_phy_set_tpw_via_vdd33(uint16 vdd33);
|
||||
void system_phy_set_rfoption(uint8 option);
|
||||
|
||||
bool system_param_save_with_protect(uint16 start_sec, void *param, uint16 len);
|
||||
bool system_param_load(uint16 start_sec, uint16 offset, void *param, uint16 len);
|
||||
|
||||
void system_soft_wdt_stop(void);
|
||||
void system_soft_wdt_restart(void);
|
||||
void system_soft_wdt_feed(void);
|
||||
|
||||
#define NULL_MODE 0x00
|
||||
#define STATION_MODE 0x01
|
||||
#define SOFTAP_MODE 0x02
|
||||
#define STATIONAP_MODE 0x03
|
||||
|
||||
typedef enum _auth_mode {
|
||||
AUTH_OPEN = 0,
|
||||
AUTH_WEP,
|
||||
AUTH_WPA_PSK,
|
||||
AUTH_WPA2_PSK,
|
||||
AUTH_WPA_WPA2_PSK,
|
||||
AUTH_MAX
|
||||
} AUTH_MODE;
|
||||
|
||||
uint8 wifi_get_opmode(void);
|
||||
uint8 wifi_get_opmode_default(void);
|
||||
bool wifi_set_opmode(uint8 opmode);
|
||||
bool wifi_set_opmode_current(uint8 opmode);
|
||||
uint8 wifi_get_broadcast_if(void);
|
||||
bool wifi_set_broadcast_if(uint8 interface);
|
||||
|
||||
struct bss_info {
|
||||
STAILQ_ENTRY(bss_info) next;
|
||||
|
||||
uint8 bssid[6];
|
||||
uint8 ssid[32];
|
||||
uint8 channel;
|
||||
sint8 rssi;
|
||||
AUTH_MODE authmode;
|
||||
uint8 is_hidden;
|
||||
sint16 freq_offset;
|
||||
};
|
||||
|
||||
typedef struct _scaninfo {
|
||||
STAILQ_HEAD(, bss_info) *pbss;
|
||||
struct espconn *pespconn;
|
||||
uint8 totalpage;
|
||||
uint8 pagenum;
|
||||
uint8 page_sn;
|
||||
uint8 data_cnt;
|
||||
} scaninfo;
|
||||
|
||||
typedef void (* scan_done_cb_t)(void *arg, STATUS status);
|
||||
|
||||
struct station_config {
|
||||
uint8 ssid[32];
|
||||
uint8 password[64];
|
||||
uint8 bssid_set; // Note: If bssid_set is 1, station will just connect to the router
|
||||
// with both ssid[] and bssid[] matched. Please check about this.
|
||||
uint8 bssid[6];
|
||||
};
|
||||
|
||||
bool wifi_station_get_config(struct station_config *config);
|
||||
bool wifi_station_get_config_default(struct station_config *config);
|
||||
bool wifi_station_set_config(struct station_config *config);
|
||||
bool wifi_station_set_config_current(struct station_config *config);
|
||||
|
||||
bool wifi_station_connect(void);
|
||||
bool wifi_station_disconnect(void);
|
||||
|
||||
sint8 wifi_station_get_rssi(void);
|
||||
|
||||
struct scan_config {
|
||||
uint8 *ssid; // Note: ssid == NULL, don't filter ssid.
|
||||
uint8 *bssid; // Note: bssid == NULL, don't filter bssid.
|
||||
uint8 channel; // Note: channel == 0, scan all channels, otherwise scan set channel.
|
||||
uint8 show_hidden; // Note: show_hidden == 1, can get hidden ssid routers' info.
|
||||
};
|
||||
|
||||
bool wifi_station_scan(struct scan_config *config, scan_done_cb_t cb);
|
||||
|
||||
uint8 wifi_station_get_auto_connect(void);
|
||||
bool wifi_station_set_auto_connect(uint8 set);
|
||||
|
||||
bool wifi_station_set_reconnect_policy(bool set);
|
||||
|
||||
enum {
|
||||
STATION_IDLE = 0,
|
||||
STATION_CONNECTING,
|
||||
STATION_WRONG_PASSWORD,
|
||||
STATION_NO_AP_FOUND,
|
||||
STATION_CONNECT_FAIL,
|
||||
STATION_GOT_IP
|
||||
};
|
||||
|
||||
enum dhcp_status {
|
||||
DHCP_STOPPED,
|
||||
DHCP_STARTED
|
||||
};
|
||||
|
||||
uint8 wifi_station_get_connect_status(void);
|
||||
|
||||
uint8 wifi_station_get_current_ap_id(void);
|
||||
bool wifi_station_ap_change(uint8 current_ap_id);
|
||||
bool wifi_station_ap_number_set(uint8 ap_number);
|
||||
uint8 wifi_station_get_ap_info(struct station_config config[]);
|
||||
|
||||
bool wifi_station_dhcpc_start(void);
|
||||
bool wifi_station_dhcpc_stop(void);
|
||||
enum dhcp_status wifi_station_dhcpc_status(void);
|
||||
|
||||
char* wifi_station_get_hostname(void);
|
||||
bool wifi_station_set_hostname(char *name);
|
||||
|
||||
struct softap_config {
|
||||
uint8 ssid[32];
|
||||
uint8 password[64];
|
||||
uint8 ssid_len; // Note: Recommend to set it according to your ssid
|
||||
uint8 channel; // Note: support 1 ~ 13
|
||||
AUTH_MODE authmode; // Note: Don't support AUTH_WEP in softAP mode.
|
||||
uint8 ssid_hidden; // Note: default 0
|
||||
uint8 max_connection; // Note: default 4, max 4
|
||||
uint16 beacon_interval; // Note: support 100 ~ 60000 ms, default 100
|
||||
};
|
||||
|
||||
bool wifi_softap_get_config(struct softap_config *config);
|
||||
bool wifi_softap_get_config_default(struct softap_config *config);
|
||||
bool wifi_softap_set_config(struct softap_config *config);
|
||||
bool wifi_softap_set_config_current(struct softap_config *config);
|
||||
|
||||
struct station_info {
|
||||
STAILQ_ENTRY(station_info) next;
|
||||
|
||||
uint8 bssid[6];
|
||||
struct ip_addr ip;
|
||||
};
|
||||
|
||||
struct dhcps_lease {
|
||||
struct ip_addr start_ip;
|
||||
struct ip_addr end_ip;
|
||||
};
|
||||
|
||||
enum dhcps_offer_option{
|
||||
OFFER_START = 0x00,
|
||||
OFFER_ROUTER = 0x01,
|
||||
OFFER_END
|
||||
};
|
||||
|
||||
uint8 wifi_softap_get_station_num(void);
|
||||
struct station_info * wifi_softap_get_station_info(void);
|
||||
void wifi_softap_free_station_info(void);
|
||||
|
||||
bool wifi_softap_dhcps_start(void);
|
||||
bool wifi_softap_dhcps_stop(void);
|
||||
bool wifi_softap_set_dhcps_lease(struct dhcps_lease *please);
|
||||
bool wifi_softap_get_dhcps_lease(struct dhcps_lease *please);
|
||||
enum dhcp_status wifi_softap_dhcps_status(void);
|
||||
bool wifi_softap_set_dhcps_offer_option(uint8 level, void* optarg);
|
||||
|
||||
#define STATION_IF 0x00
|
||||
#define SOFTAP_IF 0x01
|
||||
|
||||
bool wifi_get_ip_info(uint8 if_index, struct ip_info *info);
|
||||
bool wifi_set_ip_info(uint8 if_index, struct ip_info *info);
|
||||
bool wifi_get_macaddr(uint8 if_index, uint8 *macaddr);
|
||||
bool wifi_set_macaddr(uint8 if_index, uint8 *macaddr);
|
||||
|
||||
uint8 wifi_get_channel(void);
|
||||
bool wifi_set_channel(uint8 channel);
|
||||
|
||||
void wifi_status_led_install(uint8 gpio_id, uint32 gpio_name, uint8 gpio_func);
|
||||
void wifi_status_led_uninstall();
|
||||
|
||||
/** Get the absolute difference between 2 u32_t values (correcting overflows)
|
||||
* 'a' is expected to be 'higher' (without overflow) than 'b'. */
|
||||
#define ESP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1)))
|
||||
|
||||
void wifi_promiscuous_enable(uint8 promiscuous);
|
||||
|
||||
typedef void (* wifi_promiscuous_cb_t)(uint8 *buf, uint16 len);
|
||||
|
||||
void wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb);
|
||||
|
||||
void wifi_promiscuous_set_mac(const uint8_t *address);
|
||||
|
||||
enum phy_mode {
|
||||
PHY_MODE_11B = 1,
|
||||
PHY_MODE_11G = 2,
|
||||
PHY_MODE_11N = 3
|
||||
};
|
||||
|
||||
enum phy_mode wifi_get_phy_mode(void);
|
||||
bool wifi_set_phy_mode(enum phy_mode mode);
|
||||
|
||||
enum sleep_type {
|
||||
NONE_SLEEP_T = 0,
|
||||
LIGHT_SLEEP_T,
|
||||
MODEM_SLEEP_T
|
||||
};
|
||||
|
||||
bool wifi_set_sleep_type(enum sleep_type type);
|
||||
enum sleep_type wifi_get_sleep_type(void);
|
||||
|
||||
enum {
|
||||
EVENT_STAMODE_CONNECTED = 0,
|
||||
EVENT_STAMODE_DISCONNECTED,
|
||||
EVENT_STAMODE_AUTHMODE_CHANGE,
|
||||
EVENT_STAMODE_GOT_IP,
|
||||
EVENT_SOFTAPMODE_STACONNECTED,
|
||||
EVENT_SOFTAPMODE_STADISCONNECTED,
|
||||
EVENT_MAX
|
||||
};
|
||||
|
||||
enum {
|
||||
REASON_UNSPECIFIED = 1,
|
||||
REASON_AUTH_EXPIRE = 2,
|
||||
REASON_AUTH_LEAVE = 3,
|
||||
REASON_ASSOC_EXPIRE = 4,
|
||||
REASON_ASSOC_TOOMANY = 5,
|
||||
REASON_NOT_AUTHED = 6,
|
||||
REASON_NOT_ASSOCED = 7,
|
||||
REASON_ASSOC_LEAVE = 8,
|
||||
REASON_ASSOC_NOT_AUTHED = 9,
|
||||
REASON_DISASSOC_PWRCAP_BAD = 10, /* 11h */
|
||||
REASON_DISASSOC_SUPCHAN_BAD = 11, /* 11h */
|
||||
REASON_IE_INVALID = 13, /* 11i */
|
||||
REASON_MIC_FAILURE = 14, /* 11i */
|
||||
REASON_4WAY_HANDSHAKE_TIMEOUT = 15, /* 11i */
|
||||
REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, /* 11i */
|
||||
REASON_IE_IN_4WAY_DIFFERS = 17, /* 11i */
|
||||
REASON_GROUP_CIPHER_INVALID = 18, /* 11i */
|
||||
REASON_PAIRWISE_CIPHER_INVALID = 19, /* 11i */
|
||||
REASON_AKMP_INVALID = 20, /* 11i */
|
||||
REASON_UNSUPP_RSN_IE_VERSION = 21, /* 11i */
|
||||
REASON_INVALID_RSN_IE_CAP = 22, /* 11i */
|
||||
REASON_802_1X_AUTH_FAILED = 23, /* 11i */
|
||||
REASON_CIPHER_SUITE_REJECTED = 24, /* 11i */
|
||||
|
||||
REASON_BEACON_TIMEOUT = 200,
|
||||
REASON_NO_AP_FOUND = 201,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint8 ssid[32];
|
||||
uint8 ssid_len;
|
||||
uint8 bssid[6];
|
||||
uint8 channel;
|
||||
} Event_StaMode_Connected_t;
|
||||
|
||||
typedef struct {
|
||||
uint8 ssid[32];
|
||||
uint8 ssid_len;
|
||||
uint8 bssid[6];
|
||||
uint8 reason;
|
||||
} Event_StaMode_Disconnected_t;
|
||||
|
||||
typedef struct {
|
||||
uint8 old_mode;
|
||||
uint8 new_mode;
|
||||
} Event_StaMode_AuthMode_Change_t;
|
||||
|
||||
typedef struct {
|
||||
struct ip_addr ip;
|
||||
struct ip_addr mask;
|
||||
struct ip_addr gw;
|
||||
} Event_StaMode_Got_IP_t;
|
||||
|
||||
typedef struct {
|
||||
uint8 mac[6];
|
||||
uint8 aid;
|
||||
} Event_SoftAPMode_StaConnected_t;
|
||||
|
||||
typedef struct {
|
||||
uint8 mac[6];
|
||||
uint8 aid;
|
||||
} Event_SoftAPMode_StaDisconnected_t;
|
||||
|
||||
typedef union {
|
||||
Event_StaMode_Connected_t connected;
|
||||
Event_StaMode_Disconnected_t disconnected;
|
||||
Event_StaMode_AuthMode_Change_t auth_change;
|
||||
Event_StaMode_Got_IP_t got_ip;
|
||||
Event_SoftAPMode_StaConnected_t sta_connected;
|
||||
Event_SoftAPMode_StaDisconnected_t sta_disconnected;
|
||||
} Event_Info_u;
|
||||
|
||||
typedef struct _esp_event {
|
||||
uint32 event;
|
||||
Event_Info_u event_info;
|
||||
} System_Event_t;
|
||||
|
||||
typedef void (* wifi_event_handler_cb_t)(System_Event_t *event);
|
||||
|
||||
void wifi_set_event_handler_cb(wifi_event_handler_cb_t cb);
|
||||
|
||||
typedef enum wps_type {
|
||||
WPS_TYPE_DISABLE = 0,
|
||||
WPS_TYPE_PBC,
|
||||
WPS_TYPE_PIN,
|
||||
WPS_TYPE_DISPLAY,
|
||||
WPS_TYPE_MAX
|
||||
} WPS_TYPE_t;
|
||||
|
||||
enum wps_cb_status {
|
||||
WPS_CB_ST_SUCCESS = 0,
|
||||
WPS_CB_ST_FAILED,
|
||||
WPS_CB_ST_TIMEOUT,
|
||||
WPS_CB_ST_WEP,
|
||||
};
|
||||
|
||||
bool wifi_wps_enable(WPS_TYPE_t wps_type);
|
||||
bool wifi_wps_disable(void);
|
||||
bool wifi_wps_start(void);
|
||||
|
||||
typedef void (*wps_st_cb_t)(int status);
|
||||
bool wifi_set_wps_cb(wps_st_cb_t cb);
|
||||
|
||||
typedef void (*freedom_outside_cb_t)(uint8 status);
|
||||
int wifi_register_send_pkt_freedom_cb(freedom_outside_cb_t cb);
|
||||
void wifi_unregister_send_pkt_freedom_cb(void);
|
||||
int wifi_send_pkt_freedom(uint8 *buf, int len, bool sys_seq);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user