package com.fca.uconnect.global;
/**
 * <p class=proto-main>The  proto is utilized to establish Tunnel Connection and stop Connection.</p>
 *
 * <div class=proto-hier>
 * <a href="#com.fca.uconnect.global.EstablishRemoteConnection">EstablishRemoteConnection </a>
 *
 * <a href="#com.fca.uconnect.global.EndConnection">EndConnection</a>
 *
 * <a href="#com.fca.uconnect.global.EstablishAcknowledgement">EstablishAcknowledgement </a>
 *
 * </div>
 *
 *  <h3 class=change-log-hdr> Change Log</h3>
 *  <table id="change-log" class="change-log"><thead><tr>
 *	<th>Version</th><th>Date</th><th>Notes</th></tr></thead>
 *   <tbody>
 *	<tr><td>1.0</td><td>2017-07-13</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>BIMD send to Vehicle</td><td>Publish</td><td>topic/${iot:ClientId}/CONN</td></tr>
 *	 <tr><td>BIMD receive from Vehicle</td><td>Subscribe</td><td>topic/CONN/#</td></tr>
 *	 <tr><td>Vehicle send to BIMD </td><td>Publish</td><td>topic/CONN/${iot:ClientId}</td></tr>
 *	 <tr><td>Vehicle receive from BIMD </td><td>Subscribe</td><td>topic/${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 BIMD:</p>
 *
 * <img class=img-border src=./images/comm_control.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>Connection Event</td><td>TBM/HU</td><td></td><td></td><td><p>The in-vehicle Connection event which triggers the client device to send an EstablishConnection message  to the BIMD.</p></td></tr>
 * <tr><td>2.</td><td>Assign MessageId</td><td>TBM/HU</td><td></td><td></td><td><p>The client generates the messageId for the message by incrementing a sequence counter.</p></td></tr>
 * <tr><td>3.</td><td>Send EstablishRemoteConnection Message</td><td>TBM/HU</td><td>EstablishRemoteConnection</td><td>/CONN/${iot:ClientId}</td><td><p>The client populates the EstablishRemoteConnection Message with the required elements and publishes to the Connection topic.</p></td></tr>
 * <tr><td>4.</td><td>Process Message</td><td>BIMD</td><td></td><td></td><td><p>The BIMD processes the message and generates an EstablishAcknowledgement Message with the status and the correlationId set to the messageId from the received EstablishRemoteConnection Message.</p></td></tr>
 * <tr><td>5.</td><td>Send EstablishAcknowledgement Message</td><td>BIMD</td><td>EstablishAcknowledgement</td><td>${iot:ClientId}/CONN</td><td><p>The service publishes the response message to the Connection topic for the client to receive.</p></td></tr>
 * <tr><td>6.</td><td>Process Message</td><td>TBM/HU</td><td></td><td></td><td><p>The client receives the message and verifies the correlationId matches the messageId of the sent request.</p></td></tr>
 * <tr><td>8.</td><td>Send EndConnection Message</td><td>TBM/HU</td><td><p>EndConnection</td><td>${iot:ClientId}/CONN</td><td>The Client publishes the EndConnection message to stop the Connection to  the Connection topic for the BIMD to receive.</p></td></tr>
 * <tr><td>9.</td><td>Process Message</td><td>TBM/HU</td><td></td><td></td><td><p>The BIMD receives the message and verifies the correlationId matches the messageId of the initially sent request and stops the  connection.</p></td></tr>
 * </tbody>
 * </table>
 */
import "Global_V2M_Uconnect_Common.proto";
/**
 * This message is to establish Tunnel Connection from V2M.
 * <div class=exmsg-main>
 * <h4>EstablishRemoteConnection Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 * 		timestamp: 1488574019636
 * 		messageId: 1
 * 		messages
 * 	    {
 * 		 [com.fca.uconnect.global.establishRemoteConnection]
 * 		 {
 * 			connectionId: 123456
 * 			host: "host"
 * 			port: 8080
 * 			priority: 1
 * 		 }
 * 		}
 *	</code>
 *   </div>
 * </div>
 */
message EstablishRemoteConnection {
	optional int32	connectionId = 1;
	optional string	host = 2;
	optional int32 port = 3;
	optional int32 priority = 4;
	map<string,string> parameters = 5;
}
/**
 * This message is to end the Tunnel Connection.
 * <div class=exmsg-main>
 * <h4>EndConnection Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 * 		timestamp: 1488574019636
 * 		messageId: 1
 * 		messages
 * 	    {
 * 		 [com.fca.uconnect.global.endConnection]
 * 		 {
 * 			connectionId: 123456
 * 		 }
 * 		}
 *	</code>
 *   </div>
 * </div>
 */
message EndConnection {
	optional int32	connectionId = 1;
}
/**
 * This message is to Acknowledge the Connection Establishment.
 * <div class=exmsg-main>
 * <h4>EstablishAcknowledgement Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 * 		timestamp: 1488574019636
 * 		messageId: 2
 *      correlationId: 1
 * 		messages
 * 	    {
 * 		 [com.fca.uconnect.global.establishAcknowledgement]
 * 		 {
 * 			status: SUCCESS
 * 		 }
 * 		}
 *	</code>
 *   </div>
 * </div>
 */
message EstablishAcknowledgement {
	enum StatusEnum {
		SUCCESS = 0;
		FAILED = 1;
	}
	enum ReasonEnum {
		FAILED = 0;
		INVALID_PORT = 1;
		PORT_ALREADY_IN_USE = 2;
		INVALID_HOST = 3;
		INVALID_PRIORITY = 4;
	}
	optional StatusEnum status = 1;
	optional ReasonEnum reason = 2;
}


extend UconnectAnyV2M {
		optional EstablishRemoteConnection establishRemoteConnection = 2000;
		optional EndConnection endRemoteConnection = 2010;
		optional EstablishAcknowledgement establishAck = 2020;
}
