@@ -2596,6 +2596,11 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait)
2596
2596
payloadCfg[2 ] = (durationInMs >> (8 *2 )) & 0xff ;
2597
2597
payloadCfg[3 ] = (durationInMs >> (8 *3 )) & 0xff ;
2598
2598
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
+
2599
2604
if (maxWait != 0 )
2600
2605
{
2601
2606
// check for "not acknowledged" command
@@ -2614,7 +2619,7 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait)
2614
2619
// NOTE: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up!
2615
2620
// Returns true if command has not been not acknowledged.
2616
2621
// 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)
2618
2623
{
2619
2624
// use durationInMs = 0 for infinite duration
2620
2625
if (_printDebug == true )
@@ -2631,7 +2636,11 @@ boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wake
2631
2636
packetCfg.startingSpot = 0 ;
2632
2637
2633
2638
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 ;
2635
2644
2636
2645
// duration
2637
2646
// big endian to little endian, switch byte order
@@ -2641,49 +2650,35 @@ boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wake
2641
2650
payloadCfg[7 ] = (durationInMs >> (8 *3 )) & 0xff ;
2642
2651
2643
2652
// flags
2644
- payloadCfg[8 ] = 0x00 ;
2645
- payloadCfg[9 ] = 0x00 ;
2646
- payloadCfg[10 ] = 0x00 ;
2647
2653
2648
2654
// disables USB interface when powering off, defaults to true
2649
2655
if (forceWhileUsb)
2650
2656
{
2651
- payloadCfg[11 ] = 0x04 ;
2657
+ payloadCfg[8 ] = 0x06 ; // force | backup
2652
2658
}
2653
2659
else
2654
2660
{
2655
- payloadCfg[11 ] = 0x02 ;
2661
+ payloadCfg[8 ] = 0x02 ; // backup only (leave the force bit clear - module will stay on if USB is connected)
2656
2662
}
2657
2663
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 ;
2672
2667
2673
- case 1 : // EXINT 0
2674
- terminatingByte = 0x20 ; // 0010 0000
2675
- break ;
2668
+ // wakeUpSources
2676
2669
2677
- case 2 : // EXINT 1
2678
- terminatingByte = 0x40 ; // 0100 0000
2679
- break ;
2670
+ // wakeupPin mapping, defaults to VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0
2680
2671
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
2685
2677
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 ;
2687
2682
2688
2683
if (maxWait != 0 )
2689
2684
{
0 commit comments