In short term when clicked on the button buttonClick is activated. You send a broadcast to all the nodes by passing the parameters to the function SendData, afterwards it return. And call ActivateAlllNodeswhere it call itself until max number of nodes has been received. I do not know it is easier to look through having all the project.
private void buttonClick(object sender, System.EventArgs e)
{
if (api.SendData(BROADCAST,command,2, ActivateAlllNodes)))
{
m_txtStatus.Text.Insert(1,"OKAY");
}
else
{
m_txtStatus.Text.Insert(1,"FAILING");
}
}
public virtual void ActivateAlllNodes(byte[] command)
{
byte nodeID = 0;
while (nodeID++ < MAX_NODES)
{
if (nodeIDisaccepted)
break;
}
if (nodeID > MAX_NODES)
{
m_txtStatus.Text.Insert(1,"FINISH");
}
else
{
api.SendData(nodeID, command, 2,ActivateAlllNodes);
}
}
public delegate void CompletedFunc(byte b);
public byte SendData(byte nodeID, byte[] pdata, byte dataLength, CompletedFunc cmplfunc)
{
byte byCompletedFunc = ( cmplfunc == NULL? 0: 0x03); and some other stuff here...
}