设备DevArr 的length 在delete设备的时候没有更新

TinyServer 只不维护是否在线,只管维护LastTime就好
This commit is contained in:
WangQiang 2016-09-19 09:52:01 +00:00
parent 08aca30863
commit 78f9af8b7d
2 changed files with 7 additions and 5 deletions

View File

@ -132,7 +132,7 @@ void TinyServer::OnReceive(TinyMessage& msg, TinyController& ctrl)
// 设置当前设备
Current = dv;
OnPing(msg);
pDevMgmt->DeviceRequest(DeviceAtions::Online, dv); // 成功收到Ping才等于上线
// pDevMgmt->DeviceRequest(DeviceAtions::Online, dv); // 成功收到Ping才等于上线
break;
case 5:
case 0x15:
@ -156,7 +156,7 @@ void TinyServer::OnReceive(TinyMessage& msg, TinyController& ctrl)
}
// 更新设备信息
if(dv) dv->LastTime = Sys.Seconds();
if(dv && msg.Code > 2) dv->LastTime = Sys.Seconds();
// 设置当前设备
Current = dv;

View File

@ -82,9 +82,11 @@ bool DevicesManagement::DeleteDev(byte id)
{
debug_printf("DevicesManagement::DeleteDev Del id: 0x%02X\r\n", id);
int idx = DevArr.FindIndex(dv);
debug_printf("idx~~~~~~~~~~~:%d\r\n", idx);
if (idx >= 0)DevArr[idx] = nullptr;
// int idx = DevArr.FindIndex(dv);
// debug_printf("idx~~~~~~~~~~~:%d\r\n", idx);
// if (idx >= 0)DevArr[idx] = nullptr;
// DevArr.RemoveAt(idx);
DevArr.Remove(dv);
delete dv;
SaveDev();