 /**
 * <p class=proto-main>This is to define Emergency Call.When ECall is triggered, Phone call will be dialed out to the call center.The operator may expect to see the vehicle related information when the phone call is connected. Client  gathers vehicle information and send it out.
 * Before the phone call is connected, the user also has the chance to cancel the Ecall.</p>
 *
 * <div class=proto-hier>
 * 	 UconnectAny
 * 	   |
 * 	   |---- <a href="#com.fca.uconnect.global.ECallDataUpload">ECallDataUpload ecallDataUpload (160)</a>
 * 	   |
 * 	   |---- <a href="#com.fca.uconnect.global.ECallStatusUpdate">ECallStatusUpdate ecallStatusUpdate (161)</a>
 * 	   |
 * 	   |---- <a href="#com.fca.uconnect.global.ECallVehDataRequest">ECallVehDataRequest ecallVehDataRequest (162)</a>
 * 	   |
 * 	   |---- <a href="#com.fca.uconnect.global.ECallVehDataResponse">ECallVehDataResponse ecallVehDataResponse (163)</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>2.0</td><td>2018-06-19</td><td>Added UpdateECallPhoneNumbers</td></tr>
 * <tr><td>1.9</td><td>2017-05-12</td><td>Sequence Diagram and Documentation Updates</td></tr>
 *  <tr><td>1.8</td><td>2017-11-2</td><td>Update to Proto3</td></tr>
 *  <tr><td>1.7</td><td>2017-09-27</td><td>Add response to return error code.</td></tr>
 *  <tr><td>1.6</td><td>2017-09-20</td><td>Added ACK Message and additional Enum fields to EcallStatus.</td></tr>
 *  <tr><td>1.5</td><td>2017-07-07</td><td>Call Status is added to EcallVehDataRequest.</td></tr>
 *  <tr><td>1.4</td><td>2017-06-30</td><td>Added new fields like trigger mode,Device.</td></tr>
 *  <tr><td>1.3</td><td>2017-04-19</td><td>Moved VehicleInfo to UConnectCommon.</td></tr>
 *  <tr><td>1.2</td><td>2017-04-18</td><td>Moved  key value for status of each door/window/hood/trunk.</td></tr>
 *  <tr><td>1.1</td><td>2017-04-12</td><td>Removed isTestCall,fuelRemaining,TyrePressure,VIN & isPositionTrusted and added odometer,language,country and estimatedHeadingError .</td></tr>
 *	<tr><td>1.0</td><td>2017-03-09</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}/ECAL</td></tr>
 *	 <tr><td>Cloud receive from Vehicle</td><td>Subscribe</td><td>fcasdp/ECAL/#</td></tr>
 *	 <tr><td>Vehicle send to Cloud </td><td>Publish</td><td>fcasdp/ECAL/${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>The following sequence diagram depicts the flow of messages between the TBM and the SDP:</p>
 *
 * <img class=img-border src=./images/ecall.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>ECALL Event</td><td>TBM</td><td></td><td></td><td><p>The in-vehicle ECALL event which triggers the client device to send an ECALLDATA to the SDP.</p></td></tr>
 * <tr><td>2.</td><td>Assign MessageId</td><td>TBM</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 ECallDataUpload Message</td><td>TBM</td><td>ECallDataUpload</td><td>/ECAL/${iot:ClientId}</td><td><p>The client populates the ECallDataUpload Message with the required elements and publishes to the ECAL topic.</p></td></tr>
 * <tr><td>4.1</td><td>Process Message</td><td>SDP</td><td></td><td></td><td><p>The SDP processes the message and waits for call through ECallStatusUpdate.</p></td></tr>
 * <tr><td>4.2.</td><td>Assign correlationID</td><td>SDP</td><td></td><td></td><td><p>Assign correct correlationId.</p></td></tr>
 * <tr><td>5</td><td>send AckMessage</td><td>SDP</td><td>AckMessage</td><td>/ECAL/${iot:ClientId}</td><td><p>The SDP sends AckMessage to acknowledge that it received ECallDataUpload Message.</p></td></tr>
 * <tr><td>6</td><td>Process AckMessage</td><td>TBM</td><td></td><td></td><td><p>The client process AckMessage.</p></td></tr>
 * <tr><td></td><td>opt</td><td></td><td></td><td></td><td><p>step 5 is opt means The interaction operator opt means that the combined fragment represents a choice of behavior where either the (sole) operand happens or nothing happens. </p></td></tr>
 * <tr><td>7.</td><td>Send ECallStatusUpdate message<td>TBM</td><td>ECallStatusUpdate</td><td>/ECAL/${iot:ClientId}</td><td><p>The client populates the ECallStatusUpdate Message with the required elements and publishes to the ECAL topic.</p></td></tr>
 * <tr><td>8.1</td><td>Process Message</td><td>SDP</td><td></td><td></td><td><p>The SDP processes the message.</p></td></tr>
 * <tr><td>8.2.</td><td>Assign correlationID</td><td>SDP</td><td></td><td></td><td><p>Assign correct correlationId.</p></td></tr>
 * <tr><td>9.</td><td>send AckMessage</td><td>SDP</td><td>AckMessage</td><td>/ECAL/${iot:ClientId}</td><td><p>The SDP sends AckMessage to acknowledge that it received ECallStatusUpdate Message.</p></td></tr>
 * <tr><td>10.</td><td>Process AckMessage</td><td>TBM</td><td></td><td></td><td><p>The client process AckMessage.</p></td></tr>
 * <tr><td>11.</td><td>ECall Data Query Event</td><td>SDP</td><td></td><td></td><td><p>The SDP can continuously request client for Ecall Data through EcallVehDataRequest.</p></td></tr>
 * <tr><td></td><td>loop</td><td></td><td></td><td></td><td><p>step 11 to 15 are in loop means the interaction operator loop means that the combined fragment represents a loop. The loop operand will be repeated a number of times. The loop construct represents a recursive application of the seq operator where
 * 															   the loop operand is sequenced after the result of earlier iterations.</p></td></tr>
 * <tr><td>12.</td><td>Send ECallVehDataRequest Message</td><td>SDP</td><td>ECallVehDataRequest</td><td>${iot:ClientId}/ECAL</td><td><p>The SDP publishes the ECALLVehDataRequest with NOT_TERMINATED enum and publishes to the ECAL topic for the client to receive.</p></td></tr>
 * <tr><td>13.</td><td>Process Message</td><td>TBM</td><td></td><td></td><td><p>The client receives the message .</p></td></tr>
 * <tr><td>14.</td><td>Send ECallVehDataResponse Message</td><td>TBM</td><td><p>ECallVehDataResponse</td><td>${iot:ClientId}/ECAL</td><td>The Client populates the ECallVehDataResponse message to the ECAL topic for the client to receive.</p></td></tr>
 * <tr><td>15.</td><td>Process Message</td><td>SDP</td><td></td><td></td><td><p>The SDP receives the message and verifies the data and proceed accordingly.</p></td></tr>
 * <tr><td>16.</td><td>Send ECallStatusUpdate message<td>SDP</td><td>ECallStatusUpdate</td><td>${iot:ClientId}/ECAL</td><td><p>The SDP populates the ECallStatusUpdate Message with the Call status as Terminated and publishes to the ECAL topic.</p></td></tr>
 * <tr><td>17.</td><td>Process Message</td><td>TBM</td><td></td><td></td><td><p>The Client processes the message and Acknowledges that Call is Terminated.</p></td></tr>
 * <tr><td>18.</td><td>Send ECallVehDataRequest Message</td><td>SDP</td><td>ECallVehDataRequest</td><td>${iot:ClientId}/ECAL</td><td><p>The SDP publishes the ECALLVehDataRequest with TERMINATED enum to mention that this is the last request for data after the call is terminated and publishes to the ECAL topic for the client to receive .</p></td></tr>
 * <tr><td>19.</td><td>Process Message</td><td>TBM</td><td></td><td></td><td><p>The client process the message .</p></td></tr>
 * <tr><td>20.</td><td>Send ECallVehDataResponse Message</td><td>TBM</td><td><p>ECallVehDataResponse</td><td>${iot:ClientId}/ECAL</td><td>The Client populates the ECallVehDataResponse message to the ECAL topic for the client to receive.</p></td></tr>
 * <tr><td>21.</td><td>Process Message</td><td>SDP</td><td></td><td></td><td><p>The SDP receives the message and verifies the data and proceed accordingly.</p></td></tr>
 * </tbody>
 * </table>
 */
 
 syntax="proto3";
