QNX CAR Platform for Infotainment 2.1 -- JavaScript API (Cordova)

car.profile

Manage the system user information
Source:

Methods

<static> addProfile(name, avatar, theme, bluetoothDeviceId, successCallback, errorCallback)

Create a new profile
Parameters:
Name Type Argument Description
name String The name of the profile.
avatar String <optional>
The avatar for the profile.
theme String <optional>
The preferred theme for the profile.
bluetoothDeviceId String <optional>
The preferred Bluetooth device for the profile.
successCallback Function <optional>
The callback that is called on success.
errorCallback Function <optional>
The callback that is called if there is an error.
Source:
Examples
 

//define your callback function(s)
function successCallback(profileid) {
		console.log("profile id = " + profileid);
}

function errorCallback(error) {
		console.log(error.code, error.msg);
}

//call the method
car.profile.addProfile('Joe', 'platform:///path/to/avatar.png', 'default', '9D:BA:8E:43:ED:68', successCallback, errorCallback);
 REST

Request:
http://<car-ip>/car/profile/addProfile?name=Joe&avatar=platform%3A%2F%2F%2Fpath%2Fto%2Favatar.png&themeId=default&bluetoothDeviceId=9D:BA:8E:43:ED:68

Success Response:
{
		code: 1,
		data: [ 
			{ 
				id: 2
			}
		]
}

Error Response:
{
		code: -1,
		msg: "An error has occurred"
}

<static> cancelWatch(watchId)

Stop watching profile changes
Parameters:
Name Type Description
watchId Number The watch ID returned by car.profile.watchProfile.
Source:
Example
car.profile.cancelWatch(watchId);

<static> deleteProfile(profileId, successCallback, errorCallback)

Delete an existing profile
Parameters:
Name Type Argument Description
profileId Number The ID of the profile.
successCallback Function <optional>
The callback that is called on success.
errorCallback Function <optional>
The callback that is called if there is an error.
Source:
Examples
 

//define your callback function(s)
function successCallback() {
		console.log("profile has been deleted");
}

function errorCallback(error) {
		console.log(error.code, error.msg);
}

//call the method
car.profile.deleteProfile(2, successCallback, errorCallback);
 REST

Request:
http://<car-ip>/car/profile/deleteProfile?profileId=2

Success Response:
{
		code: 1
}

Error Response:
{
		code: -1,
		msg: "An error has occurred"
}

<static> getActive(successCallback, errorCallback)

Retrieves the current profile information
Parameters:
Name Type Argument Description
successCallback Function The callback that is called on success.
errorCallback Function <optional>
The callback that is called if there is an error.
Source:
Examples
 

//define your callback function(s)
function successCallback(profile) {
		console.log("profile id = " + profile.id + "\n" +
					"profile name = " + profile.name + "\n" +
					"profile avatar = " + profile.avatar + "\n" +
					"profile theme = " + profile.theme + "\n" +
					"profile bluetooth device id = " + profile.bluetoothDeviceId
		);
}

function errorCallback(error) {
		console.log(error.code, error.msg);
}

//call the method
car.profile.getActive(successCallback, errorCallback);
 REST

Request:
http://<car-ip>/car/profile/getActive

Success Response:
{
		code: 1,
		data: { 
			id: 1, 
			name: 'John Doe', 
			avatar: 'platform:///path/to/avatar.png', 
			theme: 'default', 
			bluetoothDeviceId: '9D:BA:8E:43:ED:68' 
		}
}

Error Response:
{
		code: -1,
		msg: "An error has occurred"
}

<static> getList(successCallback, errorCallback)

Return a list of available profiles
Parameters:
Name Type Argument Description
successCallback Function The callback that is called on success.
errorCallback Function <optional>
The callback that is called if there is an error.
Source:
Examples
 

//define your callback function(s)
function successCallback(profiles) {
		//iterate through all the profiles
		for (var i=0; i<profiles.length; i++) {
			console.log("profile id = " + profiles[i].id + "\n" +
						"profile name = " + profiles[i].name + "\n" +
						"profile avatar = " + profiles[i].avatar
						"profile avatar = " + profiles[i].avatar + "\n" +
						"profile theme = " + profiles[i].theme + "\n" +
						"profile bluetooth device id = " + profiles[i].bluetoothDeviceId
			);
		}
}

function errorCallback(error) {
		console.log(error.code, error.msg);
}

//call the method
car.profile.getList(successCallback, errorCallback);
 REST

Request:
http://<car-ip>/car/profile/getList

Success Response:
{
		code: 1,
		data: [ 
			{ 
				id: 1, 
				name: 'John Doe', 
				avatar: 'platform:///path/to/avatar.png', 
				theme: 'default', 
				bluetoothDeviceId: '9D:BA:8E:43:ED:68' 
			}, { 
				id: 2, 
				name: 'Joe', 
				avatar: 'platform:///path/to/avatar.png', 
				theme: 'jeep', 
				bluetoothDeviceId: null 
			}
		]
}

