mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-27 21:16:50 +03:00
add back SmartConfig
This commit is contained in:
parent
b5679b10ef
commit
483533ac4c
@ -27,6 +27,7 @@ extern "C" {
|
|||||||
#include "osapi.h"
|
#include "osapi.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
|
#include "smartconfig.h"
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#include "lwip/err.h"
|
#include "lwip/err.h"
|
||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
@ -375,6 +376,45 @@ int ESP8266WiFiClass::hostByName(const char* aHostname, IPAddress& aResult)
|
|||||||
return (aResult != 0) ? 1 : 0;
|
return (aResult != 0) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ESP8266WiFiClass::beginSmartConfig()
|
||||||
|
{
|
||||||
|
if (_smartConfigStarted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
|
|
||||||
|
_smartConfigStarted = true;
|
||||||
|
|
||||||
|
//SC_TYPE_ESPTOUCH use ESPTOUCH for smartconfig, or use SC_TYPE_AIRKISS for AIRKISS
|
||||||
|
smartconfig_start(SC_TYPE_ESPTOUCH, &ESP8266WiFiClass::_smartConfigDone);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ESP8266WiFiClass::stopSmartConfig()
|
||||||
|
{
|
||||||
|
if (!_smartConfigStarted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
smartconfig_stop();
|
||||||
|
_smartConfigStarted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ESP8266WiFiClass::smartConfigDone(){
|
||||||
|
if (!_smartConfigStarted)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return smartconfig_get_status() == SC_STATUS_LINK_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ESP8266WiFiClass::_smartConfigDone(void* result)
|
||||||
|
{
|
||||||
|
station_config* sta_conf = reinterpret_cast<station_config*>(result);
|
||||||
|
|
||||||
|
wifi_station_set_config(sta_conf);
|
||||||
|
wifi_station_disconnect();
|
||||||
|
wifi_station_connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ESP8266WiFiClass::printDiag(Print& p)
|
void ESP8266WiFiClass::printDiag(Print& p)
|
||||||
{
|
{
|
||||||
const char* modes[] = {"NULL", "STA", "AP", "STA+AP"};
|
const char* modes[] = {"NULL", "STA", "AP", "STA+AP"};
|
||||||
|
@ -211,12 +211,29 @@ public:
|
|||||||
*/
|
*/
|
||||||
void printDiag(Print& dest);
|
void printDiag(Print& dest);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Start SmartConfig
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void beginSmartConfig();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Query SmartConfig status, to decide when stop config
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool smartConfigDone();
|
||||||
|
|
||||||
|
void stopSmartConfig();
|
||||||
|
|
||||||
friend class WiFiClient;
|
friend class WiFiClient;
|
||||||
friend class WiFiServer;
|
friend class WiFiServer;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _scanDone(void* result, int status);
|
static void _scanDone(void* result, int status);
|
||||||
void * _getScanInfoByIndex(int i);
|
void * _getScanInfoByIndex(int i);
|
||||||
|
static void _smartConfigDone(void* result);
|
||||||
|
bool _smartConfigStarted = false;
|
||||||
|
|
||||||
static size_t _scanCount;
|
static size_t _scanCount;
|
||||||
static void* _scanResult;
|
static void* _scanResult;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ compiler.S.flags=-c -g -x assembler-with-cpp -MMD
|
|||||||
compiler.c.elf.ldscript=eagle.app.v6.ld
|
compiler.c.elf.ldscript=eagle.app.v6.ld
|
||||||
compiler.c.elf.flags=-nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-T{compiler.c.elf.ldscript}"
|
compiler.c.elf.flags=-nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-T{compiler.c.elf.ldscript}"
|
||||||
compiler.c.elf.cmd=xtensa-lx106-elf-gcc
|
compiler.c.elf.cmd=xtensa-lx106-elf-gcc
|
||||||
compiler.c.elf.libs=-lgcc -lm -lhal -lphy -lnet80211 -llwip -lwpa -lmain -lpp
|
compiler.c.elf.libs=-lgcc -lm -lhal -lphy -lnet80211 -llwip -lwpa -lmain -lpp -lsmartconfig
|
||||||
|
|
||||||
compiler.cpp.cmd=xtensa-lx106-elf-g++
|
compiler.cpp.cmd=xtensa-lx106-elf-g++
|
||||||
compiler.cpp.flags=-c -Os -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -std=c++11 -MMD
|
compiler.cpp.flags=-c -Os -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -std=c++11 -MMD
|
||||||
|
Loading…
x
Reference in New Issue
Block a user