From c156bc9d3458b4a1ca5a5aa73b2de23d44edd33d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4X2?= Date: Wed, 1 Mar 2017 01:19:22 +0800 Subject: [PATCH] =?UTF-8?q?WiFi=E6=8E=A5=E5=8F=A3=E6=9E=90=E6=9E=84?= =?UTF-8?q?=E6=97=B6=E8=87=AA=E5=8A=A8=E9=94=80=E6=AF=81ssid/pass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Drivers/Esp8266/Esp8266.cpp | 31 +++++++++++++++---------------- Net/NetworkInterface.cpp | 6 ++++++ Net/NetworkInterface.h | 2 +- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Drivers/Esp8266/Esp8266.cpp b/Drivers/Esp8266/Esp8266.cpp index 47135338..5a30d031 100644 --- a/Drivers/Esp8266/Esp8266.cpp +++ b/Drivers/Esp8266/Esp8266.cpp @@ -50,20 +50,19 @@ Esp8266::Esp8266(COM idx, Pin power, Pin rst) Esp8266::~Esp8266() { - delete SSID; - delete Pass; + RemoveLed(); } void Esp8266::Init(ITransport* port, Pin power, Pin rst) { - Name = "Esp8266"; - Speed = 54; + Name = "Esp8266"; + Speed = 54; Port = port; - if(Port) + if (Port) { - if(MinSize) MinSize = Port->MinSize; - if(MaxSize) MaxSize = Port->MaxSize; + if (MinSize) MinSize = Port->MinSize; + if (MaxSize) MaxSize = Port->MaxSize; Port->Register(OnPortReceive, this); } @@ -71,16 +70,16 @@ void Esp8266::Init(ITransport* port, Pin power, Pin rst) _power.Init(power, false); if (rst != P0) _rst.Init(rst, true); - _task = 0; + _task = 0; - Led = nullptr; + Led = nullptr; - _Expect = nullptr; + _Expect = nullptr; Buffer(_sockets, 5 * 4).Clear(); - Mode = NetworkType::STA_AP; - WorkMode= NetworkType::STA_AP; + Mode = NetworkType::STA_AP; + WorkMode = NetworkType::STA_AP; InitConfig(); LoadConfig(); @@ -100,10 +99,10 @@ void Esp8266::SetLed(Pin led) void Esp8266::SetLed(OutputPort& led) { - auto fp = new FlushPort(); - fp->Port = &led; + auto fp = new FlushPort(); + fp->Port = &led; fp->Start(); - Led = fp; + Led = fp; } void Esp8266::RemoveLed() @@ -463,7 +462,7 @@ void ParseFail(cstring name, const Buffer& bs) uint Esp8266::OnPortReceive(ITransport* sender, Buffer& bs, void* param, void* param2) { - auto esp = (Esp8266*)param; + auto esp = (Esp8266*)param; return esp->OnReceive(bs, param2); } diff --git a/Net/NetworkInterface.cpp b/Net/NetworkInterface.cpp index 6946cb6d..3b29bd3f 100644 --- a/Net/NetworkInterface.cpp +++ b/Net/NetworkInterface.cpp @@ -289,6 +289,12 @@ WiFiInterface::WiFiInterface() : NetworkInterface() Pass = nullptr; } +WiFiInterface::~WiFiInterface() +{ + delete SSID; + delete Pass; +} + bool WiFiInterface::IsStation() const { return Mode == NetworkType::Station || Mode == NetworkType::STA_AP; diff --git a/Net/NetworkInterface.h b/Net/NetworkInterface.h index 7b9316e5..d606769e 100644 --- a/Net/NetworkInterface.h +++ b/Net/NetworkInterface.h @@ -113,7 +113,7 @@ public: String* Pass; // 无线密码 WiFiInterface(); - virtual ~WiFiInterface() { } + virtual ~WiFiInterface(); bool IsStation() const; bool IsAP() const;