package com.fca.uconnect.global;


// import public "Global_Uconnect_Control.proto";
import public "Global_Uconnect_GNSS.proto";
import public "Global_Uconnect_VehicleInfo.proto";
import public "Global_Uconnect_Device.proto";
import public "Global_Uconnect_Ext_SQDF.proto";
/**
 * This message represents  ECall DataUpload for emergencies and accidents.
 * <div class=exmsg-main>
 * <h4>ECallDataUpload Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 *		timestamp: 1489600238258
 * 		messageId: 1
 * 		messages
 * 		{
 * 		 [com.fca.uconnect.global.ecallDataUpload]
 * 		 {
 * 		  vehicleId: "1234AXFGFGHGH4566"
 * 		  isPositionTrusted: true
 * 		  timeStamp: 1489600238256
 * 		  vehicleLocation
 * 		  {
 * 			longitude: 43.9999
 * 			latitude: -84.54636
 * 		  }
 * 		 numberOfPassengers: 1
 * 		 airBagStatus
 * 		 {
 * 		  driver: false
 * 		  driverKnee: false
 * 		  passenger: false
 * 		  passengerKnee: false
 * 		  leftSideCurtain: false
 * 		  leftSeat: false
 * 		  rightSeat: false
 * 		}
 * 		  vehicleSpeed: 75.0
 * 		  engineStatus: STOP
 * 	    }
 * 	  }
 *	</code>
 *   </div>
 * </div>
 */
