• Aha - cracked it. In order for this to work, the PowerOff GPS has to be part of the promise chain otherwise the GPS will be powered off before any of the setup functions get called.

    This log shows that the GPS was getting powered off before the config functions had been called.

    
    1612911680439.88598632812 : loadSettings()
    1612911680515.14233398437 : [object Object]
    1612911688460.4853515625 : exitSetup()
    1612911688462.83520507812 : [object Object]
    1612911689101.75122070312 : setupGPS() PSMOO
    1612911689108.15991210937 : Powering GPS Off
    1612911689112.61547851562 : UBX_CFG_RESET()
    ERROR: Invalid RX or TX pins
    1612911689242.68139648437 : UBX_CFG_PM2()
    ERROR: Invalid RX or TX pins
    1612911689335.45483398437 : UBX_CFG_RXM()
    ERROR: Invalid RX or TX pins
    1612911689370.275390625 : UBX_CFG_SAVE()
    ERROR: Invalid RX or TX pins
    >
    >
    > 
    

    Now using this code:

    
    function setupPSMOO() {
      log_debug("setupGPS() PSMOO");
      Promise.resolve().then(function() {
        UBX_CFG_RESET();
        return delay(100);
      }).then(function() {
        UBX_CFG_PM2(settings.update, settings.search);
        return delay(20);
      }).then(function() {
        UBX_CFG_RXM();
        return delay(20);
      }).then(function() {
        UBX_CFG_SAVE();
        return delay(20);
      }).then(function() {
        log_debug("Powering GPS Off");
        /*
         * must be part of the promise chain to ensure that
         * setup does not return and powerOff before config functions
         * have run
         *
         */
        Bangle.setGPSPower(0);
        return delay(20);
      });
    }
    
    

    I can see everything working properly.

    
    1612912276800.58569335937 : loadSettings()
    1612912276876.20825195312 : [object Object]
    1612912286403.42993164062 : exitSetup()
    1612912286405.77978515625 : [object Object]
    1612912287045.123046875 : setupGPS() PSMOO
    1612912287053.27124023437 : UBX_CFG_RESET()
    1612912287181.38403320312 : UBX_CFG_PM2()
    1612912287272.99780273437 : UBX_CFG_RXM()
    1612912287307.84887695312 : UBX_CFG_SAVE()
    1612912287355.33422851562 : Powering GPS Off
    > 
    
    

    Yeah - getting code ready for pull request. Many thanks for all you help @Gordon.

About

Avatar for HughB @HughB started