@@ -2596,6 +2596,11 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait)
25962596 payloadCfg[2 ] = (durationInMs >> (8 *2 )) & 0xff ;
25972597 payloadCfg[3 ] = (durationInMs >> (8 *3 )) & 0xff ;
25982598
2599+ payloadCfg[4 ] = 0x02 ; // Flags : set the backup bit
2600+ payloadCfg[5 ] = 0x00 ; // Flags
2601+ payloadCfg[6 ] = 0x00 ; // Flags
2602+ payloadCfg[7 ] = 0x00 ; // Flags
2603+
25992604 if (maxWait != 0 )
26002605 {
26012606 // check for "not acknowledged" command
@@ -2614,7 +2619,7 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait)
26142619// NOTE: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up!
26152620// Returns true if command has not been not acknowledged.
26162621// Returns false if command has not been acknowledged or maxWait = 0.
2617- boolean SFE_UBLOX_GPS::powerOffWithInterrupt (uint32_t durationInMs, uint8_t wakeupPin , boolean forceWhileUsb, uint16_t maxWait)
2622+ boolean SFE_UBLOX_GPS::powerOffWithInterrupt (uint32_t durationInMs, uint32_t wakeupSources , boolean forceWhileUsb, uint16_t maxWait)
26182623{
26192624 // use durationInMs = 0 for infinite duration
26202625 if (_printDebug == true )
@@ -2631,7 +2636,11 @@ boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wake
26312636 packetCfg.startingSpot = 0 ;
26322637
26332638 payloadCfg[0 ] = 0x00 ; // message version
2634- // bytes 1-3 are reserved
2639+
2640+ // bytes 1-3 are reserved - and must be set to zero
2641+ payloadCfg[1 ] = 0x00 ;
2642+ payloadCfg[2 ] = 0x00 ;
2643+ payloadCfg[3 ] = 0x00 ;
26352644
26362645 // duration
26372646 // big endian to little endian, switch byte order
@@ -2641,49 +2650,35 @@ boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wake
26412650 payloadCfg[7 ] = (durationInMs >> (8 *3 )) & 0xff ;
26422651
26432652 // flags
2644- payloadCfg[8 ] = 0x00 ;
2645- payloadCfg[9 ] = 0x00 ;
2646- payloadCfg[10 ] = 0x00 ;
26472653
26482654 // disables USB interface when powering off, defaults to true
26492655 if (forceWhileUsb)
26502656 {
2651- payloadCfg[11 ] = 0x04 ;
2657+ payloadCfg[8 ] = 0x06 ; // force | backup
26522658 }
26532659 else
26542660 {
2655- payloadCfg[11 ] = 0x02 ;
2661+ payloadCfg[8 ] = 0x02 ; // backup only (leave the force bit clear - module will stay on if USB is connected)
26562662 }
26572663
2658- // wakeUpSources
2659- payloadCfg[12 ] = 0x00 ;
2660- payloadCfg[13 ] = 0x00 ;
2661- payloadCfg[14 ] = 0x00 ;
2662-
2663- // wakeupPin mapping, defaults to EXINT0, limited to one pin for now
2664- // last byte of wakeUpSources
2665- uint8_t terminatingByte;
2666-
2667- switch (wakeupPin)
2668- {
2669- case 0 : // UART RX
2670- terminatingByte = 0x08 ; // 0000 1000
2671- break ;
2664+ payloadCfg[9 ] = 0x00 ;
2665+ payloadCfg[10 ] = 0x00 ;
2666+ payloadCfg[11 ] = 0x00 ;
26722667
2673- case 1 : // EXINT 0
2674- terminatingByte = 0x20 ; // 0010 0000
2675- break ;
2668+ // wakeUpSources
26762669
2677- case 2 : // EXINT 1
2678- terminatingByte = 0x40 ; // 0100 0000
2679- break ;
2670+ // wakeupPin mapping, defaults to VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0
26802671
2681- case 3 : // SPI CS
2682- terminatingByte = 0x80 ; // 1000 0000
2683- break ;
2684- }
2672+ // Possible values are:
2673+ // VAL_RXM_PMREQ_WAKEUPSOURCE_UARTRX
2674+ // VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0
2675+ // VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT1
2676+ // VAL_RXM_PMREQ_WAKEUPSOURCE_SPICS
26852677
2686- payloadCfg[15 ] = terminatingByte;
2678+ payloadCfg[12 ] = (wakeupSources >> (8 *0 )) & 0xff ;
2679+ payloadCfg[13 ] = (wakeupSources >> (8 *1 )) & 0xff ;
2680+ payloadCfg[14 ] = (wakeupSources >> (8 *2 )) & 0xff ;
2681+ payloadCfg[15 ] = (wakeupSources >> (8 *3 )) & 0xff ;
26872682
26882683 if (maxWait != 0 )
26892684 {
0 commit comments