message ECallDataUpload {
	  VehicleInfo vehicleInfo = 1;/// This message is to get the Vehicle Information.
	  VehicleData vehicleData = 12; /// Get Vehicle Health Data
	  int64    timeStamp=2;///The milliseconds since Jan 1, 1970 00:00:00 UTC when the message is created. Should come from the system clock of the sender.
	  int32 numberOfPassengers=4;/// This represents number of passengers present in the Veh.
	  AirBagStatus airBagStatus = 5;///This represents whether airbags are deployed or not.
	  SeatState seatOccupied=6;///This represents which seats are occupied in the vehicle.
	  SeatState beltBuckled=7;///This represents which seat belts are buckled.
	  VehicleStatus vehicleStatus = 8;///Status of each door/window/hood/trunk.
	  TriggerModeEnum triggerMode = 9;///Trigger mode of the data upload.
	  Device deviceDetails = 10; /// Device Identification Details.
	  CrashDetectedEnum crashDetected =11; /// Crash Detected CanImpactEven toggle bit
	  repeated CrashDetection crashDetails = 13;
	 enum TriggerModeEnum{
		MANUAL = 0;
		AUTOMATIC = 1;
	 }
	  enum CrashDetectedEnum {
		NO = 0;
		YES = 1;
	 }
	message AirBagStatus{
		 bool isDriver=1; /// Identifies as the main Driver Airbag
		 bool isDriverKnee=2; /// Identifies as the Driver Knee Airbag
		 bool isPassenger=3; /// Identifies as the main Passenger Airbag
		 bool isPassengerKnee=4; /// Identifies as the Passenger Knee Airbag
		 bool isLeftSideCurtain=5; /// Identifies as the Left Side Curtain Airbag
		 bool isRightSideCurtain=6; /// Identifies as the Right Side Curtain Airbag
		 bool isLeftSeat=7; /// Identifies as the Left Seat Airbag
		 bool isRightSeat=8; /// Identifies as the Right Seat Airbag
	}
	message SeatState{
		 bool isFrontLeft=1;///identifies whether Front Left Seat Occupied.
		 bool isFrontRight=2;///identifies whether Front Right Seat Occupied.
		 bool isRearLeft=3;///identifies whether Rear Left Seat Occupied.
		 bool isRearRight=4;///identifies whether Rear Right Seat Occupied.
		 bool isRearMiddle=5;///identifies whether Rear Middle Seat Occupied.
		 bool isTailLeft=6;///identifies whether Tail Left Seat Occupied.
		 bool isTailRight=7;///identifies whether Tail RightSeat Occupied.
	}

	message CrashDetection{
		 bool isFrontPreTension=1;/// Front Pretention Event .
		 bool isEarsRear=2;/// Rear EARs event.
		 bool isHighSevFront=3;/// High Severity Front Event.
		 bool isSideEvent=4;/// Side Impact Event.
		 bool isRearEvent=5;/// Rear Impact Event.
		 bool isLowSevFront=6;/// Low Severity Front Event.
		 bool isNonEarRoll=7;/// Non-Ears Roll-over Event.
		 bool isEarRoll=8;/// EARs roll-over event.
		 bool isLeftSideEvent=9;/// Left Side Event.
		 bool isSideEvent2= 10;/// Side Event[5]
		 bool isRightSideEvent=11;/// Right Side Event.
		 bool isPedestrianCrash=12;/// Pedestrian Crash Event.
		 bool isUknownType=13;/// General Event Indicator.
	}
}

