/**
 * <p class=proto-main>This API notify the FOTA client of an update.  The FOTA client will manage downloading the update most likely through a different channel (https).</p>
 *
 * <div class=proto-hier>
 *   UconnectAny
 *     |
 *     |---- <a href="#com.fca.uconnect.global.FirmwareUpdateNotification">FirmwareUpdateNotification firmwareUpdateNotification (400)</a>
 *     |
 *     |---- <a href="#com.fca.uconnect.global.FirmwareUpdateResponse">FirmwareUpdateResponse firmwareUpdateResponse (401)</a>
 *
 * </div>
 *
 *  <h3 class=change-log-hdr> Change Log</h3>
 *  <table id="change-log" class="change-log"><thead><tr>
 *	<td>Version</td><td>Date</td><td>Notes</td></tr></thead>
 *   <tbody>
  *    <tr><td>1.2</td><td>2017-11-2</td><td>Update to Proto3</td></tr>	
 *	<tr><td>1.1</td><td>2017-09-27</td><td>Update response</td></tr>
 *	<tr><td>1.0</td><td>2017-03-29</td><td>Release of initial Proto</td></tr>
 *	</tbody></table>
 *
 *  <h3 class=change-log-hdr>List of MQTT Topics</h3>
 *  <table class="change-log"><thead><tr>
 *	<td>Flow</td><td>Type</td><td>Topic Name</td></tr></thead>
 *    <tbody>
 *   <tr><td>Cloud send to Vehicle</td><td>Publish</td><td>fcasdp/${iot:ClientId}/FOTA</td></tr>
 *	 <tr><td>Cloud receive from Vehicle</td><td>Subscribe</td><td>fcasdp/FOTA/#</td></tr>
 *	 <tr><td>Vehicle send to Cloud </td><td>Publish</td><td>fcasdp/FOTA/${iot:ClientId}</td></tr>
 *	 <tr><td>Vehicle receive from Cloud </td><td>Subscribe</td><td>fcasdp/${iot:ClientId}/#</td></tr>
 *	</tbody></table>
 * <h3 class=change-log-hdr>Data Flow</h3>
 *
 * <p class=proto-main>The following sequence diagram depicts the flow of messages between the TBM/HU and the SDP:</p>
 *
 * <img class=img-border src=./images/fota.png>
 *
 * <table class=sequence-table><thead><tr>
 *	<td>Sequence</td><td>Title</td><td>Role</td><td>Message</td><td>Topic</td><td>Description</td></tr></thead>
 *   <tbody>
 *  <tr><td>1.</td><td>Firmware Update Event</td><td>SDP</td><td></td><td></td><td><p>The FirmwareUpdate event which triggers the SDP device to send an FirmwareUpdate Notification to Client.</p></td></tr>
 * <tr><td>1.2.</td><td>Assign MessageId</td><td>SDP</td><td></td><td></td><td><p>The SDP generates the messageId for the message by incrementing a sequence counter.</p></td></tr>
 * <tr><td>2.</td><td>Send FirmwareUpdateNotification Message</td><td>SDP</td><td>FirmwareUpdateNotification</td><td>${iot:ClientId}/FOTA</td><td><p>The SDP populates the FirmwareUpdateNotification Message with the required elements and publishes to the FOTA topic.</p></td></tr>
 * <tr><td>3.1.</td><td>Process Message</td><td>TBM/HU</td><td></td><td></td><td><p>The Client process the message,verify the update and download it from URL and respond and generates an FirmwareUpdateResponse Message with the status .</p></td></tr>
 * <tr><td>3.2.</td><td>Assign correlationID</td><td>TBM/HU</td><td></td><td></td><td><p>Assign correct correlationId.</p></td></tr>
 * <tr><td>4.</td><td>Send FirmwareUpdateResponse Message</td><td>TBM/HU</td><td>FirmwareUpdateResponse</td><td>/FOTA/${iot:ClientId}</td><td><p>The Client publishes the response message to the FOTA topic for the SDP to receive.</p></td></tr>
 * <tr><td>5.1</td><td>Process Message</td><td>SDP</td><td></td><td></td><td><p>The SDP receives the message and verifies if correlationId is correct.</p></td></tr>
 * <tr><td>5.2</td><td>Assign CorrelationID</td><td>TBM/HU</td><td></td><td></td><td><p>Assign correct correlationId.</p></td></tr>
 * <tr><td>6.1</td><td>send AckMessage</td><td>SDP</td><td>AckMessage</td><td>/FOTA/${iot:ClientId}</td><td><p>The SDP sends AckMessage to acknowledge that it received FirmwareUpdateResponse.</p></td></tr>
 * <tr><td>6.2</td><td>Process AckMessage</td><td>TBM/HU</td><td></td><td></td><td><p>The client process AckMessage.</p></td></tr>
 * </tbody>
 * </tbody>
 * </table>
 */
