Client Example Code (HU/TBM):

           /**********************************************************************************************
     * This example code is provided for illustrative purposes only and provided 'AS IS' without
     * warranty of any kind.
     *
     * Copyright ©2014 Chrysler Group LLC.  All Rights Reserved.  All information contained herein is,
     * and remains the property of Chrysler Group LLC and its suppliers, if any.  The intellectual and
     * technical concepts contained herein are proprietary to Chrysler Group LLC and its suppliers
     * and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade
     * secret or copyright law. Dissemination of this information or reproduction of this material is
     * strictly forbidden unless prior written permission is obtained from Chrysler Group LLC.
     *
     * Chrysler, Jeep, Dodge, Ram, SRT, Mopar and the Pentastar logo are registered trademarks of
     * Chrysler Group LLC. FIAT is a registered trademark of Fiat group Marketing & Corporate
     * Communication S.p.A. used under license by Chrysler Group LLC.
     *********************************************************************************************/
    package com.fca.uconnect.global;
    import java.util.List;

    import com.amazonaws.services.iot.client.AWSIotException;
    import com.amazonaws.services.iot.client.AWSIotMessage;
    import com.amazonaws.services.iot.client.AWSIotMqttClient;
    import com.amazonaws.services.iot.client.AWSIotQos;
    import com.amazonaws.services.iot.client.AWSIotTopic;
    import com.fca.uconnect.global.GlobalUconnectControl.Address;
    import com.fca.uconnect.global.GlobalUconnectControl.Destination;
    import com.fca.uconnect.global.GlobalUconnectControl.Destination.OriginalSource;
    import com.fca.uconnect.global.GlobalUconnectControl.Destination.RoutePreference;
    import com.fca.uconnect.global.GlobalUconnectControl.Location;
    import com.fca.uconnect.global.GlobalUconnectControl.PointOfInterest;
    import com.fca.uconnect.global.GlobalUconnectControl.UconnectAny;
    import com.fca.uconnect.global.GlobalUconnectControl.UconnectMessage;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.PersonalAccount;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.PersonalAccount.InfotainmentPreference;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.PersonalAccount.MusicFavourite;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.PersonalAccount.NavigationPreference;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.PersonalAccount.RadioPreset;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.PersonalAccount.RadioPreset.RadioStation;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.PersonalAccount.RadioPreset.RadioStation.StationType;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.VehSyncModel;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.VehicleConfigPublish;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.WifiSetting;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.WifiSetting.EncryptionEnum;
    import com.google.protobuf.ByteString;
    import com.google.protobuf.ExtensionRegistry;

    /**
     * This example class demonstrates how to use the AWS IoT mqtt client to send a Uconnect VehSync message to the SDP and wait for a response message.
     * This code is only for reference and is furnished without warranty.....
     *
     * @author FCA Global V2C API Team
     *
     */
    public class TBMExampleForVehSync {

    	private String clientId; // The clientId is unique to the device and obtained from the client X.509 certificate CN.
    	private int messageId; // The messageId is a sequential number incremented and assigned to each message sent from the client.
    	private AWSIotMqttClient mqttClient; // The mqtt client object from the AWS IoT client library.
    	private AWSIotTopic iotTopic; // The Topic object to subscribe for inbound messages.
    	private ExtensionRegistry extRegistry; // Google protocol buffers extension registry instance.
    	private int correlationId = 0;// The correlationId is a sender messageId so that Sender can recognize the message once its received response.
    	private Semaphore semaphore;//The semaphore object is used to wait for a response.
    	List messages ;

    	/**
    	 * Constructor - initialize protocol buffer extension registry for parsing incoming Uconnect Messages.
    	 */
    	public TBMExampleForVehSync() {
    		extRegistry = ExtensionRegistry.newInstance();
    		extRegistry.add(GlobalUconnectExtVehSync.vehicleConfigPublish);
    		extRegistry.add(GlobalUconnectExtVehSync.vehicleConfigRequest);
    		this.semaphore = new Semaphore();
    	}

    	/**
    	 * This method generates a Protocol Buffer Uconnect Message given the required inputs for VehicleConfigPublish.
    	 *
    	 */
    	public UconnectMessage getVehConfigPubMsg() {
    		this.messageId++;
    		WifiSetting wifiSetting = WifiSetting.newBuilder()
    				 .setEncryption(EncryptionEnum.WEP)
    				 .setSsid("FCA")
    				 .setPassword("FCAPWD")
    				 .build();
    		RadioStation radioStation = RadioStation.newBuilder()
    				.setStationFrequency(91)
    				.setStationName("Michigan Radio")
    				.setStationType(StationType.FM)
    				.build();
    		RadioPreset radioPreset = RadioPreset.newBuilder()
    				.addStations(radioStation)
    				.build();
    		MusicFavourite musicFavourite = MusicFavourite.newBuilder()
    				.addBandNames("Green Day")
    				.addSongNames("Wake Me Up When September")
    				.addSongNames("Boulevard of Broken Dreams")
    				.build();
    		InfotainmentPreference infotainmentPreference = InfotainmentPreference.newBuilder()
    				.setMusicFavorite(musicFavourite)
    				.setRadioPreset(radioPreset)
    				.build();
    		Location destLocation = Location.newBuilder()
    				.setPositionLatitude(42.480201)
    				.setPositionLongitude(-83.671875F)
    				.build();
    				Address address = Address.newBuilder()
    				.setHouseNumber("1000")
    				.setStreetName("Chrystler Drive")
    				.setCityName("Auburn Hills")
    				.setProvinceName("Michigan")
    				.setCountryName("USA")
    				.build();
    				Address poiAddress = Address.newBuilder()
    				.setHouseNumber("2000")
    				.setStreetName("abc drive")
    				.setCityName("Auburn Hills")
    				.setProvinceName("Michigan")
    				.setCountryName("USA")
    				.build();
    				PointOfInterest poi  = PointOfInterest.newBuilder()
    				.setCategory("Restaurant")
    				.setDescription("favorite")
    				.setName("ABCD Restaurant")
    				.setId(123)
    				.setPhoneNumber("123 456 7890")
    				.setLocation(destLocation)
    				.setUrl("www.abcrestaurant.com")
    				.setAddress(poiAddress)
    				.build();
    				Destination dest = Destination.newBuilder()
    				.setDestinationDescription("fav restaurant")
    				.setRoutePreference(RoutePreference.Fast)
    				.setOrignalSource(OriginalSource.SDP)
    				.setCreateTimestamp(System.currentTimeMillis())
    				.setLocation(destLocation)
    				.setDestinationPoi(poi)
    				.setDestinationAddress(address)
    				.build();
    		NavigationPreference navigationPreference = NavigationPreference.newBuilder()
    				.addFavoriteLocations(dest)
    				.build();

    		PersonalAccount personalAccount = PersonalAccount.newBuilder()
    				.setInfotainmentPreference(infotainmentPreference)
    				.setNavigationPreference(navigationPreference)
    				.build();
    		VehSyncModel vehSyncModel = VehSyncModel.newBuilder()
    				.setPersonalAccountData(personalAccount)
    				.setWifiConfigSet(wifiSetting)
    				.build();
    		VehicleConfigPublish vehicleConfigPublish = VehicleConfigPublish.newBuilder()
    				.setConfigSetVersion(1)
    				.setIsChangesOnly(false)
    				.setModelData(vehSyncModel)
    				.build();

    		UconnectMessage msg = UconnectMessage.newBuilder()
    			.setTimestamp(System.currentTimeMillis())
    			.setMessageId(messageId)
    			.setCorrelationId(correlationId)
    			.addMessages(UconnectAny.newBuilder().
    					 setExtension(GlobalUconnectExtVehSync.vehicleConfigPublish,vehicleConfigPublish))
    			.build();
    		return msg;
    	}

    	/**
    	 * This method demonstrates connecting to the AWS IoT mqtt broker and publishing an Activation message to the UACT topic.
    	 */
    	public List process() {

    		mqttClient = new AWSIotMqttClient("endpoint", clientId, "awsAccessKeyId", "awsSecretAccessKey");
    		try {
    			mqttClient.connect();

    			iotTopic = new AWSIotTopic(clientId+"/VCSC/", AWSIotQos.QOS1) {
    				public void onMessage(AWSIotMessage msg) {
    					try{
    					UconnectMessage msgIn;
    						msgIn = UconnectMessage.parseFrom(msg.getPayload(),extRegistry);

    					if ( msgIn.getMessages(0).hasExtension(GlobalUconnectExtVehSync.vehicleConfigRequest)) {
    						correlationId=msgIn.getMessageId();
    						sendMessage(getVehConfigPubMsg());
    						semaphore.unlock();// Releasing the lock
    					}

    			} catch( Exception ex) {
    				ex.printStackTrace();
    				System.out.println("Err processing message: "+ex+", try parsing Vehicle Sync.");
    			}
    			}
    			};
    			mqttClient.subscribe(iotTopic);
    			this.semaphore.lock();	// lock thread
    			if(messages!=null)
    				return messages;
    		} catch (AWSIotException ex) {
    			System.out.println("Caught AWS Exception "+ex);
    			ex.printStackTrace();
    		}  catch (Exception e) {
    			e.printStackTrace();
    		}
    		return null;
    	}
    	public void sendMessage(UconnectMessage msg) {
    		final byte[] msgOut = msg.toByteArray();
    		new Thread(new Runnable() {

    		    @Override
    		public void run() {
    		try {
    			AWSIotMessage message = new
    					MessagePublisherListener("/VCSC/"+clientId,AWSIotQos.QOS1,msgOut);
    			mqttClient.publish(message);

    		} catch (AWSIotException e) {
    			System.out.println("Caught Exception "+e);
    						e.printStackTrace();
    					}
    			    }

    			}).start();
    		}

    	/**
    	 * Example main to launch example.
    	 *
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		TBMExampleForVehSync example = new TBMExampleForVehSync();
    		example.process();
    	}
    }

Here's an example of how Service Connects to AWS IOT MQTT for VehiclConfigSync topics and process VehiclConfig Requests .

Service Example Code (SDP):

    package com.fca.uconnect.global;

    import com.amazonaws.services.iot.client.AWSIotException;
    import com.amazonaws.services.iot.client.AWSIotMessage;
    import com.amazonaws.services.iot.client.AWSIotMqttClient;
    import com.amazonaws.services.iot.client.AWSIotQos;
    import com.amazonaws.services.iot.client.AWSIotTopic;
    import com.fca.uconnect.global.GlobalUconnectControl.UconnectAny;
    import com.fca.uconnect.global.GlobalUconnectControl.UconnectMessage;
    import com.fca.uconnect.global.GlobalUconnectExtVehSync.VehicleConfigRequest;
    import com.google.protobuf.ByteString;
    import com.google.protobuf.ExtensionRegistry;

    public class SDPExampleForVehSync {
    private String clientId; // The clientId is unique to the device and obtained from the client X.509 certificate CN.
    private int messageId=10; // The messageId is a sequential number incremented and assigned to each message sent from the client.
    private AWSIotMqttClient mqttClient; // The mqtt client object from the AWS IoT client library.
    private AWSIotTopic iotTopic; // The Topic object to subscribe for inbound messages.
    private ExtensionRegistry extRegistry; // Google protocol buffers extension registry instance.
    private int correlationId = 0;// The correlationId is a sender messageId so that Sender can recognize the message once its received response.

    public SDPExampleForVehSync() {
    	extRegistry = ExtensionRegistry.newInstance();
    	extRegistry.add(GlobalUconnectExtVehSync.vehicleConfigPublish);
    	extRegistry.add(GlobalUconnectExtVehSync.vehicleConfigRequest);
    }

    public UconnectMessage getVehicleConfigReqMsg() {
    	messageId++;
    	VehicleConfigRequest vehReqMsg = VehicleConfigRequest.newBuilder()
    			.setConfigSetVersion(1)
    			.build();
    	UconnectMessage msg = UconnectMessage.newBuilder()
    		.setTimestamp(System.currentTimeMillis())

    		.setMessageId(messageId)
    		.addMessages(UconnectAny.newBuilder().
    		 setExtension(GlobalUconnectExtVehSync.vehicleConfigRequest, vehReqMsg))
    		.build();

    	return msg;
    }

    public void process() {

    	mqttClient = new AWSIotMqttClient("endpoint", clientId, "awsAccessKeyId", "awsSecretAccessKey");

    try {
    mqttClient.connect();
     iotTopic = new AWSIotTopic("/VCSC/#",AWSIotQos.QOS1){
    	public void onMessage(AWSIotMessage msg) {
    try {

    	UconnectMessage	msgIn = UconnectMessage.parseFrom(msg.getPayload(),extRegistry);
    	if (correlationId==msgIn.getMessageId() &&msgIn.getMessages(0).hasExtension(GlobalUconnectExtVehSync.vehicleConfigPublish) ) {
    		GlobalUconnectExtVehSync.VehicleConfigPublish vehPubMsg = msgIn.getMessages(0).getExtension(GlobalUconnectExtVehSync.vehicleConfigPublish);
    	// Receive Vehicle Config
    	}

    } catch( Exception ex) {
    	ex.printStackTrace();
    	System.out.println("Err processing message: "+ex+", try parsing Vehicle Sync.");
    }
    }
    };

    mqttClient.subscribe(iotTopic);
    sendMessage(getVehicleConfigReqMsg());
    } catch (AWSIotException e) {
    	System.out.println("Caught Exception "+e);
    	e.printStackTrace();
    }
    }

    public void sendMessage(UconnectMessage msg) {
    final byte[] msgOut = msg.toByteArray();
    new Thread(new Runnable() {

        @Override
    public void run() {
    try {
    	AWSIotMessage message = new
    			MessagePublisherListener(clientId+"/VCSC/",AWSIotQos.QOS1,msgOut);
    	mqttClient.publish(message);

    } catch (AWSIotException e) {
    	System.out.println("Caught Exception "+e);
    				e.printStackTrace();
    			}
    	    }

    	}).start();
    }
    public static void main(String[] args) {
    	SDPExampleForVehSync m = new SDPExampleForVehSync();
    	m.process();
    }
    }

The example code demonstrates how to connect with AWS IoT for publishing and subscribing to the VehicleConfigSync topic.

Download Client Example Code here

Download Service Example Code here