/**
 * This message is to update the status of the call.
 *<div class=exmsg-main>
 * <h4>ECallStatusUpdate Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 *		timestamp: 1489600243281
 * 		messageId: 2
 * 		messages
 * 		{
 * 		 [com.fca.uconnect.global.ecallStatusUpdate]
 * 		 {
 * 		  ecallStatusEnum: DIAL
 * 		 }
 * 		}
 *	</code>
 *   </div></div>
 */
message ECallStatusUpdate {
	 ECallStatusEnum ecallStatusEnum = 1;
	enum ECallStatusEnum{
		DIAL=0; /// Dialing
		CANCELLED=1;///This represents the call is cancelled.
		TERMINATED=2;///This represents the call is terminated.
		DROPPED_CALL = 3;///This is sent when TBM detects dropped call without a terminate tone.
		CALL_FAILED = 4;///This is sent when TBM fails to Establish CALL.
		ATTEMPT_FAILED = 5; /// Sent during retry when call connection fails to be established.
	}
}
/**
 * This message is to request Veh data from Client and it has no elements.
 * <div class=exmsg-main>
 * <h4>ECallVehDataRequest Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 *		timestamp: 1489600243281
 * 		messageId: 1
 * 		messages
 * 		{
 * 		 [com.fca.uconnect.global.ecallVehDataRequest]
 * 		 {
 * 			callStatus:TERMINATED
 * 		 }
 * 		}
 *	</code>
 *   </div></div>
 */
message ECallVehDataRequest{
	 CallStatusEnum callStatus = 1;
	enum CallStatusEnum{
		TERMINATED = 0;///Terminated
		TERMINATED_OTHER = 1;///Terminated for Other Reasons.
		NOT_TERMINATED = 2;/// Call is not terminated ,send the data and stay on line.
	}
}
/**
 * This message sends Veh data to SDP when it requests for Veh data.
 * <div class=exmsg-main>
 * <h4>ECallVehDataRequest Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 *		timestamp: 1489600243281
 * 		messageId: 3
 * 		messages
 * 		{
 * 		 [com.fca.uconnect.global.ecallVehDataResponse]
 * 		 {
 * 		  ecallDataUpload
 * 		 {
 * 		  vehicleId: "1234AXFGFGHGH4566"
 * 		  isPositionTrusted: true
 * 		  timeStamp: 1489600238256
 * 		  vehicleLocation
 * 		  {
 * 			longitude: 43.9999
 * 			latitude: -84.54636
 * 		  }
 * 		 numberOfPassengers: 1
 * 		 airBagStatus
 * 		 {
 * 		  driver: false
 * 		  driverKnee: false
 * 		  passenger: false
 * 		  passengerKnee: false
 * 		  leftSideCurtain: false
 * 		  leftSeat: false
 * 		  rightSeat: false
 * 		}
 * 		  vehicleSpeed: 75.0
 * 		  tyrePressure: 45.0
 * 		  engineStatus: STOP
 * 	    }
 * 	    }
 * 	   }
 * 	  }
 *	</code>
 *   </div></div>
 *
 */
message ECallVehDataResponse{
	enum ResponseEnum {
		SUCCESS = 0;
		FAILURE = 1;
	}	

	 ECallDataUpload eCallDataUpload = 1;
	 ResponseEnum response = 2;/// Response (Success or Failure)
	 bool isTransient = 3; /// Indicates a transient error and a retry can be attempted.
	 int32 failureReasonCode = 4; /// Specific error code.
}
// extend UconnectAny {
     // ECallDataUpload ecallDataUpload = 160;
     // ECallStatusUpdate ecallStatusUpdate = 161;
     // ECallVehDataRequest ecallVehDataRequest =162;
     // ECallVehDataResponse ecallVehDataResponse = 163;
     // AckMessage eCallAckMessage=164;
// }

message UpdateEcallPhoneNumbers {
	bytes phoneList = 1;
	repeated PhoneListMessage phoneListMessages = 2;

}
 message PhoneListMessage {
 	bool EnableCallType = 1;
	string PrimaryPhoneNumber = 2; /// Primary Phone Number for the feature
	string SecondaryPhoneNumber = 3; /// Secondary Phone Number for the feature
	CallType callTypeEnum = 4;


	enum CallType {
		SOS = 0;
		ASOS_IMPACT = 1;


	}

}

message RequestEcallPhoneNumbers {
 	repeated PhoneListMessage phoneListMessages = 1;

}
