private IList <byte> GetCapability(int endpointId) { var ret = new List <byte>(); ret.Add(COMMAND_CLASS_ZWAVEPLUS_INFO_V2.ID); if (endpointId != 2) // exclude secure classes for testing { if (_network.HasSecurityScheme(SecuritySchemes.S0)) { ret.Add(COMMAND_CLASS_SECURITY.ID); } if (_network.HasSecurityScheme(SecuritySchemeSet.ALLS2)) { ret.Add(COMMAND_CLASS_SECURITY_2.ID); } } if (!_network.HasSecurityScheme(SecuritySchemeSet.ALL)) { ret.AddRange(ENDPOINTS_COMMAND_CLASSES); } else { ret.AddRange(_network.GetSecureFilteredCommandClasses(ENDPOINTS_COMMAND_CLASSES, false)); } return(ret); }
protected override void OnCompletedInternal(ActionCompletedUnit ou) { var result = ou.Action.Result; if (result is RequestNodeInfoResult) { RequestNodeInfoResult res = (RequestNodeInfoResult)result; if (res) { if (_nodeInfo.Result) { _nodeInfoSecondAttempt.Token.SetCancelled(); } else if (_nodeInfoSecondAttempt.Result) { isFirstFailed = true; SpecificResult.RequestNodeInfo = _nodeInfoSecondAttempt.SpecificResult; } if ((res.CommandClasses == null || !res.CommandClasses.Contains(COMMAND_CLASS_MULTI_CHANNEL_V4.ID)) && (res.SecureCommandClasses == null || !res.SecureCommandClasses.Contains(COMMAND_CLASS_MULTI_CHANNEL_V4.ID))) { _requestEndPoints.Token.SetCancelled(); _requestEndPointsCapabilities.Token.SetCancelled(); } } else if (isFirstFailed) { _requestEndPoints.Token.SetCancelled(); _requestEndPointsCapabilities.Token.SetCancelled(); } } else if (result is RequestDataResult) { RequestDataResult res = (RequestDataResult)result; if (res && res.Command != null && res.Command.Length > 1 && res.Command[0] == COMMAND_CLASS_MULTI_CHANNEL_V4.ID) { if (res.Command[1] == COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_END_POINT_REPORT.ID) { COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_END_POINT_REPORT epReport = res.Command; _isIdentical = epReport.properties1.identical == 0x01; _endPoints = epReport.properties2.individualEndPoints; var count = _isIdentical ? 1 : _endPoints; if ((count > 0 && count < 0xFF)) { var tmpList = new List <ActionBase>(); for (int i = 0; i < count; i++) { COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_CAPABILITY_GET cGet = new COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_CAPABILITY_GET(); cGet.properties1.res = 0x00; cGet.properties1.endPoint = (byte)(i + 1); var requestCapability = new RequestDataOperation(0, res.NodeId, cGet, _txOptions, new COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_CAPABILITY_REPORT(), 2, 5000); tmpList.Add(requestCapability); if (_network != null && _network.HasSecurityScheme(res.NodeId, SecuritySchemeSet.ALL)) { byte[] data = null; if (_network.HasSecurityScheme(res.NodeId, SecuritySchemeSet.ALLS2)) { data = new COMMAND_CLASS_SECURITY_2.SECURITY_2_COMMANDS_SUPPORTED_GET(); } else if (_network.HasSecurityScheme(res.NodeId, SecuritySchemes.S0)) { data = new COMMAND_CLASS_SECURITY.SECURITY_COMMANDS_SUPPORTED_GET(); } COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_CMD_ENCAP multiChannelCmd = new COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_CMD_ENCAP(); multiChannelCmd.commandClass = data[0]; multiChannelCmd.command = data[1]; multiChannelCmd.parameter = new List <byte>(); for (int j = 2; j < data.Length; j++) { multiChannelCmd.parameter.Add(data[j]); } multiChannelCmd.properties1.res = 0; multiChannelCmd.properties1.sourceEndPoint = 0; multiChannelCmd.properties2.bitAddress = 0; multiChannelCmd.properties2.destinationEndPoint = (byte)(i + 1); data = multiChannelCmd; var requestSupported = new RequestDataOperation(0, res.NodeId, multiChannelCmd, _txOptions, new COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_CMD_ENCAP(), 2, 5000); tmpList.Add(requestSupported); } } _requestEndPointsCapabilities.AddActions(tmpList.ToArray()); } SpecificResult.RequestEndPoints = res; } } } else if (result.InnerResults != null && result.InnerResults.Count > 0) { SpecificResult.RequestEndPointCapabilities = new List <RequestDataResult>(); foreach (var item in result.InnerResults) { if (item is RequestDataResult) { RequestDataResult res = (RequestDataResult)item; if (res && res.Command != null && res.Command.Length > 1 && res.Command[0] == COMMAND_CLASS_MULTI_CHANNEL_V4.ID) { if (res.Command[1] == COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_CAPABILITY_REPORT.ID) { COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_CAPABILITY_REPORT cmd = res.Command; if (_isIdentical) { SpecificResult.RequestEndPointCapabilities.Clear(); for (int i = 0; i < _endPoints; i++) { SpecificResult.RequestEndPointCapabilities.Add(res); } } else { SpecificResult.RequestEndPointCapabilities.Add(res); } } else if (res.Command[1] == COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_CMD_ENCAP.ID) { try { byte[] secureCC = null; COMMAND_CLASS_MULTI_CHANNEL_V4.MULTI_CHANNEL_CMD_ENCAP cmd = res.Command; if (cmd.commandClass == COMMAND_CLASS_SECURITY.ID && cmd.command == COMMAND_CLASS_SECURITY.SECURITY_COMMANDS_SUPPORTED_REPORT.ID) { COMMAND_CLASS_SECURITY.SECURITY_COMMANDS_SUPPORTED_REPORT supportedS0 = new[] { cmd.commandClass, cmd.command }.Concat(cmd.parameter).ToArray(); secureCC = supportedS0.commandClassSupport.TakeWhile(x => x != 0xEF).ToArray(); } else if (cmd.commandClass == COMMAND_CLASS_SECURITY_2.ID && cmd.command == COMMAND_CLASS_SECURITY_2.SECURITY_2_COMMANDS_SUPPORTED_REPORT.ID) { COMMAND_CLASS_SECURITY_2.SECURITY_2_COMMANDS_SUPPORTED_REPORT supportedS2 = new[] { cmd.commandClass, cmd.command }.Concat(cmd.parameter).ToArray(); secureCC = supportedS2.commandClass.TakeWhile(x => x != 0xEF).ToArray(); } if (_isIdentical) { for (int i = 0; i < _endPoints; i++) { _network.SetSecureCommandClasses(new NodeTag(NodeId, (byte)(i + 1)), secureCC); } } else { _network.SetSecureCommandClasses(new NodeTag(NodeId, cmd.properties1.sourceEndPoint), secureCC); } } catch { } } } } } } }
protected bool IsSupportedScheme(NetworkViewPoint network, byte[] command, SecuritySchemes scheme) { bool ret = false; if (command != null && command.Length > 0) { if (scheme == SecuritySchemes.NONE && !network.HasNetworkAwareCommandClass(command[0]) && network.HasSecurityScheme(SecuritySchemeSet.ALL)) { ret = !network.HasSecureCommandClass(command[0]); } else { ret = true; } } return(ret); }