@shuangbing/bmw-connected-drive
Version:
This package can be used to access the BMW ConnectedDrive services.
356 lines (339 loc) • 11.7 kB
TypeScript
export declare class Account {
username: string;
password: string;
region: Regions;
token?: Token;
tokenStore?: ITokenStore;
logger?: ILogger;
constructor(username: string, password: string, region: Regions, tokenStore?: ITokenStore, logger?: ILogger);
getToken(): Promise<Token>;
private retrieveToken;
private executeFetchWithRetry;
private delay;
private static getQueryStringValue;
private static base64UrlEncode;
}
export declare class ConnectedDrive {
serviceExecutionStatusCheckInterval: number;
account: Account;
logger?: ILogger;
constructor(username: string, password: string, region: Regions, tokenStore?: ITokenStore, logger?: ILogger);
getVehicles(): Promise<Vehicle[]>;
getVehicleStatus(vin: string): Promise<VehicleStatus>;
lockDoors(vin: string, waitExecution?: boolean): Promise<RemoteServiceResponse>;
unlockDoors(vin: string, waitExecution?: boolean): Promise<RemoteServiceResponse>;
startClimateControl(vin: string, waitExecution?: boolean): Promise<RemoteServiceResponse>;
stopClimateControl(vin: string, waitExecution?: boolean): Promise<RemoteServiceResponse>;
flashLights(vin: string, waitExecution?: boolean): Promise<RemoteServiceResponse>;
blowHorn(vin: string, waitExecution?: boolean): Promise<RemoteServiceResponse>;
private executeService;
getServiceStatus(vin: string): Promise<ServiceStatus>;
sendMessage(vin: string, subject: string, message: string): Promise<boolean>;
request(url: string, isPost?: boolean, requestBody?: any): Promise<any>;
}
export declare class DetailedServiceStatus {
constructor(response: {
"rsStatus": RemoteServiceExecutionState;
"rsDetailedStatus": RemoteServiceExecutionStateDetailed;
"initiationError": "NO_ERROR" | string;
"rsError": "NO_ERROR" | string;
"creationTime": string;
"initStatus": true;
});
status: RemoteServiceExecutionState;
detailedStatus: RemoteServiceExecutionStateDetailed;
initiationError: string;
error: string;
creationTime: Date;
initStatus: boolean;
}
export declare interface ILogger {
Log(level: LogLevel, message: string): void;
LogTrace(message: string): void;
LogDebug(message: string): void;
LogInformation(message: string): void;
LogWarning(message: string): void;
LogError(message: string): void;
LogCritical(message: string): void;
}
export declare interface ITokenStore {
storeToken(token: Token): void;
retrieveToken(): Token | undefined;
}
export declare abstract class LoggerBase implements ILogger {
abstract Log(level: LogLevel, message: string): void;
LogTrace(message: string): void;
LogDebug(message: string): void;
LogInformation(message: string): void;
LogWarning(message: string): void;
LogError(message: string): void;
LogCritical(message: string): void;
}
export declare enum LogLevel {
Trace = 0,
Debug = 1,
Information = 2,
Warning = 3,
Error = 4,
Critical = 5
}
export declare enum Regions {
NorthAmerica = "NorthAmerica",
RestOfWorld = "RestOfWorld",
China = "China"
}
export declare enum RemoteServiceExecutionState {
INITIATED = "INITIATED",
DELIVERED = "DELIVERED",
STARTED = "STARTED",
PENDING = "PENDING",
RUNNING = "RUNNING",
PROV_RUNNING = "PROV_RUNNING",
EXECUTED = "EXECUTED",
CANCELLED_WITH_ERROR = "CANCELLED_WITH_ERROR",
UNKNOWN = "UNKNOWN"
}
export declare enum RemoteServiceExecutionStateDetailed {
UNKNOWN = "UNKNOWN",
OTHER_SERVICE_WITH_PROVISIONING_RUNNING = "OTHER_SERVICE_WITH_PROVISIONING_RUNNING",
PROVISIONING_STARTED = "PROVISIONING_STARTED",
SMS_DELIVERED_TO_GATEWAY = "SMS_DELIVERED_TO_GATEWAY",
PROVISIONING_FINISHED = "PROVISIONING_FINISHED",
SMS_DELIVERED_TO_VEHICLE = "SMS_DELIVERED_TO_VEHICLE",
DLQ_MESSAGE_PROVIDED = "DLQ_MESSAGE_PROVIDED",
DLQ_MESSAGE_FETCHED = "DLQ_MESSAGE_FETCHED",
UPLINK_MESSAGE_ACK = "UPLINK_MESSAGE_ACK",
DEPROVISIONING_STARTED = "DEPROVISIONING_STARTED",
DEPROVISIONING_FINISHED = "DEPROVISIONING_FINISHED"
}
export declare class RemoteServiceResponse {
constructor(response: {
"eventId": {
"eventId": string;
};
"vin": string;
"creationTime": string;
});
eventId: string;
vin: string;
creationTime: Date;
}
export declare enum RemoteServices {
/** climate */
ClimateNow = "RCN",
/** lock */
LockDoors = "RDL",
/** unlock */
UnlockDoors = "RDU",
/** horn */
BlowHorn = "RHB",
/** light */
FlashLight = "RLF",
/** Climate timer */
ClimateTimer = "RCT",
/** Charging profile */
ChargingProfile = "RCP"
}
export declare class ServiceStatus {
constructor(response: {
"event": {
"eventId": string;
"rsType": RemoteServices;
"rsTypeVersion": "v1";
"vin": string;
"userid": string;
"creationTime": string;
"lastUpdated": string;
"rsEventStatus": RemoteServiceExecutionState;
"requestParams": string;
/** List of concluded events. The list is *not* sorted by time. */
"actions": {
"rsStatus": RemoteServiceExecutionState;
"rsDetailedStatus": RemoteServiceExecutionStateDetailed;
"initiationError": "NO_ERROR" | string;
"rsError": "NO_ERROR" | string;
"creationTime": string;
"initStatus": true;
}[];
"uploads": [];
};
});
eventId: string;
serviceType: RemoteServices;
vin: string;
creationTime: Date;
lastUpdated: Date;
status: RemoteServiceExecutionState;
requestParams: string;
actions?: DetailedServiceStatus[];
}
export declare class Token {
response: string;
accessToken: string;
refreshToken: string;
validUntil: Date;
constructor({ response, accessToken, refreshToken, validUntil }: {
response: string;
accessToken: string;
refreshToken: string;
validUntil: Date;
});
}
export declare class Vehicle {
vin?: string;
model?: string;
bodytype?: string;
driveTrain?: string;
fuelType?: string;
color?: string;
colorCode?: string;
brand?: string;
licensePlate?: string;
yearOfConstruction?: number;
statisticsCommunityEnabled?: boolean;
statisticsAvailable?: boolean;
hub?: string;
hasAlarmSystem?: boolean;
dealer?: any;
breakdownNumber?: string;
countryCode?: string;
egoVehiclePath?: string;
chargingUpdateMode?: string;
steering?: string;
vehicleFinderRestriction?: string;
hmiVersion?: string;
a4a?: string;
vehicleFinder?: string;
remote360?: string;
hornBlow?: string;
lightFlash?: string;
doorLock?: string;
doorUnlock?: string;
climateControl?: string;
climateNow?: string;
climateNowRES?: string;
climateControlRES?: string;
chargingControl?: string;
chargeNow?: string;
sendPoi?: string;
rangeMap?: string;
lastDestinations?: string;
intermodalRouting?: string;
climateFunction?: string;
onlineSearchMode?: string;
onlineSearchProvider?: string;
smartSolution?: string;
carCloud?: string;
supportedChargingModes?: [any];
lscType?: string;
ipa?: string;
puStep?: string;
remoteSoftwareUpgrade?: string;
}
export declare class VehicleStatus {
unitOfLength?: string;
remainingRange?: number;
updateTimeConverted?: Date;
doorDriverRear?: string;
doorPassengerRear?: string;
beRemainingRangeFuelKm?: number;
doorDriverFront?: string;
hoodState?: string;
chargingStatus?: string;
kombiCurrentRemainingRangeFuel?: number;
windowDriverRear?: string;
beRemainingRangeElectricKm?: number;
mileage?: number;
unitOfEnergy?: string;
overallEnergyConsumption?: number;
beRemainingRangeElectric?: number;
socHvPercent?: number;
singleImmediateCharging?: boolean;
updateTimeConvertedTime?: Date;
connectorStatus?: string;
chargingHVStatus?: string;
chargingLevelHv?: number;
unitOfCombustionConsumption?: string;
gpsLat?: number;
windowDriverFront?: string;
gpsLng?: number;
conditionBasedServices?: string;
windowPassengerFront?: string;
windowPassengerRear?: string;
lastChargingEndReason?: string;
updateTimeConvertedDate?: Date;
beRemainingRangeFuelMile?: number;
beRemainingRangeFuel?: number;
doorPassengerFront?: string;
beChargingLevelHv?: number;
updateTimeConvertedTimestamp?: number;
remainingFuel?: number;
heading?: number;
lscTrigger?: string;
lightsParking?: string;
doorLockState?: string;
updateTime?: Date;
beEnergyLevelHv?: number;
trunkState?: string;
batterySizeMax?: number;
beRemainingRangeElectricMile?: number;
chargingConnectionType?: string;
unitOfElectricConsumption?: string;
lastUpdateReason?: string;
constructor(response: {
attributesMap: {
unitOfLength: string;
remaining_range: string;
updateTime_converted: string;
door_driver_rear: string;
door_passenger_rear: string;
beRemainingRangeFuelKm: string;
door_driver_front: string;
hood_state: string;
charging_status: string;
kombi_current_remaining_range_fuel: string;
window_driver_rear: string;
beRemainingRangeElectricKm: string;
mileage: string;
unitOfEnergy: string;
overall_energy_consumption: string;
beRemainingRangeElectric: string;
soc_hv_percent: string;
single_immediate_charging: string;
updateTime_converted_time: string;
connectorStatus: string;
chargingHVStatus: string;
chargingLevelHv: string;
unitOfCombustionConsumption: string;
gps_lat: string;
window_driver_front: string;
gps_lng: string;
condition_based_services: string;
window_passenger_front: string;
window_passenger_rear: string;
lastChargingEndReason: string;
updateTime_converted_date: string;
beRemainingRangeFuelMile: string;
beRemainingRangeFuel: string;
door_passenger_front: string;
beChargingLevelHv: string;
updateTime_converted_timestamp: string;
remaining_fuel: string;
heading: string;
lsc_trigger: string;
lights_parking: string;
door_lock_state: string;
updateTime: string;
beEnergyLevelHv: string;
trunk_state: string;
battery_size_max: string;
beRemainingRangeElectricMile: string;
charging_connection_type: string;
unitOfElectricConsumption: string;
lastUpdateReason: string;
};
});
toInteger(string: string): number | undefined;
toFloat(string: string): number | undefined;
}
export { }