修改flag 二进制为 bool类型
This commit is contained in:
parent
a2e59c8de3
commit
1c38566dba
|
@ -24,7 +24,11 @@ AP0801::AP0801()
|
|||
|
||||
Data = nullptr;
|
||||
Size = 0;
|
||||
Flag = 0;
|
||||
// 一众标识初始化
|
||||
NetMaster = false;
|
||||
NetBra = false;
|
||||
EspMaster = false;
|
||||
EspBra = false;
|
||||
}
|
||||
|
||||
void AP0801::Init(ushort code, cstring name, COM message)
|
||||
|
@ -183,13 +187,8 @@ void AP0801::Register(int index, IDataPort& dp)
|
|||
|
||||
void AP0801::OpenClient(ISocketHost& host)
|
||||
{
|
||||
/*
|
||||
Flag 四个字节 最高字节标识esp作为Master 第二字节标识esp广播Controller
|
||||
第三字节为 w5500 作为Master 第四字节为 w5500 广播端口
|
||||
*/
|
||||
|
||||
assert(Client, "Client");
|
||||
debug_printf("\r\n OpenClient Flag :0x%08X\r\n", Flag);
|
||||
// debug_printf("\r\n OpenClient Flag :0x%08X\r\n", Flag);
|
||||
|
||||
// 网络就绪后,打开指示灯
|
||||
auto net = dynamic_cast<W5500*>(&host);
|
||||
|
@ -206,38 +205,38 @@ void AP0801::OpenClient(ISocketHost& host)
|
|||
{
|
||||
if (Host == esp) // 8266 作为Host的时候 使用 Master 和广播端口两个 HostAP 为空
|
||||
{
|
||||
if (esp->Joined && !(Flag & 0x01000000))
|
||||
if (esp->Joined && !EspMaster)
|
||||
{
|
||||
AddControl(*Host, tk->Uri(), 0); // 如果 Host 是 ESP8266 则要求 JoinAP 完成才能添加主控制器
|
||||
Flag |= 0x01000000;
|
||||
EspMaster = true;
|
||||
}
|
||||
if (!(Flag & 0x00010000))
|
||||
if (!EspBra)
|
||||
{
|
||||
AddControl(*Host, uri, tk->Port);
|
||||
Flag |= 0x00010000;
|
||||
EspBra = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Host == net) // w5500 作为Host的时候 使用Master和广播两个端口 HostAP 开启AP时非空 打开其内网端口
|
||||
{
|
||||
if (!(Flag & 0x00000100))
|
||||
if (!NetMaster)
|
||||
{
|
||||
AddControl(*Host, tk->Uri(), 0); // 如果 Host 是 W5500 打开了就直接允许添加Master
|
||||
Flag |= 0x00000100;
|
||||
NetMaster = true;
|
||||
}
|
||||
if (!(Flag & 0x00000001))
|
||||
if (!NetBra)
|
||||
{
|
||||
AddControl(*Host, uri, tk->Port);
|
||||
Flag |= 0x00000001;
|
||||
NetBra = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (HostAP && HostAP == esp) // 只使用esp的时候HostAp为空
|
||||
{
|
||||
if (!(Flag & 0x00010000))
|
||||
if (!EspBra)
|
||||
{
|
||||
AddControl(*Host, uri, tk->Port);
|
||||
Flag |= 0x00010000;
|
||||
EspBra = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,13 @@ public:
|
|||
private:
|
||||
void* Data;
|
||||
int Size;
|
||||
uint Flag; // 内部使用 标识Controller创建情况
|
||||
// Control 打开情况标识
|
||||
bool NetMaster;
|
||||
bool NetBra;
|
||||
bool EspMaster;
|
||||
bool EspBra;
|
||||
|
||||
// uint Flag; // 内部使用 标识Controller创建情况
|
||||
|
||||
void OpenClient(ISocketHost& host);
|
||||
TokenController* AddControl(ISocketHost& host, const NetUri& uri, ushort localPort);
|
||||
|
|
|
@ -27,8 +27,12 @@ AP0802::AP0802()
|
|||
Client = nullptr;
|
||||
|
||||
Data = nullptr;
|
||||
Size = 0;
|
||||
Flag = 0;
|
||||
Size = 0;
|
||||
// Control 打开情况标识
|
||||
NetMaster = false;
|
||||
NetBra = false;
|
||||
EspMaster = false;
|
||||
EspBra = false;
|
||||
}
|
||||
|
||||
void AP0802::Init(ushort code, cstring name, COM message)
|
||||
|
@ -173,6 +177,13 @@ void AP0802::Register(int index, IDataPort& dp)
|
|||
ds.Register(index, dp);
|
||||
}
|
||||
|
||||
/*
|
||||
// Control 打开情况标识
|
||||
bool NetMaster;
|
||||
bool NetBra;
|
||||
bool EspMaster;
|
||||
bool EspBra;
|
||||
*/
|
||||
void AP0802::OpenClient(ISocketHost& host)
|
||||
{
|
||||
/*
|
||||
|
@ -198,38 +209,38 @@ void AP0802::OpenClient(ISocketHost& host)
|
|||
{
|
||||
if (Host == esp) // 8266 作为Host的时候 使用 Master 和广播端口两个 HostAP 为空
|
||||
{
|
||||
if (esp->Joined && !(Flag & 0x01000000))
|
||||
if (esp->Joined && !EspMaster)
|
||||
{
|
||||
AddControl(*Host, tk->Uri(), 0); // 如果 Host 是 ESP8266 则要求 JoinAP 完成才能添加主控制器
|
||||
Flag |= 0x01000000;
|
||||
EspMaster = true;
|
||||
}
|
||||
if (!(Flag & 0x00010000))
|
||||
if (!EspBra)
|
||||
{
|
||||
AddControl(*Host, uri, tk->Port);
|
||||
Flag |= 0x00010000;
|
||||
EspBra = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Host == net) // w5500 作为Host的时候 使用Master和广播两个端口 HostAP 开启AP时非空 打开其内网端口
|
||||
{
|
||||
if (!(Flag & 0x00000100))
|
||||
if (!NetMaster)
|
||||
{
|
||||
AddControl(*Host, tk->Uri(), 0); // 如果 Host 是 W5500 打开了就直接允许添加Master
|
||||
Flag |= 0x00000100;
|
||||
NetMaster = true;
|
||||
}
|
||||
if (!(Flag & 0x00000001))
|
||||
if (!NetBra)
|
||||
{
|
||||
AddControl(*Host, uri, tk->Port);
|
||||
Flag |= 0x00000001;
|
||||
NetBra = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (HostAP && HostAP == esp) // 只使用esp的时候HostAp为空
|
||||
{
|
||||
if (!(Flag & 0x00010000))
|
||||
if (!EspBra)
|
||||
{
|
||||
AddControl(*Host, uri, tk->Port);
|
||||
Flag |= 0x00010000;
|
||||
EspBra = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,13 @@ public:
|
|||
private:
|
||||
void* Data;
|
||||
int Size;
|
||||
uint Flag; // 内部使用 标识Controller创建情况
|
||||
// Control 打开情况标识
|
||||
bool NetMaster;
|
||||
bool NetBra;
|
||||
bool EspMaster;
|
||||
bool EspBra;
|
||||
|
||||
// uint Flag; // 内部使用 标识Controller创建情况
|
||||
|
||||
void OpenClient(ISocketHost& host);
|
||||
TokenController* AddControl(ISocketHost& host, const NetUri& uri, ushort localPort);
|
||||
|
|
Loading…
Reference in New Issue