"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var DiagnosticLogs_exports = {};
__export(DiagnosticLogs_exports, {
  DiagnosticLogs: () => DiagnosticLogs
});
module.exports = __toCommonJS(DiagnosticLogs_exports);
var import_MatterDefinition = require("../MatterDefinition.js");
var import_elements = require("../../elements/index.js");
/**
 * @license
 * Copyright 2022-2024 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
const DiagnosticLogs = (0, import_elements.ClusterElement)({
  name: "DiagnosticLogs",
  id: 50,
  classification: "node",
  pics: "DLOG",
  details: "This Cluster supports an interface to a Node. It provides commands for retrieving unstructured diagnostic logs from a Node that may be used to aid in diagnostics. It will often be the case that unstructured diagnostic logs will be Node-wide and not specific to any subset of Endpoints. When present, this Cluster shall be implemented once for the Node. The Node SHOULD also implement the BDX Initiator and BDX Sender roles as defined in the BDX Protocol.",
  xref: { document: "core", section: "11.11" },
  children: [
    (0, import_elements.AttributeElement)({ name: "ClusterRevision", id: 65533, type: "ClusterRevision", default: 1 }),
    (0, import_elements.CommandElement)({
      name: "RetrieveLogsRequest",
      id: 0,
      access: "O",
      conformance: "M",
      direction: "request",
      response: "RetrieveLogsResponse",
      details: "Reception of this command starts the process of retrieving diagnostic logs from a Node.",
      xref: { document: "core", section: "11.11.5.1" },
      children: [
        (0, import_elements.FieldElement)({
          name: "Intent",
          id: 0,
          type: "IntentEnum",
          conformance: "M",
          details: "This field shall indicate why the diagnostic logs are being retrieved from the Node. A Node may utilize this field to selectively determine the logs to transfer.",
          xref: { document: "core", section: "11.11.5.1.1" }
        }),
        (0, import_elements.FieldElement)({
          name: "RequestedProtocol",
          id: 1,
          type: "TransferProtocolEnum",
          conformance: "M",
          details: "This field shall be used to indicate how the log transfer is to be realized. If the field is set to BDX, then if the receiving Node supports BDX it shall attempt to use BDX to transfer any potential diagnostic logs; if the receiving Node does not support BDX then the Node shall follow the requirements defined for a TransferProtocolEnum of ResponsePayload. If this field is set to ResponsePayload the receiving Node shall only utilize the LogContent field of the RetrieveLogsResponse command to transfer diagnostic log information.",
          xref: { document: "core", section: "11.11.5.1.2" }
        }),
        (0, import_elements.FieldElement)({
          name: "TransferFileDesignator",
          id: 2,
          type: "string",
          conformance: "O",
          constraint: "max 32",
          details: "This field shall be present if the RequestedProtocol is BDX. The TransferFileDesignator shall be set as the File Designator of the BDX transfer if initiated.\nEffect on Receipt\nOn receipt of this command, the Node shall respond with a RetrieveLogsResponse command.\nIf the RequestedProtocol is set to BDX the Node SHOULD immediately realize the RetrieveLogsResponse command by initiating a BDX Transfer, sending a BDX SendInit message with the File Designator field of the message set to the value of the TransferFileDesignator field of the RetrieveLogsRequest. On reception of a BDX SendAccept message the Node shall send a RetrieveLogsResponse command with a Status field set to Success and proceed with the log transfer over BDX. If a failure StatusReport is received in response to the SendInit message, the Node shall send a RetrieveLogsResponse command with a Status of Denied. In the case where the Node is able to fit the entirety of the requested logs within the LogContent field, the Status field of the RetrieveLogsResponse shall be set to Exhausted and a BDX session shall NOT be initiated.\nIf the RequestedProtocol is set to BDX and either the Node does not support BDX or it is not possible for the Node to establish a BDX session, then the Node shall utilize the LogContent field of the RetrieveLogsResponse command to transfer as much of the current logs as it can fit within the response, and the Status field of the RetrieveLogsResponse shall be set to Exhausted.\nIf the RequestedProtocol is set to ResponsePayload the Node shall utilize the LogContent field of the RetrieveLogsResponse command to transfer as much of the current logs as it can fit within the response, and a BDX session shall NOT be initiated.\nIf the RequestedProtocol is set to BDX and there is no TransferFileDesignator the command shall fail with a Status Code of INVALID_COMMAND.\nIf the Intent and/or the RequestedProtocol arguments contain invalid (out of range) values the command shall fail with a Status Code of INVALID_COMMAND.",
          xref: { document: "core", section: "11.11.5.1.3" }
        })
      ]
    }),
    (0, import_elements.CommandElement)({
      name: "RetrieveLogsResponse",
      id: 1,
      conformance: "M",
      direction: "response",
      details: "This shall be generated as a response to the RetrieveLogsRequest. The data for this command is shown in the following.",
      xref: { document: "core", section: "11.11.5.2" },
      children: [
        (0, import_elements.FieldElement)({
          name: "Status",
          id: 0,
          type: "StatusEnum",
          conformance: "M",
          details: "This field shall indicate the result of an attempt to retrieve diagnostic logs.",
          xref: { document: "core", section: "11.11.5.2.1" }
        }),
        (0, import_elements.FieldElement)({
          name: "LogContent",
          id: 1,
          type: "octstr",
          conformance: "M",
          constraint: "max 1024",
          details: "This field shall be included in the command if the Status field has a value of Success or Exhausted. A Node SHOULD utilize this field to transfer the newest diagnostic log entries. This field shall be empty if BDX is requested and the Status field has a value of Success.",
          xref: { document: "core", section: "11.11.5.2.2" }
        }),
        (0, import_elements.FieldElement)({
          name: "UtcTimeStamp",
          id: 2,
          type: "epoch-us",
          conformance: "O",
          details: "This field SHOULD be included in the command if the Status field has a value of Success and the Node maintains a wall clock. When included, the UTCTimeStamp field shall contain the value of the oldest log entry in the diagnostic logs that are being transferred.",
          xref: { document: "core", section: "11.11.5.2.3" }
        }),
        (0, import_elements.FieldElement)({
          name: "TimeSinceBoot",
          id: 3,
          type: "systime-us",
          conformance: "O",
          details: "This field SHOULD be included in the command if the Status field has a value of Success. When included, the TimeSinceBoot field shall contain the time of the oldest log entry in the diagnostic logs that are being transferred represented by the number of microseconds since the last time the Node went through a reboot.",
          xref: { document: "core", section: "11.11.5.2.4" }
        })
      ]
    }),
    (0, import_elements.DatatypeElement)({
      name: "IntentEnum",
      type: "enum8",
      xref: { document: "core", section: "11.11.4.1" },
      children: [
        (0, import_elements.FieldElement)({
          name: "EndUserSupport",
          id: 0,
          conformance: "M",
          description: "Logs to be used for end- user support",
          details: "shall indicate that the purpose of the log request is to retrieve logs for the intention of providing support to an end-user.",
          xref: { document: "core", section: "11.11.4.1.1" }
        }),
        (0, import_elements.FieldElement)({
          name: "NetworkDiag",
          id: 1,
          conformance: "M",
          description: "Logs to be used for network diagnostics",
          details: "shall indicate that the purpose of the log request is to diagnose the network(s) for which the Node is currently commissioned (and/or connected) or has previously been commissioned (and/or connected).",
          xref: { document: "core", section: "11.11.4.1.2" }
        }),
        (0, import_elements.FieldElement)({
          name: "CrashLogs",
          id: 2,
          conformance: "M",
          description: "Obtain crash logs from the Node",
          details: "shall indicate that the purpose of the log request is to retrieve any crash logs that may be present on a Node.",
          xref: { document: "core", section: "11.11.4.1.3" }
        })
      ]
    }),
    (0, import_elements.DatatypeElement)({
      name: "StatusEnum",
      type: "enum8",
      xref: { document: "core", section: "11.11.4.2" },
      children: [
        (0, import_elements.FieldElement)({
          name: "Success",
          id: 0,
          conformance: "M",
          description: "Successful transfer of logs",
          details: "shall be used if diagnostic logs will be or are being transferred.",
          xref: { document: "core", section: "11.11.4.2.1" }
        }),
        (0, import_elements.FieldElement)({
          name: "Exhausted",
          id: 1,
          conformance: "M",
          description: "All logs has been transferred",
          details: "shall be used when a BDX session is requested, however, all available logs were provided in a LogContent field.",
          xref: { document: "core", section: "11.11.4.2.2" }
        }),
        (0, import_elements.FieldElement)({
          name: "NoLogs",
          id: 2,
          conformance: "M",
          description: "No logs of the requested type available",
          details: "shall be used if the Node does not currently have any diagnostic logs of the requested type (Intent) to transfer.",
          xref: { document: "core", section: "11.11.4.2.3" }
        }),
        (0, import_elements.FieldElement)({
          name: "Busy",
          id: 3,
          conformance: "M",
          description: "Unable to handle request, retry later",
          details: "shall be used if the Node is unable to handle the request (e.g. in the process of another transfer) and the Client SHOULD re-attempt the request later.",
          xref: { document: "core", section: "11.11.4.2.4" }
        }),
        (0, import_elements.FieldElement)({
          name: "Denied",
          id: 4,
          conformance: "M",
          description: "The request is denied, no logs being transferred",
          details: "shall be used if the Node is denying the current transfer of diagnostic logs for any reason.",
          xref: { document: "core", section: "11.11.4.2.5" }
        })
      ]
    }),
    (0, import_elements.DatatypeElement)({
      name: "TransferProtocolEnum",
      type: "enum8",
      xref: { document: "core", section: "11.11.4.3" },
      children: [
        (0, import_elements.FieldElement)({
          name: "ResponsePayload",
          id: 0,
          conformance: "M",
          description: "Logs to be returned as a response",
          details: "shall be used by a Client to request that logs are transferred using the LogContent attribute of the response",
          xref: { document: "core", section: "11.11.4.3.1" }
        }),
        (0, import_elements.FieldElement)({
          name: "Bdx",
          id: 1,
          conformance: "M",
          description: "Logs to be returned using BDX",
          details: "shall be used by a Client to request that logs are transferred using BDX as defined in BDX Protocol",
          xref: { document: "core", section: "11.11.4.3.2" }
        })
      ]
    })
  ]
});
import_MatterDefinition.MatterDefinition.children.push(DiagnosticLogs);
//# sourceMappingURL=DiagnosticLogs.js.map