Error Response:
{
		code: -1,
		msg: "An error has occurred"
}

<static> getSettings(successCallback, errorCallback, settings)

Retrieve settings for the current profile
Parameters:
Name Type Argument Description
successCallback Function The callback that is called on success.
errorCallback Function <optional>
The callback that is called if there is an error.
settings Array <optional>
A list of settings to whitelist.
Source:
Examples
 

//define your callback function(s)
function successCallback(settings) {
		//iterate through all the settings
		for (var i=0; i<settings.length; i++) {
			console.log("setting key = " + settings[i].key + "\n" +
						"setting value = " + settings[i].value
			);
		}
}

function errorCallback(error) {
		console.log(error.code, error.msg);
}

//call the method
car.profile.getSettings(successCallback, errorCallback, ['hvac_fanSpeed_frontLeft', 'audio_volume_everywhere', 'radio_preset_am']);
 REST

Request:
http://<car-ip>/car/profile/getSettings?settings=hvac_fanSpeed_all,hvac_airConditioning_all,radio_preset_am

Success Response:
{
		code: 1,
		data: [
			{ key: 'hvac_fanSpeed_frontLeft', value: 1 },
			{ key: 'audio_volume_everywhere', value: 10 },
			{ key: 'radio_preset_am', value: [880,910,950,1020,1220,1430] }
		]
}

Error Response:
{
		code: -1,
		msg: "An error has occurred"
}

<static> setActive(profileId, successCallback, errorCallback)

Change the active profile
Parameters:
Name Type Argument Description
profileId Number The ID of the profile to make active.
successCallback Function The callback that is called on success.
errorCallback Function <optional>
The callback that is called if there is an error.
Source:
Examples
 

//call the method
car.profile.setActive(1);
 REST

Request:
http://<car-ip>/car/profile/setActive?profileId=1

Success Response:
{
		code: 1
}

Error Response:
{
		code: -1,
		msg: "An error has occurred"
}

<static> setSetting(key, value, successCallback, errorCallback)

Set the value of a setting for the current profile
Parameters:
Name Type Argument Description
key String The key of the setting.
value Mixed The value of the setting.
successCallback Function <optional>
The callback that is called on success.
errorCallback Function <optional>
The callback that is called if there is an error.
Source:
Examples
 

//define your callback function(s)
function successCallback() {
		console.log("setting has been set");
}

function errorCallback(error) {
		console.log(error.code, error.msg);
}

//call the method
car.profile.setSettings('hvac_fanSpeed_frontLeft', 1, successCallback, errorCallback);
 REST

Request:
http://<car-ip>/car/profile/setSettings?key=hvac_fanSpeed_frontLeft&value=1

Success Response:
{
		code: 1,
}

Error Response:
{
		code: -1,
		msg: "An error has occurred"
}

<static> updateProfile(profileId, name, avatar, theme, bluetoothDeviceId, successCallback, errorCallback)

Update an existing profile
Parameters:
Name Type Argument Description
profileId Number The ID of the profile.
name String <optional>
The name of the profile.
avatar String <optional>
The avatar for the profile.
theme String <optional>
The preferred theme for the profile.
bluetoothDeviceId String <optional>
The preferred Bluetooth device for the profile.
successCallback Function <optional>
The callback that is called on success.
errorCallback Function <optional>
The callback that is called if there is an error.
Source:
Examples
 

//define your callback function(s)
function successCallback() {
		console.log("profile has been updated");
}

function errorCallback(error) {
		console.log(error.code, error.msg);
}

//call the method
car.profile.updateProfile(2, 'Joe', 'platform:///path/to/avatar.png', 'default', '9D:BA:8E:43:ED:68', successCallback, errorCallback);
 REST

Request:
http://<car-ip>/car/profile/updateProfile?profileId=2&name=Joe&avatar=platform%3A%2F%2F%2Fpath%2Fto%2Favatar.png&themeId=default&bluetoothDeviceId=9D:BA:8E:43:ED:68

Success Response:
{
		code: 1
}

Error Response:
{
		code: -1,
		msg: "An error has occurred"
}

<static> watchProfile(callback) → {Number}

Watch for profile changes
Parameters:
Name Type Description
callback Function The function to be called when a change is detected.
Source:
Returns:
An ID for the added watch.
Type
Number
Example
//define a callback function
function myCallback(profile) {
		console.log("profile id = " + profile.id + "\n" +
					"profile name = " + profile.name + "\n" +
					"profile avatar = " + profile.avatar + "\n" +
					"profile theme = " + profile.theme + "\n" +
					"profile bluetooth device id = " + profile.bluetoothDeviceId
}

var watchId = car.profile.watchProfile(myCallback);