@@ -438,7 +438,7 @@ void SFE_UBLOX_GNSS::setPacketCfgPayloadSize(size_t payloadSize)
438
438
}
439
439
440
440
//Initialize the I2C port
441
- bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t maxWait)
441
+ bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t maxWait, bool softReset )
442
442
{
443
443
commType = COMM_TYPE_I2C;
444
444
_i2cPort = &wirePort; //Grab which port the user wants us to use
@@ -460,20 +460,40 @@ bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t ma
460
460
//New in v2.0: allocate memory for the file buffer - if required. (The user should have called setFileBufferSize already)
461
461
createFileBuffer();
462
462
463
+ //Issue a soft reset to clear the buffers
464
+ if (softReset)
465
+ softwareResetGNSSOnly();
466
+
463
467
// Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored
464
468
bool connected = isConnected(maxWait);
465
469
466
470
if (!connected)
471
+ {
472
+ #ifndef SFE_UBLOX_REDUCED_PROG_MEM
473
+ if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
474
+ {
475
+ _debugSerial->println(F("begin: isConnected - second attempt"));
476
+ }
477
+ #endif
467
478
connected = isConnected(maxWait);
479
+ }
468
480
469
481
if (!connected)
482
+ {
483
+ #ifndef SFE_UBLOX_REDUCED_PROG_MEM
484
+ if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
485
+ {
486
+ _debugSerial->println(F("begin: isConnected - third attempt"));
487
+ }
488
+ #endif
470
489
connected = isConnected(maxWait);
490
+ }
471
491
472
492
return (connected);
473
493
}
474
494
475
495
//Initialize the Serial port
476
- bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait)
496
+ bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait, bool softReset )
477
497
{
478
498
commType = COMM_TYPE_SERIAL;
479
499
_serialPort = &serialPort; //Grab which port the user wants us to use
@@ -485,20 +505,40 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait)
485
505
//New in v2.0: allocate memory for the file buffer - if required. (The user should have called setFileBufferSize already)
486
506
createFileBuffer();
487
507
508
+ //Issue a soft reset to clear the buffers
509
+ if (softReset)
510
+ softwareResetGNSSOnly();
511
+
488
512
// Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored
489
513
bool connected = isConnected(maxWait);
490
514
491
515
if (!connected)
516
+ {
517
+ #ifndef SFE_UBLOX_REDUCED_PROG_MEM
518
+ if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
519
+ {
520
+ _debugSerial->println(F("begin: isConnected - second attempt"));
521
+ }
522
+ #endif
492
523
connected = isConnected(maxWait);
524
+ }
493
525
494
526
if (!connected)
527
+ {
528
+ #ifndef SFE_UBLOX_REDUCED_PROG_MEM
529
+ if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
530
+ {
531
+ _debugSerial->println(F("begin: isConnected - third attempt"));
532
+ }
533
+ #endif
495
534
connected = isConnected(maxWait);
535
+ }
496
536
497
537
return (connected);
498
538
}
499
539
500
540
// Initialize for SPI
501
- bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait)
541
+ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait, bool softReset )
502
542
{
503
543
commType = COMM_TYPE_SPI;
504
544
_spiPort = &spiPort;
@@ -538,14 +578,34 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed,
538
578
}
539
579
}
540
580
541
- // Call isConnected up to three times
581
+ //Issue a soft reset to clear the buffers
582
+ if (softReset)
583
+ softwareResetGNSSOnly();
584
+
585
+ // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored
542
586
bool connected = isConnected(maxWait);
543
587
544
588
if (!connected)
589
+ {
590
+ #ifndef SFE_UBLOX_REDUCED_PROG_MEM
591
+ if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
592
+ {
593
+ _debugSerial->println(F("begin: isConnected - second attempt"));
594
+ }
595
+ #endif
545
596
connected = isConnected(maxWait);
597
+ }
546
598
547
599
if (!connected)
600
+ {
601
+ #ifndef SFE_UBLOX_REDUCED_PROG_MEM
602
+ if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
603
+ {
604
+ _debugSerial->println(F("begin: isConnected - third attempt"));
605
+ }
606
+ #endif
548
607
connected = isConnected(maxWait);
608
+ }
549
609
550
610
return (connected);
551
611
}
@@ -5413,6 +5473,20 @@ void SFE_UBLOX_GNSS::hardReset()
5413
5473
sendCommand(&packetCfg, 0); // don't expect ACK
5414
5474
}
5415
5475
5476
+ void SFE_UBLOX_GNSS::softwareResetGNSSOnly()
5477
+ {
5478
+ // Issue controlled software reset (GNSS only)
5479
+ packetCfg.cls = UBX_CLASS_CFG;
5480
+ packetCfg.id = UBX_CFG_RST;
5481
+ packetCfg.len = 4;
5482
+ packetCfg.startingSpot = 0;
5483
+ payloadCfg[0] = 0; // hot start
5484
+ payloadCfg[1] = 0; // hot start
5485
+ payloadCfg[2] = 0x02; // 0x02 = Controlled software reset (GNSS only)
5486
+ payloadCfg[3] = 0; // reserved
5487
+ sendCommand(&packetCfg, 0); // don't expect ACK
5488
+ }
5489
+
5416
5490
//Reset module to factory defaults
5417
5491
//This still works but it is the old way of configuring ublox modules. See getVal and setVal for the new methods
5418
5492
bool SFE_UBLOX_GNSS::factoryDefault(uint16_t maxWait)
0 commit comments