public void SendRequest(byte[] request) { // lookup request[0] in supportedClasses to see if we need to encrypt the message or NOT // we don't encrypt the message if it's sent by the Security Class byte cmd = request[0]; SupportedCommandClasses scc = supportedClasses.Find(x => x.cclass == cmd); byte[] msg = ZWaveMessage.CreateRequest(this.Id, request); if (scc != null && scc.secure && cmd != (byte)CommandClass.Security) { security.encryptAndSend(this, msg); } else { SendMessage(msg); } }
public bool BuildSupportedList(byte[] nodesInfo, bool secured) { bool afterMark = false; bool foundSecure = false; if (nodesInfo == null) { return(false); } foreach (byte nodeInfo in nodesInfo) { if (nodeInfo == (byte)0xEF) { // COMMAND_CLASS_MARK. // Marks the end of the list of supported command classes. The remaining classes // are those that can be controlled by the device. These classes are created // without values. Messages received cause notification events instead. afterMark = true; continue; } var cc = CommandClassFactory.GetCommandClass((byte)nodeInfo); if (cc == null) { Console.WriteLine(nodeInfo.ToString("X2") + " - We don't NOT supporte this CommandClass"); } else { SupportedCommandClasses scc = supportedClasses.Find(x => x.cclass == (byte)nodeInfo); if (scc == null) { scc = new SupportedCommandClasses { cclass = (byte)nodeInfo, secure = secured, afterMark = afterMark }; supportedClasses.Add(scc); Console.WriteLine("Added " + scc); } else { scc.secure = true; Console.WriteLine("Updated " + scc); } } if (nodeInfo == (byte)CommandClass.Security) { foundSecure = true; } this.NodeInformationFrame = addElementToArray(this.NodeInformationFrame, nodeInfo); if (secured) { this.SecuredNodeInformationFrame = addElementToArray(this.SecuredNodeInformationFrame, nodeInfo); } } return(foundSecure); }