syntax="proto3";
package com.fca.uconnect.global;


// import public "Global_Uconnect_Control.proto";
/**
 * This message is to Push the Firmware to Client when there is an update available.
 * <div class=exmsg-main>
 * <h4>FirmwareUpdateNotification Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 * 		timestamp: 1490885867532
 * 		messageId: 11
 * 		messages
 * 		{
 * 		 [com.fca.uconnect.global.firmwareUpdateNotification]
 * 		 {
 * 		  firmwareDescriptor
 * 		  {
 * 			firmwareVersion: "2.0"
 * 			ecuAddress: 956488
 * 			description: "Update for ABC"
 * 			expireDate: 360000
 * 			packageSize: 10000
 * 			url: "https://abc.com"
 * 			checksum: "CE114E4501D2F4E2DCEA3E17B546F339"
 *  	  }
 * 		  fotaTaskId: "AXCSEA1234"
 * 		 }
 * 		}
 *	</code>
 *   </div>
 * </div>
 */
message FirmwareUpdateNotification {
	message FirmwareDescriptor{
	enum FirmwareType{
		MAPDB=0; /// Map update
		HUHMI=1; /// Head Unit HMI
		OS=2; /// Operating System Patch
		HARDWARE_DRIVER=3; /// Hardware Driver
		CALIBRATION = 4; /// Calibration
		CODING = 5; /// Application Code
	}
	 string firmwareVersion = 1;///Version of the Firmware that needs to be download.
	 int32 ecuAddress  		= 2;/// Diagnostic ECU ID.
	 string description 	= 3;/// Description of the firmware update - This field is mandatory for Red Bend Clients
	 string token 			= 4;///Token which will be sent to download server to download the Firmware.
	 int64  expireDate		= 5;///Time till when the Software is available for update.
	 int32  packageSize		= 6;///Size of the Firmware update.
	 string url 			= 7;///URL to download the firmware update.
	 string checksum		= 8;///Checksum of the FW package is to ensure integrity of downloading.
	 FirmwareType firmwareType = 9;
	}
	 repeated FirmwareDescriptor firmwareDescriptor = 1; /// Firmware Descriptor
	  string 			 fotaTaskId		= 2; /// FOTA Task ID
	 }

/**
 * This message is to respond to SDP after Client installs Firmware Updates.
 *<div class=exmsg-main>
 * <h4>FirmwareUpdateResponse Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 * 		timestamp: 1490885867676
 * 		messageId: 1
 * 		correlationId: 11
 * 		messages
 * 		{
 * 		 [com.fca.uconnect.global.firmwareUpdateResponse]
 * 		 {
 * 			responseEnum: SUCCESS
 * 		 }
 * 		}
 *	</code>
 *   </div></div>
 */
message FirmwareUpdateResponse {

 enum ResponseEnum {
			SUCCESS = 0;///Received the Notification.
			DOWNLOAD_FAILED = 1;///Downaload Failed from Download server.
			CHECKSUM_FAILED = 2;///CheckSum Failed while calculating.
			DECRYPTION_FAILED = 3; /// Decryption Failure
			UPTODATE = 4;/// This Firmware update is already installed.
		}
		 ResponseEnum response = 1; /// Indicator for the status of the FirmwareUpdate.
		 bool isTransient = 2; /// Indicates a transient error and a retry can be attempted.
		 int32 failureReasonCode = 3; /// Specific error code.
}

// extend UconnectAny{
	 // FirmwareUpdateNotification firmwareUpdateNotification=400;
	 // FirmwareUpdateResponse firmwareUpdateResponse=401;
	 // AckMessage fotaAckMessage=402;
// }

