Skip to content

Commit

Permalink
v1.2.12
Browse files Browse the repository at this point in the history
- ZigBee: fix node add/discovery desync
- ZigBee: added "node announce" event
  • Loading branch information
genemars committed Feb 14, 2023
1 parent 4560e37 commit 0b3d9c0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions MIG.HomeAutomation/ZigBee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ public object InterfaceControl(MigInterfaceCommand request)
{
break;
}

Thread.Sleep(DelayBetweenAttempts);
}
coord.PermitJoin(false);
Expand Down Expand Up @@ -417,6 +416,11 @@ public void RouteEvent(ZigBeeNode node, string eventDescription, string property
{
OnInterfacePropertyChanged(this.GetDomain(), node.IeeeAddress.ToString(), eventDescription, propertyPath, propertyValue);
}

public void ControllerEvent(string eventPath, string eventPayload)
{
OnInterfacePropertyChanged(this.GetDomain(), "0", "ZigBee Controller", eventPath, eventPayload);
}

public ZigBeeNode GetNode(ushort nodeId)
{
Expand All @@ -441,11 +445,11 @@ public void AddNode(ZigBeeNode node)
});
if (initialized)
{
lastAddedNode = node.IeeeAddress.ToString();
OnInterfacePropertyChanged(this.GetDomain(), "0", "ZigBee Controller", "Controller.Status", "Added node " + node.IeeeAddress);
ControllerEvent("Controller.Status", "Added node " + node.IeeeAddress);
// get manufacturer name and model identifier
ReadClusterData(node).Wait();
OnInterfaceModulesChanged(this.GetDomain());
lastAddedNode = node.IeeeAddress.ToString();
}
}
}
Expand All @@ -455,7 +459,7 @@ public void RemoveNode(ZigBeeNode node)
int removed = modules.RemoveAll((m) => m.Address == node.IeeeAddress.ToString());
if (removed > 0)
{
OnInterfacePropertyChanged(this.GetDomain(), "0", "ZigBee Controller", "Controller.Status", "Removed node " + node.IeeeAddress);
ControllerEvent("Controller.Status", "Removed node " + node.IeeeAddress);
OnInterfaceModulesChanged(this.GetDomain());
}
}
Expand Down Expand Up @@ -719,7 +723,7 @@ public void CommandReceived(ZigBeeCommand command)
var node = _zigBee.GetNode(nodeId);
if (command is DeviceAnnounce)
{
// Console.WriteLine("DEVICE ANNOUNCE");
_zigBee.ControllerEvent("Controller.Status", "Announce node " + node.IeeeAddress);
}
else if (command is ReportAttributesCommand)
{
Expand Down

0 comments on commit 0b3d9c0

Please sign in to comment.