Plugin car.profile

car.profile

Manages the system user information

Methods

addProfile

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 function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
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"
}

cancelWatch

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

deleteProfile

Delete an existing profile
Parameters:
Name Type Argument Description
profileId Number The ID of the profile.
successCallback Function <optional>
The function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
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"
}

getActive

Retrieve the current profile information
Parameters:
Name Type Argument Description
successCallback Function The function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
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"
}

getList

Return a list of available profiles
Parameters:
Name Type Argument Description
successCallback Function The function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
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: 'titanium', 
                bluetoothDeviceId: null 
            }
        ]
}

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

getSettings

Retrieve settings for the current profile
Parameters:
Name Type Argument Description
successCallback Function The function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
settings Array <optional>
A list of settings to whitelist.
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"
}

setActive

Change the active profile
Parameters:
Name Type Argument Description
profileId Number The ID of the profile to make active.
successCallback Function The function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
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"
}

setSetting

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 function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
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"
}

updateProfile

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 function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
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"
}

watchProfile

Watch for profile changes
Parameters:
Name Type Description
callback Function The function to call when a change is detected.
Returns:
An ID for the added watch.
Type
  • String
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);