/*
 * Copyright 1999-2023 Logitech, Inc.
 * All Rights Reserved
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

syntax = "proto3";

package logi.device.proto;

option java_package = "com.logitech.vc.proto";

import "device_common.proto";

/**
 * Kong as an Android device can accumulate
 * crash debug information during its operation.
 * When Kong is running in device mode, those
 * crash dump files need to be copied over to
 * PC and uploaded to S3.
 * Note, if Kong is running in host mode, uploaded
 *  files, and then moved to device mode, will it
 *  copy the same files over?
 *
 * This message requests that crash dump files be
 * copied over to PC
 *
 * EXPECTED RESPONSE
 * SendCrashDumpResponse
 *
 */
message SendCrashDumpRequest
{
	/**
	 * Unused. Reserved for future use.
	 */
	bool reserved = 1;
}

/**
 * Crash dump information.  Most of these
 * are supplied by the crash analytics service, so lets
 * pass this information along.
 */
message CrashDumpInfo
{
	/**
	 * the filename
	 */
	string file_name = 1;

	/**
	 * the serial number
	 */
	string device_id = 2;

	/**
	 * the software version
	 */
	string software_version = 3;

	/**
	 * the file size
	 */
	uint64 file_size = 4;

	/**
	 * timestamp
	 */
	uint64 timestamp = 5;

	/**
	 * md5 for file
	 */
	string md5 = 6;

	/**
	 * the device type .  Kong|Diddy
	 */
	string device_type = 7;

	/**
	 * the device mode.  Hosted|Appliance
	 */
	string device_mode = 8;

	/**
	 * the report type. BugReport|EventLog,Diagnostics
	 */
	string report_type = 9;

	/**
	 * the content type. application/zip | text/plain | application/json
	 */
	string content_type = 10;
}

/**
 * Response which contains the crash dump file name
 * information and bool value to indicate will send
 * file
 */
message SendCrashDumpResponse
{
	/**
	 * (OPTIONAL)
	 * If crash dump exists, this variable
	 * contains the file name of crash dump
	 * that will be copied over.
	 */
	string crash_dump_file = 1;

	/**
	 * (REQUIRED)
	 * bool value to indicate will send file
	 * true if sending file over.
	 * false if no file to send.
	 * If true, caller will look at CrashDumpInfo
	 */
	bool will_send_file = 2;

	/**
	 * (OPTIONAL)
	 * Crash dump info
	 */
	CrashDumpInfo crash_dump_info = 3;
}

message SendCrashDumpRequestv2
{
	/**
	 * The attestation challenge.
	 * (REQUIRED)
	 */
	string challenge = 1;

	/**
	 * Time to live
	 * (REQUIRED)
	 */
	int32 ttl = 2;
}

/**
 * Response which contains the crash dump file name
 * information, bool value to indicate will send
 * file, body of the request and signature
 */
message SendCrashDumpResponsev2
{
	/**
	 * (OPTIONAL)
	 * If crash dump exists, this variable
	 * contains the file name of crash dump
	 * that will be copied over.
	 */
	string crash_dump_file = 1;

	/**
	 * (REQUIRED)
	 * bool value to indicate will send file
	 * true if sending file over.
	 * false if no file to send.
	 * If true, caller will look at CrashDumpInfo
	 */
	bool will_send_file = 2;

	/**
	 * (OPTIONAL)
	 * The get upload url body.  This is a json string
	 */
	string body = 3;

	/**
	 * (OPTIONAL)
	 * The get upload url body signature.
	 */
	string signature = 4;
}

/**
 * This is event sent from PC or Kong to indicate
 *   Success
 */
message SendCrashDumpEvent
{
	/**
	 * (REQUIRED)
	 * Contains the file name of crash dump
	 * that is being sent or in process of being
	 * received
	 */
	string crash_dump_file = 1;

	/**
	 * (REQUIRED)
	 * Transfer state.
	 *  true indicates file was received without errors and bug report file was uploaded
	 *  false means an error occurred
	 */
	bool success = 2;
}

/**
 * Place holder for Android requesting that a crash dump copy
 * get initiated from PC side
 */
message CrashDumpAvailableEvent
{
	/**
	 * Unused. Reserved for future use.
	 */
	bool reserved = 1;
}

/**
 * Ask device to generate a bug report. This could be
 * for gathering logcat, system logs, etc.
 * Similar to SendCrashDumpRequestv2, but bug report generation is on
 * demand.
 * EXPECTED RESPONSE:
 * GenerateCrashDumpResponse
 * It should follow the same flow as described here
 * https://docs.google.com/document/d/1D5nx1nenDu9ucZbYPXlNNxFEN1tx3W7k044mvi74x28/edit#heading=h.a9wyfbpb2282
 */
