public static ZWaveEvent GetEvent(ZWaveNode node, byte[] message) { ZWaveEvent nodeEvent = null; byte cmdType = message[8]; if (message.Length > 12 && cmdType == (byte)Command.AssociationReport) { byte groupId = message[9]; byte maxAssociations = message[10]; byte numAssociations = message[11]; // it is always zero ?!? string assocNodes = ""; if (message.Length > 13) { for (int a = 12; a < message.Length - 1; a++) { assocNodes += message[a] + ","; } } assocNodes = assocNodes.TrimEnd(','); // var associationRespose = new AssociationResponse() { Max = maxAssociations, Count = numAssociations, NodeList = assocNodes, GroupId = groupId }; nodeEvent = new ZWaveEvent(node, EventParameter.Association, associationRespose, 0); } return(nodeEvent); }
public ZWaveEvent GetEvent(ZWaveNode node, byte[] message) { ZWaveEvent nodeEvent = null; byte cmdType = message[1]; if (message.Length > 5 && cmdType == (byte)Command.AssociationReport) { byte groupId = message[2]; byte associationMax = message[3]; byte associationCount = message[4]; // it is always zero ?!? string associationNodes = ""; if (message.Length > 4) { for (int a = 5; a < message.Length; a++) { associationNodes += message[a] + ","; } } associationNodes = associationNodes.TrimEnd(','); // var associationResponse = new AssociationResponse() { Max = associationMax, Count = associationCount, NodeList = associationNodes, GroupId = groupId }; nodeEvent = new ZWaveEvent(node, EventParameter.Association, associationResponse, 0); } return(nodeEvent); }
public static ZWaveEvent GetEvent(ZWaveNode node, byte[] message) { ZWaveEvent nodeEvent = null; byte cmdType = message[8]; if (message.Length > 12 && cmdType == (byte)Command.AssociationReport) { byte groupId = message[9]; byte maxAssociations = message[10]; byte numAssociations = message[11]; // it is always zero ?!? string assocNodes = ""; if (message.Length > 13) { for (int a = 12; a < message.Length - 1; a++) { assocNodes += message[a] + ","; } } assocNodes = assocNodes.TrimEnd(','); // var associationRespose = new AssociationResponse() { Max = maxAssociations, Count = numAssociations, NodeList = assocNodes, GroupId = groupId }; nodeEvent = new ZWaveEvent(node, EventParameter.Association, associationRespose, 0); } return nodeEvent; }
public AssociationResponse ReceiveAssociationResponse() { var pdu = ReadNextPDU(DataUnitType.AssociateAcceptPDU, DataUnitType.AssociateRejectPDU); if (pdu is AssociateAcceptPDU associateAcceptPDU) { var associationResponse = AssociationResponse.FromPDU(associateAcceptPDU); MaxDataTransferPDULengthRequestedByPeer = associationResponse.MaxDataTransferPDULength; return(associationResponse); } else if (pdu is AssociateRejectPDU associateRejectPDU) { throw new AssociationRejectedException(associateRejectPDU); } else { throw new Exception("Logic error"); } }
public ZWaveEvent GetEvent(ZWaveNode node, byte[] message) { ZWaveEvent nodeEvent = null; byte cmdType = message[1]; // we want to get in to that we can handle NO Associations if (message.Length > 4 && cmdType == (byte)Command.AssociationReport) { byte groupId = message[2]; byte associationMax = message[3]; byte associationCount = message[4]; // it is always zero ?!? string associationNodes = ""; if (message.Length > 4) { for (int a = 5; a < message.Length; a++) { associationNodes += message[a] + ","; } } associationNodes = associationNodes.TrimEnd(','); // We don't want to send empty response since it will be handled as "timeout" // so setting it to "None" if (associationNodes.Length == 0) { associationNodes = "None"; } // var associationResponse = new AssociationResponse() { Max = associationMax, Count = associationCount, NodeList = associationNodes, GroupId = groupId }; nodeEvent = new ZWaveEvent(node, EventParameter.Association, associationResponse, 0); } return(nodeEvent); }
public NodeEvent GetEvent(ZWaveNode node, byte[] message) { NodeEvent nodeEvent = null; byte cmdType = message[1]; // we want to get in to that we can handle NO Associations if (message.Length > 4 && cmdType == (byte)Command.AssociationReport) { byte groupId = message[2]; byte associationMax = message[3]; byte associationCount = message[4]; // it is always zero ?!? string associationNodes = ""; if (message.Length > 4) { for (int a = 5; a < message.Length; a++) { associationNodes += message[a] + ","; } } associationNodes = associationNodes.TrimEnd(','); // We don't want to send empty response since it will be handled as "timeout" // so setting it to "None" if (associationNodes.Length == 0) { associationNodes = "None"; } // var associationResponse = new AssociationResponse() { Max = associationMax, Count = associationCount, NodeList = associationNodes, GroupId = groupId }; nodeEvent = new NodeEvent(node, EventParameter.Association, associationResponse, 0); } return nodeEvent; }
public void SendAssociationResponse(AssociationResponse associationResponse) { var associateAcceptPDU = associationResponse.ToPDU(_associateRequestPDU); SendPDU(associateAcceptPDU); }