internal ZclCommand(ZclCluster cluster, byte id, String name, bool specificResponseRequired) { m_cluster = cluster; m_Id = id; m_zigBeeStatus = ZclHelper.ZCL_ERROR_SUCCESS; // as far as ZigBeeCommand class is concerned a response will always be required // ZCL will use the Default Response if ZclCommand require no specific response m_responseRequired = true; if (specificResponseRequired) { m_useDefaultResponse = false; } else { m_useDefaultResponse = true; } this.Name = m_cluster.Name + "_" + name; this.Description = null; this.HResult = ZclHelper.ZigBeeStatusToHResult(m_zigBeeStatus); m_isZdoCommand = false; ZclHelper.SetClusterSpecificHeader(ref m_zclHeader, 0); int offset = ZclHelper.GetCommandIdOffset(ref m_zclHeader, 0); m_zclHeader[offset] = m_Id; m_zclInParamList = new List <ZclValue>(); InputParams = new List <IAdapterValue>(); OutputParams = new List <IAdapterValue>(); }
internal void Send() { // set cluster Id m_clusterId = m_cluster.Id; m_responseClusterId = m_cluster.Id; // add header to payload m_payload = new byte[m_zclHeader.Length]; Array.Copy(m_zclHeader, m_payload, m_zclHeader.Length); // add command parameters to payload foreach (var item in m_zclInParamList) { // copy in parameter data from "BridgeRT" in parameter to // "internal" ZCL parameter IAdapterValue value = GetInputParamByName(item.Name); item.Data = value.Data; // add parameter in ZCL payload byte[] tempBuffer = item.ToByteBuffer(); if (tempBuffer == null) { // can't set current parameter => give up with sending m_zigBeeStatus = ZclHelper.ZCL_ERROR_INVALID_VALUE; HResult = ZclHelper.ZigBeeStatusToHResult(m_zigBeeStatus); return; } int previousLength = m_payload.Length; Array.Resize(ref m_payload, previousLength + tempBuffer.Length); Array.Copy(tempBuffer, 0, m_payload, previousLength, tempBuffer.Length); } // send command m_zigBeeStatus = ZclHelper.ZCL_ERROR_SUCCESS; if (!SendCommand(m_cluster.EndPoint.Device.Module, m_cluster.EndPoint.Device, m_cluster.EndPoint)) { m_zigBeeStatus = ZclHelper.ZCL_ERROR_TIMEOUT; } HResult = ZclHelper.ZigBeeStatusToHResult(m_zigBeeStatus); return; }