message GenerateCrashDumpRequest
{
	/**
	 * The attestation challenge.
	 * (REQUIRED)
	 */
	string challenge = 1;

	/**
	 * Time to live
	 * (REQUIRED)
	 */
	int32 ttl = 2;

	/**
	 * The note to include in the bug report. This could be empty.
	 * (OPTIONAL)
	 */
	string note = 3;

	/**
	 * (OPTIONAL)
	 *  serial number of the intended recipient of the command.
	 *  If empty, the receiver should handle the command as the intended recipient. This also
	 * handles backward compatibility with older Sync app where serial number is not defined.
	 */
	string serial_number = 4;

	/**
	 * (OPTIONAL)
	 *  Request reference for connected devices. This could be empty for backwards
	 * compatibility.
	 */
	string request_ref = 5;
}

/**
 * Response which contains the
 * crash dump file name information,
 * bool value to indicate will send file,
 * body of the request and signature.
 * Similar to SendCrashDumpResponsev2, but bug report generation is on
 * demand.
 * It should follow the same flow as described here
 * https://docs.google.com/document/d/1D5nx1nenDu9ucZbYPXlNNxFEN1tx3W7k044mvi74x28/edit#heading=h.a9wyfbpb2282
 */
message GenerateCrashDumpResponse
{
	/**
	 * (OPTIONAL)
	 * If crash dump exists, this variable
	 * contains the file name of crash dump
	 * that will be copied over.
	 */
	string crash_dump_file = 1;

	/**
	 * (REQUIRED)
	 * bool value to indicate will send file
	 * true if sending file over.
	 * false if no file to send.
	 */
	bool will_send_file = 2;

	/**
	 * (OPTIONAL)
	 * The get upload url body.  This is a json string
	 */
	string body = 3;

	/**
	 * (OPTIONAL)
	 * The get upload url body signature.
	 */
	string signature = 4;
}

/**
 * Ask device to copy test result.
 * EXPECTED RESPONSE:
 * SendTestResultResponse
 */
message SendTestResultRequest
{
	/**
	 * Unused. Reserved for future use.
	 */
	bool reserved = 1;
}

/**
 * Test result response.
 */
message SendTestResultResponse
{
	/**
	 * (OPTIONAL)
	 * If test result file exists, this variable
	 * contains the file name
	 * that will be copied over.
	 */
	string test_result_file = 1;

	/**
	 * (REQUIRED)
	 * bool value to indicate will send file
	 * true if sending file over.
	 * false if no file to send.
	 */
	bool will_send_file = 2;
}

/**
 *  Device can use to notify Sync app to call
 *  GetMemfaultManifestRequest API with attestation...
 */
message InitiateMemfaultManifestRequestEvent
{
	/**
	 * Unused. Reserved for future use.
	 */
	bool reserved = 1;
}

/**
 * Request attested manifest from device to be used in retrieving memfault
 *  settings from futen.
 * This is to be included in UsbMsg.
 *
 * EXPECTED RESPONSE
 * GetMemfaultManifestResponse
 * Added 10/12/2022 EE
 */
message GetMemfaultManifestRequest
{
	/**
	 * The device serial number.
	 *  Reserve for future versions to indicate target device.
	 * (OPTIONAL)
	 */
	string serial = 1;

	/**
	 * The attestation challenge.
	 * (REQUIRED)
	 */
	string challenge = 2;

	/**
	 * Time to live
	 * (REQUIRED)
	 */
	int32 ttl = 3;

	/**
	 * Sender to provide in case of issue responding to initiate request
	 *   i.e  Sender is busy, firmware update in progress, etc.
	 */
	Error error = 4;
}

/**
 * GetMemfaultManifestRequest response.
 *  The device should send this message after receiving GetMemfaultManifestRequest.
 *  If the device encounters any issues, this message should be sent with the error field filled
 * out. An empty error field indicates success.
 */
message GetMemfaultManifestResponse
{
	/**
	 * The device serial number.
	 *  Reserve for future versions to indicate target device.
	 * (OPTIONAL)
	 */
	string serial = 1;
	/**
	 * The manifest body.  This is a json string
	 * (REQUIRED)
	 */
	string body = 2;

	/**
	 * The manifest body signature.
	 * (REQUIRED)
	 */
	string signature = 3;

	/**
	 * If any error are encountered while processing the request,
	 *   the device should respond with this error field.
	 * (OPTIONAL)
	 */
	Error error = 4;
}

/**
 * For sending memfault settings to device.
 *
 * EXPECTED RESPONSE
 * SendMemfaultSettingsResponse
 * Added 10/12/2022 EE
 */
message SendMemfaultSettingsRequest
{
	/**
	 * The device serial number.
	 *  Reserve for future versions to indicate target device.
	 * (OPTIONAL)
	 */
	string serial = 1;

	/**
	 * (REQUIRED)
	 * The memfault settings in bytes.
	 */
	bytes memfault_settings = 2;

	/**
	 * (REQUIRED)
	 * The memfault settings md5 hash
	 */
	string md5 = 3;
}

/**
 * Response to SendMemfaultSettingsRequest request.
 *  The device should send this message after receiving SendMemfaultSettingsRequest.
 *  If the device encounters any issues, this message should be sent with the error field filled
 * out. An empty error field indicates success.
 */
message SendMemfaultSettingsResponse
{
	/**
	 * If any error are encountered while processing the request,
	 *   the device should respond with this error field.
	 * (OPTIONAL)
	 */
	Error error = 1;
}
