@@ -288,7 +288,10 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C()
288
288
if (lsb == 0xFF )
289
289
{
290
290
// I believe this is a Ublox bug. Device should never present an 0xFF.
291
- debugPrintln ((char *)F (" checkUbloxI2C: Ublox bug, no bytes available" ));
291
+ if (_printDebug == true )
292
+ {
293
+ _debugSerial->println (F (" checkUbloxI2C: Ublox bug, no bytes available" ));
294
+ }
292
295
if (checksumFailurePin >= 0 )
293
296
{
294
297
digitalWrite ((uint8_t )checksumFailurePin, LOW);
@@ -303,7 +306,10 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C()
303
306
304
307
if (bytesAvailable == 0 )
305
308
{
306
- debugPrintln ((char *)F (" checkUbloxI2C: OK, zero bytes available" ));
309
+ if (_printDebug == true )
310
+ {
311
+ _debugSerial->println (F (" checkUbloxI2C: OK, zero bytes available" ));
312
+ }
307
313
lastCheck = millis (); // Put off checking to avoid I2C bus traffic
308
314
return (false );
309
315
}
@@ -375,7 +381,10 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C()
375
381
{
376
382
if (incoming == 0x7F )
377
383
{
378
- debugPrintln ((char *)F (" checkUbloxU2C: Ublox error, module not ready with data" ));
384
+ if (_printDebug == true )
385
+ {
386
+ _debugSerial->println (F (" checkUbloxU2C: Ublox error, module not ready with data" ));
387
+ }
379
388
delay (5 ); // In logic analyzation, the module starting responding after 1.48ms
380
389
if (checksumFailurePin >= 0 )
381
390
{
@@ -609,9 +618,19 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX)
609
618
printPacket (incomingUBX);
610
619
611
620
if (packetCfg.valid == true )
612
- debugPrintln ((char *)F (" packetCfg now valid" ));
621
+ {
622
+ if (_printDebug == true )
623
+ {
624
+ _debugSerial->println (F (" packetCfg now valid" ));
625
+ }
626
+ }
613
627
if (packetAck.valid == true )
614
- debugPrintln ((char *)F (" packetAck now valid" ));
628
+ {
629
+ if (_printDebug == true )
630
+ {
631
+ _debugSerial->println (F (" packetAck now valid" ));
632
+ }
633
+ }
615
634
}
616
635
617
636
processUBXpacket (incomingUBX); // We've got a valid packet, now do something with it
@@ -628,7 +647,7 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX)
628
647
digitalWrite ((uint8_t )checksumFailurePin, HIGH);
629
648
}
630
649
631
- debugPrint (( char *) F (" Checksum failed:" ));
650
+ _debugSerial-> print ( F (" Checksum failed:" ));
632
651
_debugSerial->print (F (" checksumA: " ));
633
652
_debugSerial->print (incomingUBX->checksumA );
634
653
_debugSerial->print (F (" checksumB: " ));
@@ -686,13 +705,19 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
686
705
if (msg->id == UBX_ACK_ACK && msg->payload [0 ] == packetCfg.cls && msg->payload [1 ] == packetCfg.id )
687
706
{
688
707
// The ack we just received matched the CLS/ID of last packetCfg sent (or received)
689
- debugPrintln ((char *)F (" UBX ACK: Command sent/ack'd successfully" ));
708
+ if (_printDebug == true )
709
+ {
710
+ _debugSerial->println (F (" UBX ACK: Command sent/ack'd successfully" ));
711
+ }
690
712
commandAck = UBX_ACK_ACK;
691
713
}
692
714
else if (msg->id == UBX_ACK_NACK && msg->payload [0 ] == packetCfg.cls && msg->payload [1 ] == packetCfg.id )
693
715
{
694
716
// The ack we just received matched the CLS/ID of last packetCfg sent
695
- debugPrintln ((char *)F (" UBX ACK: Not-Acknowledged" ));
717
+ if (_printDebug == true )
718
+ {
719
+ _debugSerial->println (F (" UBX ACK: Not-Acknowledged" ));
720
+ }
696
721
commandAck = UBX_ACK_NACK;
697
722
}
698
723
break ;
@@ -817,7 +842,10 @@ sfe_ublox_status_e SFE_UBLOX_GPS::sendCommand(ubxPacket outgoingUBX, uint16_t ma
817
842
retVal = sendI2cCommand (outgoingUBX, maxWait);
818
843
if (retVal != SFE_UBLOX_STATUS_SUCCESS)
819
844
{
820
- debugPrintln ((char *)F (" Send I2C Command failed" ));
845
+ if (_printDebug == true )
846
+ {
847
+ _debugSerial->println (F (" Send I2C Command failed" ));
848
+ }
821
849
return retVal;
822
850
}
823
851
}
@@ -831,12 +859,18 @@ sfe_ublox_status_e SFE_UBLOX_GPS::sendCommand(ubxPacket outgoingUBX, uint16_t ma
831
859
// Depending on what we just sent, either we need to look for an ACK or not
832
860
if (outgoingUBX.cls == UBX_CLASS_CFG)
833
861
{
834
- debugPrintln ((char *)F (" sendCommand: Waiting for ACK response" ));
862
+ if (_printDebug == true )
863
+ {
864
+ _debugSerial->println (F (" sendCommand: Waiting for ACK response" ));
865
+ }
835
866
retVal = waitForACKResponse (outgoingUBX.cls , outgoingUBX.id , maxWait); // Wait for Ack response
836
867
}
837
868
else
838
869
{
839
- debugPrintln ((char *)F (" sendCommand: Waiting for No ACK response" ));
870
+ if (_printDebug == true )
871
+ {
872
+ _debugSerial->println (F (" sendCommand: Waiting for No ACK response" ));
873
+ }
840
874
retVal = waitForNoACKResponse (outgoingUBX.cls , outgoingUBX.id , maxWait); // Wait for Ack response
841
875
}
842
876
}
@@ -1075,21 +1109,30 @@ sfe_ublox_status_e SFE_UBLOX_GPS::waitForACKResponse(uint8_t requestedClass, uin
1075
1109
else
1076
1110
{
1077
1111
// Reset packet and continue checking incoming data for matching cls/id
1078
- debugPrintln ((char *)F (" waitForACKResponse: CLS/ID mismatch, continue to wait..." ));
1112
+ if (_printDebug == true )
1113
+ {
1114
+ _debugSerial->println (F (" waitForACKResponse: CLS/ID mismatch, continue to wait..." ));
1115
+ }
1079
1116
packetCfg.valid = false ; // This will go true when we receive a response to the packet we sent
1080
1117
}
1081
1118
}
1082
1119
else
1083
1120
{
1084
1121
// We were expecting data but didn't get a valid config packet
1085
- debugPrintln ((char *)F (" waitForACKResponse: Invalid config packet" ));
1122
+ if (_printDebug == true )
1123
+ {
1124
+ _debugSerial->println (F (" waitForACKResponse: Invalid config packet" ));
1125
+ }
1086
1126
return (SFE_UBLOX_STATUS_FAIL); // We got an ACK, we're never going to get valid config data
1087
1127
}
1088
1128
}
1089
1129
else
1090
1130
{
1091
1131
// We have sent new data. We expect an ACK but no return config packet.
1092
- debugPrintln ((char *)F (" waitForACKResponse: New data successfully sent" ));
1132
+ if (_printDebug == true )
1133
+ {
1134
+ _debugSerial->println (F (" waitForACKResponse: New data successfully sent" ));
1135
+ }
1093
1136
return (SFE_UBLOX_STATUS_DATA_SENT); // New data successfully sent
1094
1137
}
1095
1138
}
@@ -1112,7 +1155,10 @@ sfe_ublox_status_e SFE_UBLOX_GPS::waitForACKResponse(uint8_t requestedClass, uin
1112
1155
// Through debug warning, This command might not get an ACK
1113
1156
if (packetCfg.valid == true )
1114
1157
{
1115
- debugPrintln ((char *)F (" waitForACKResponse: Config was valid but ACK not received" ));
1158
+ if (_printDebug == true )
1159
+ {
1160
+ _debugSerial->println (F (" waitForACKResponse: Config was valid but ACK not received" ));
1161
+ }
1116
1162
}
1117
1163
1118
1164
if (_printDebug == true )
@@ -1156,7 +1202,10 @@ sfe_ublox_status_e SFE_UBLOX_GPS::waitForNoACKResponse(uint8_t requestedClass, u
1156
1202
}
1157
1203
else
1158
1204
{
1159
- debugPrintln ((char *)F (" waitForNoACKResponse: CLS/ID match but failed CRC" ));
1205
+ if (_printDebug == true )
1206
+ {
1207
+ _debugSerial->println (F (" waitForNoACKResponse: CLS/ID match but failed CRC" ));
1208
+ }
1160
1209
return (SFE_UBLOX_STATUS_CRC_FAIL); // We got the right packet but it was corrupt
1161
1210
}
1162
1211
}
@@ -1165,7 +1214,7 @@ sfe_ublox_status_e SFE_UBLOX_GPS::waitForNoACKResponse(uint8_t requestedClass, u
1165
1214
// Reset packet and continue checking incoming data for matching cls/id
1166
1215
if (_printDebug == true )
1167
1216
{
1168
- debugPrint (( char *) F (" waitForNoACKResponse: CLS/ID mismatch: " ));
1217
+ _debugSerial-> print ( F (" waitForNoACKResponse: CLS/ID mismatch: " ));
1169
1218
_debugSerial->print (F (" CLS: " ));
1170
1219
_debugSerial->print (packetCfg.cls , HEX);
1171
1220
_debugSerial->print (F (" ID: " ));
@@ -1758,7 +1807,10 @@ boolean SFE_UBLOX_GPS::setPortOutput(uint8_t portID, uint8_t outStreamSettings,
1758
1807
1759
1808
if (commandAck != UBX_ACK_ACK)
1760
1809
{
1761
- debugPrintln ((char *)F (" setPortOutput failed to ACK" ));
1810
+ if (_printDebug == true )
1811
+ {
1812
+ _debugSerial->println (F (" setPortOutput failed to ACK" ));
1813
+ }
1762
1814
return (false );
1763
1815
}
1764
1816
@@ -2145,7 +2197,10 @@ boolean SFE_UBLOX_GPS::powerSaveMode(bool power_save, uint16_t maxWait)
2145
2197
*/
2146
2198
if (protVer >= 27 )
2147
2199
{
2148
- debugPrintln ((char *)F (" powerSaveMode (UBX-CFG-RXM) is not supported by this protocol version" ));
2200
+ if (_printDebug == true )
2201
+ {
2202
+ _debugSerial->println (F (" powerSaveMode (UBX-CFG-RXM) is not supported by this protocol version" ));
2203
+ }
2149
2204
return (false );
2150
2205
}
2151
2206
@@ -2303,19 +2358,28 @@ boolean SFE_UBLOX_GPS::getPVT(uint16_t maxWait)
2303
2358
if (autoPVT && autoPVTImplicitUpdate)
2304
2359
{
2305
2360
// The GPS is automatically reporting, we just check whether we got unread data
2306
- debugPrintln ((char *)F (" getPVT: Autoreporting" ));
2361
+ if (_printDebug == true )
2362
+ {
2363
+ _debugSerial->println (F (" getPVT: Autoreporting" ));
2364
+ }
2307
2365
checkUblox ();
2308
2366
return moduleQueried.all ;
2309
2367
}
2310
2368
else if (autoPVT && !autoPVTImplicitUpdate)
2311
2369
{
2312
2370
// Someone else has to call checkUblox for us...
2313
- debugPrintln ((char *)F (" getPVT: Exit immediately" ));
2371
+ if (_printDebug == true )
2372
+ {
2373
+ _debugSerial->println (F (" getPVT: Exit immediately" ));
2374
+ }
2314
2375
return (false );
2315
2376
}
2316
2377
else
2317
2378
{
2318
- debugPrintln ((char *)F (" getPVT: Polling" ));
2379
+ if (_printDebug == true )
2380
+ {
2381
+ _debugSerial->println (F (" getPVT: Polling" ));
2382
+ }
2319
2383
2320
2384
// The GPS is not automatically reporting navigation position so we have to poll explicitly
2321
2385
packetCfg.cls = UBX_CLASS_NAV;
0 commit comments