bmw-connected-drive
Version:
This package can be used to access the BMW ConnectedDrive services.
446 lines (399 loc) • 13.4 kB
TypeScript
export declare class Account {
username: string;
password: string;
region: Regions;
token?: Token;
tokenStore?: ITokenStore;
logger?: ILogger;
captchaToken?: string;
constructor(username: string, password: string, region: Regions, tokenStore?: ITokenStore, logger?: ILogger, captchaToken?: string);
getToken(): Promise<Token>;
private login;
private refresh_token;
private retrieveOAuthConfig;
private executeFetchWithRetry;
private static getQueryStringValue;
private static base64UrlEncode;
private buildTokenAndStore;
}
export declare interface Address {
formatted: string;
}
export declare interface Attributes {
lastFetched: Date;
model: string;
year: number;
color: number;
brand: CarBrand;
driveTrain: string;
headUnitType: string;
headUnitRaw: string;
hmiVersion: string;
softwareVersionCurrent: SoftwareVersion;
softwareVersionExFactory: SoftwareVersion;
telematicsUnit: string;
bodyType: string;
countryOfOrigin: string;
a4aType: string;
driverGuideInfo: DriverGuideInfo;
}
export declare interface Capabilities {
a4aType: string;
climateNow: boolean;
climateFunction: string;
horn: boolean;
isBmwChargingSupported: boolean;
isCarSharingSupported: boolean;
isChargeNowForBusinessSupported: boolean;
isChargingHistorySupported: boolean;
isChargingHospitalityEnabled: boolean;
isChargingLoudnessEnabled: boolean;
isChargingPlanSupported: boolean;
isChargingPowerLimitEnabled: boolean;
isChargingSettingsEnabled: boolean;
isChargingTargetSocEnabled: boolean;
isCustomerEsimSupported: boolean;
isDataPrivacyEnabled: boolean;
isDCSContractManagementSupported: boolean;
isEasyChargeEnabled: boolean;
isMiniChargingSupported: boolean;
isEvGoChargingSupported: boolean;
isRemoteHistoryDeletionSupported: boolean;
isRemoteEngineStartSupported: boolean;
isRemoteServicesActivationRequired: boolean;
isRemoteServicesBookingRequired: boolean;
isScanAndChargeSupported: boolean;
lastStateCallState: string;
lights: boolean;
lock: boolean;
remote360: boolean;
sendPoi: boolean;
unlock: boolean;
vehicleFinder: boolean;
vehicleStateSource: string;
isRemoteHistorySupported: boolean;
isWifiHotspotServiceSupported: boolean;
isNonLscFeatureEnabled: boolean;
isSustainabilitySupported: boolean;
isSustainabilityAccumulatedViewEnabled: boolean;
checkSustainabilityDPP: boolean;
specialThemeSupport: any[];
isRemoteParkingSupported: boolean;
remoteChargingCommands: RemoteChargingCommands;
isClimateTimerWeeklyActive: boolean;
digitalKey: DigitalKey;
}
export declare enum CarBrand {
Bmw = "BMW",
Mini = "MINI"
}
export declare enum CarView {
Dashboard = "DASHBOARD",
DriverDoor = "DRIVERDOOR",
FrontLeft = "FRONTLEFT",
FrontRight = "FRONTRIGHT",
FrontView = "FRONTVIEW",
RearLeft = "REARLEFT",
RearRight = "REARRIGHT",
RearView = "REARVIEW",
SideViewLeft = "SIDEVIEWLEFT"
}
export declare interface ChargingProfile {
chargingControlType: string;
reductionOfChargeCurrent: ReductionOfChargeCurrent;
chargingMode: string;
chargingPreference: string;
departureTimes: DepartureTime[];
climatisationOn: boolean;
chargingSettings: ChargingSettings;
}
export declare interface ChargingSettings {
targetSoc: number;
idcc: string;
hospitality: string;
}
export declare interface CheckControlMessage {
type: string;
severity: string;
}
export declare interface ClimateControlState {
activity: string;
}
export declare interface ClimateTimer {
isWeeklyTimer: boolean;
timerAction: string;
timerWeekDays: string[];
departureTime: Time;
}
export declare interface CombustionFuelLevel {
remainingFuelPercent: number;
remainingFuelLiters: number;
range: number;
}
export declare class ConnectedDrive {
serviceExecutionStatusCheckInterval: number;
account: Account;
logger?: ILogger;
constructor(username: string, password: string, region: Regions, tokenStore?: ITokenStore, logger?: ILogger, captchaToken?: string);
getVehicles(): Promise<Vehicle[]>;
getVehiclesByBrand(brand: CarBrand): Promise<Vehicle[]>;
getVehicleStatus(vin: string, brand?: CarBrand): Promise<VehicleStatus>;
getVehicleCapabilities(vin: string, brand?: CarBrand): Promise<Capabilities>;
lockDoors(vin: string, brand?: CarBrand, waitExecution?: boolean): Promise<RemoteServiceRequestResponse>;
unlockDoors(vin: string, brand?: CarBrand, waitExecution?: boolean): Promise<RemoteServiceRequestResponse>;
startClimateControl(vin: string, brand?: CarBrand, waitExecution?: boolean): Promise<RemoteServiceRequestResponse>;
stopClimateControl(vin: string, brand?: CarBrand, waitExecution?: boolean): Promise<RemoteServiceRequestResponse>;
flashLights(vin: string, brand?: CarBrand, waitExecution?: boolean): Promise<RemoteServiceRequestResponse>;
blowHorn(vin: string, brand?: CarBrand, waitExecution?: boolean): Promise<RemoteServiceRequestResponse>;
startCharging(vin: string, brand?: CarBrand, waitExecution?: boolean): Promise<RemoteServiceRequestResponse>;
stopCharging(vin: string, brand?: CarBrand, waitExecution?: boolean): Promise<RemoteServiceRequestResponse>;
private executeService;
getServiceStatus(eventId: string, brand?: CarBrand): Promise<RemoteServiceExecutionState>;
getImage(vin: string, brand: CarBrand | undefined, view: CarView): Promise<ArrayBuffer>;
sendMessage(vin: string, brand: CarBrand | undefined, subject: string, message: string): Promise<boolean>;
get(url: string, brand?: CarBrand, headers?: any): Promise<Response>;
getFromJson(url: string, brand?: CarBrand, headers?: any): Promise<any>;
postAsJson(url: string, brand?: CarBrand, requestBody?: any, headers?: any): Promise<any>;
request(url: string, brand?: CarBrand, isPost?: boolean, requestBody?: any, headers?: any): Promise<Response>;
}
export declare interface Coordinates {
latitude: number;
longitude: number;
}
export declare interface DepartureTime {
id: number;
timeStamp: Time;
action: string;
timerWeekDays: string[];
}
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 DigitalKey {
bookedServicePackage: string;
state: string;
}
export declare interface DoorsState {
combinedSecurityState: string;
leftFront: string;
leftRear: string;
rightFront: string;
rightRear: string;
combinedState: string;
hood: string;
trunk: string;
}
export declare interface DriverGuideInfo {
androidAppScheme: string;
iosAppScheme: string;
androidStoreUrl: string;
iosStoreUrl: string;
}
export declare interface DriverPreferences {
lscPrivacyMode: string;
}
export declare interface ElectricChargingState {
chargingLevelPercent: number;
range: number;
isChargerConnected: boolean;
chargingConnectionType: string;
chargingStatus: string;
chargingTarget: number;
}
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 interface LocationInfo {
coordinates: Coordinates;
address: Address;
heading: number;
}
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 interface MappingInfo {
isAssociated: boolean;
isLmmEnabled: boolean;
mappingStatus: string;
isPrimaryUser: boolean;
}
export declare interface PuStep {
month: number;
year: number;
}
export declare interface ReductionOfChargeCurrent {
start: Time;
end: Time;
}
export declare enum Regions {
NorthAmerica = "NorthAmerica",
RestOfWorld = "RestOfWorld",
China = "China"
}
export declare interface RemoteChargingCommands {
chargingControl?: string[];
flapControl?: string[];
plugControl?: string[];
}
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",
ERROR = "ERROR",
IGNORED = "IGNORED",
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 interface RemoteServiceRequestResponse {
eventId: string;
creationTime: string;
}
export declare enum RemoteServices {
/** climate */
ClimateNow = "climate-now",
/** lock */
LockDoors = "door-lock",
/** unlock */
UnlockDoors = "door-unlock",
/** horn */
BlowHorn = "horn-blow",
/** light */
FlashLight = "light-flash",
/** start charging */
ChargeStart = "start-charging",
/** stop charging */
ChargeStop = "stop-charging"
}
export declare interface RequiredService {
dateTime: Date;
type: string;
status: string;
description: string;
mileage?: number;
}
export declare interface SoftwareVersion {
puStep: PuStep;
iStep: number;
seriesCluster: string;
}
export declare interface Time {
hour: number;
minute: number;
}
export declare interface TireStatus {
currentPressure: number;
targetPressure: number;
}
export declare interface TireStatuses {
frontLeft: TireStatusInternal;
frontRight: TireStatusInternal;
rearLeft: TireStatusInternal;
rearRight: TireStatusInternal;
}
export declare interface TireStatusInternal {
status: TireStatus;
}
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 Utils {
static Delay(ms: number, logger?: ILogger): Promise<boolean>;
}
export declare interface Vehicle {
vin: string;
mappingInfo: MappingInfo;
appVehicleType: string;
attributes: Attributes;
}
export declare interface VehicleStatus {
isLeftSteering: boolean;
lastFetched: Date;
lastUpdatedAt: Date;
isLscSupported: boolean;
range: number;
doorsState: DoorsState;
windowsState: WindowsState;
tireState: TireStatuses;
location: LocationInfo;
currentMileage: number;
climateControlState: ClimateControlState;
requiredServices: RequiredService[];
checkControlMessages: CheckControlMessage[];
chargingProfile: ChargingProfile;
electricChargingState: ElectricChargingState;
combustionFuelLevel: CombustionFuelLevel;
driverPreferences: DriverPreferences;
isDeepSleepModeActive: boolean;
climateTimers: ClimateTimer[];
}
export declare interface WindowsState {
leftFront: string;
leftRear: string;
rightFront: string;
rightRear: string;
combinedState: string;
}
export { }