internal virtual void OnNodeUpdated(NodeEvent zevent) { if (NodeUpdated != null) { NodeUpdated(this, zevent); } }
private void ZWave_NodeUpdated(object sender, NodeEvent eventData) { ZWaveNode node = (ZWaveNode)sender; if (eventData.Parameter == EventParameter.SecurityDecriptedMessage && eventData.Value is byte[]) { node.ApplicationCommandHandler((byte[])eventData.Value); return; } else if (eventData.Parameter == EventParameter.SecurityNodeInformationFrame) { node.SecuredNodeInformationFrame = (byte[])eventData.Value; // we take them one a a time to make sure we keep the list with unique elements foreach (byte nodeInfo in node.SecuredNodeInformationFrame) { // if we found the COMMAND_CLASS_MARK we get out of the for loop if (nodeInfo == (byte)0xEF) { break; } node.NodeInformationFrame = Utility.AppendByteToArray(node.NodeInformationFrame, nodeInfo); } // we just send other events and save the node data NodeInformationFrameDone(node); } // Route node event OnNodeUpdated(new NodeUpdatedEventArgs(eventData.Node.Id, eventData)); }
internal virtual bool ApplicationCommandHandler(byte[] receivedMessage) { NodeEvent messageEvent = null; int messageLength = receivedMessage.Length; if (messageLength > 8) { byte commandLength = receivedMessage[6]; byte commandClass = receivedMessage[7]; // TODO: this should be moved inside the NodeCommandClass class // TODO: as "Instance" property var cc = CommandClassFactory.GetCommandClass(commandClass); byte[] message = new byte[commandLength]; Array.Copy(receivedMessage, 7, message, 0, commandLength); try { messageEvent = cc.GetEvent(this, message); } catch (Exception ex) { Utility.logger.Error(ex); } } if (messageEvent != null) { OnNodeUpdated(messageEvent); } else if (messageLength > 3 && receivedMessage[3] != 0x13) { Utility.logger.Warn("Unhandled message type"); } return(false); }
internal virtual bool ApplicationCommandHandler(byte[] rawMessage) { NodeEvent messageEvent = null; int messageLength = rawMessage.Length; if (messageLength > 8) { byte commandLength = rawMessage[6]; byte commandClass = rawMessage[7]; // TODO: this should be moved inside the NodeCommandClass class // TODO: as "Instance" property var cc = CommandClassFactory.GetCommandClass(commandClass); byte[] message = new byte[commandLength]; Array.Copy(rawMessage, 7, message, 0, commandLength); try { if (cc != null) { messageEvent = cc.GetEvent(this, message); } else { Utility.logger.Debug("CommandClass {0} not supported yet", commandClass); } } catch (Exception ex) { Utility.logger.Error(ex); } } if (messageEvent != null) { OnNodeUpdated(messageEvent); } else if (messageLength > 3 && rawMessage[3] != (byte)ZWaveFunction.SendData) { Utility.logger.Warn("Unhandled message type: {0}", BitConverter.ToString(rawMessage)); } return(false); }
private void ZWave_NodeUpdated(object sender, NodeEvent eventData) { ZWaveNode node = (ZWaveNode)sender; if (eventData.Parameter == EventParameter.SecurityDecriptedMessage && eventData.Value is byte[]) { node.ApplicationCommandHandler((byte[])eventData.Value); return; } else if (eventData.Parameter == EventParameter.SecurityNodeInformationFrame) { node.SecuredNodeInformationFrame = (byte[])eventData.Value; // we take them one a a time to make sure we keep the list with unique elements foreach (byte nodeInfo in node.SecuredNodeInformationFrame) { // if we found the COMMAND_CLASS_MARK we get out of the for loop if (nodeInfo == (byte)0xEF) break; node.NodeInformationFrame = Utility.AppendByteToArray(node.NodeInformationFrame, nodeInfo); } // we just send other events and save the node data NodeInformationFrameDone(node); } // Route node event OnNodeUpdated(new NodeUpdatedEventArgs(eventData.Node.Id, eventData)); }
internal virtual void OnNodeUpdated(NodeEvent zevent) { if (NodeUpdated != null) NodeUpdated(this, zevent); }
public NodeUpdatedEventArgs(byte nodeId, NodeEvent evt) { NodeId = nodeId; Event = evt; Timestamp = DateTime.UtcNow; }