function main() {
    if (!A.C.scandelay || parseInt(A.C.scandelay) < 5)
        A.W(`BMW Adapter scan delay was ${A.C.scandelay} set to 5 min!`, A.C.scandelay = 5);
    let scanDelay = parseInt(A.C.scandelay) * 60 * 1000; // minutes

    if (A.C.debug)
        A.debug = true;

    if (!A.C.server || typeof A.C.server !== 'string' || A.C.server.length < 10)
        A.C.server = 'www.bmw-connecteddrive.com';
    else
        A.C.server = A.C.server.trim();

    A.I(`BMW will scan the following services: ${A.C.services}.`);

    A.wait(100) // just wait a bit to give other background a chance to complete as well.
        .then(() => bmw.initialize(A.C))
        .then(() => A.makeState({
            id: bmw.renameTranslate('_RefreshData'),
            'write': true,
            role: 'button',
            type: typeof true
        }, false))
        .then(() => getCars(A.timer = setInterval(getCars, scanDelay)))
        .then(() => A.I(`BMW Adapter initialization finished, will scan ConnectedDrive every ${A.C.scandelay} minutes.`),
            err => A.W(`BMW initialization finished with error ${err}, will stop adapter!`, A.stop(true)));
}
// associate adapter and main with MyAdapter
associate adapter and main with MyAdapter
associate adapter and main with MyAdapter
function main() {
    if (!A.C.scandelay || parseInt(A.C.scandelay) < 5)
        A.W(`BMW Adapter scan delay was ${A.C.scandelay} set to 5 min!`, A.C.scandelay = 5);
    let scanDelay = parseInt(A.C.scandelay) * 60 * 1000; 
    if (A.C.debug)
        A.debug = true;
    if (!A.C.server || typeof A.C.server !== 'string' || A.C.server.length < 10)
        A.C.server = 'www.bmw-connecteddrive.com';
    else
        A.C.server = A.C.server.trim();
    A.I(`BMW will scan the following services: ${A.C.services}.`);
    A.wait(100) 
        .then(() => bmw.initialize(A.C))
        .then(() => A.makeState({
            id: bmw.renameTranslate('_RefreshData'),
            'write': true,
            role: 'button',
            type: typeof true
        }, false))
        .then(() => getCars(A.timer = setInterval(getCars, scanDelay)))
        .then(() => A.I(`BMW Adapter initialization finished, will scan ConnectedDrive every ${A.C.scandelay} minutes.`),
            err => A.W(`BMW initialization finished with error ${err}, will stop adapter!`, A.stop(true)));
}
function main ( ) { if ( ! A . C . scandelay || parseInt ( A . C . scandelay ) < 5 ) A . W ( ` ${ A . C . scandelay } ` , A . C . scandelay = 5 ) ; let scanDelay = parseInt ( A . C . scandelay ) * 60 * 1000 ; if ( A . C . debug ) A . debug = true ; if ( ! A . C . server || typeof A . C . server !== 'string' || A . C . server . length < 10 ) A . C . server = 'www.bmw-connecteddrive.com' ; else A . C . server = A . C . server . trim ( ) ; A . I ( ` ${ A . C . services } ` ) ; A . wait ( 100 ) . then ( ( ) => bmw . initialize ( A . C ) ) . then ( ( ) => A . makeState ( { id : bmw . renameTranslate ( '_RefreshData' ) , 'write' : true , role : 'button' , type : typeof true } , false ) ) . then ( ( ) => getCars ( A . timer = setInterval ( getCars , scanDelay ) ) ) . then ( ( ) => A . I ( ` ${ A . C . scandelay } ` ) , err => A . W ( ` ${ err } ` , A . stop ( true ) ) ) ; }
associate adapter and main with MyAdapter
associate adapter and main with MyAdapter
// minutes // just wait a bit to give other background a chance to complete as well.