网络接口Config方法支持返回成功失败

This commit is contained in:
大石头X2 2017-03-10 15:58:08 +08:00
parent 6841c6ae64
commit cac3f2ddac
7 changed files with 12 additions and 7 deletions

View File

@ -254,7 +254,7 @@ bool Esp8266::OnLink(uint retry)
} }
// 配置网络参数 // 配置网络参数
void Esp8266::Config() bool Esp8266::Config()
{ {
// 设置多连接 // 设置多连接
SetMux(true); SetMux(true);
@ -268,6 +268,8 @@ void Esp8266::Config()
SetMAC(false, mac); SetMAC(false, mac);
//SetAutoConn(AutoConn); //SetAutoConn(AutoConn);
return true;
} }
Socket* Esp8266::CreateSocket(NetType type) Socket* Esp8266::CreateSocket(NetType type)

View File

@ -30,7 +30,7 @@ public:
void Init(ITransport* port, Pin power = P0, Pin rst = P0); void Init(ITransport* port, Pin power = P0, Pin rst = P0);
virtual void Config(); virtual bool Config();
void SetLed(Pin led); void SetLed(Pin led);
void SetLed(OutputPort& led); void SetLed(OutputPort& led);
void RemoveLed(); void RemoveLed();

View File

@ -514,7 +514,7 @@ bool W5500::OnLink(uint retry)
return true; return true;
} }
void W5500::Config() bool W5500::Config()
{ {
ShowConfig(); ShowConfig();
@ -555,6 +555,8 @@ void W5500::Config()
// 一次性全部写入 // 一次性全部写入
WriteFrame(0, bs); WriteFrame(0, bs);
return true;
} }
void W5500::ChangePower(int level) void W5500::ChangePower(int level)

View File

@ -29,7 +29,7 @@ public:
void SetLed(Pin led); void SetLed(Pin led);
void SetLed(OutputPort& led); void SetLed(OutputPort& led);
virtual void Config(); virtual bool Config();
// 读写帧,帧本身由外部构造 (包括帧数据内部的读写标志) // 读写帧,帧本身由外部构造 (包括帧数据内部的读写标志)
bool WriteFrame(ushort addr, const Buffer& bs, byte socket = 0 ,byte block = 0); bool WriteFrame(ushort addr, const Buffer& bs, byte socket = 0 ,byte block = 0);

View File

@ -60,7 +60,7 @@ public:
bool Active() const; bool Active() const;
// 应用配置 // 应用配置
virtual void Config() = 0; virtual bool Config() = 0;
// 保存和加载网络配置 // 保存和加载网络配置
void InitConfig(); void InitConfig();

View File

@ -237,9 +237,10 @@ void TinyIP::OnClose()
_port->Close(); _port->Close();
} }
void TinyIP::Config() bool TinyIP::Config()
{ {
//ShowConfig(); //ShowConfig();
return true;
} }
bool TinyIP::SendEthernet(ETH_TYPE type, const MacAddress& remote, const byte* buf, uint len) bool TinyIP::SendEthernet(ETH_TYPE type, const MacAddress& remote, const byte* buf, uint len)

View File

@ -59,7 +59,7 @@ public:
virtual ~TinyIP(); virtual ~TinyIP();
void Init(ITransport* port); void Init(ITransport* port);
virtual void Config(); virtual bool Config();
ushort CheckSum(IPAddress* remote, const byte* buf, uint len, byte type); ushort CheckSum(IPAddress* remote, const byte* buf, uint len, byte type);
bool SendEthernet(ETH_TYPE type, const MacAddress& remote, const byte* buf, uint len); bool SendEthernet(ETH_TYPE type, const MacAddress& remote, const byte* buf, uint len);