Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 8faa233

Browse files
committed
Adding enableGNSS. This one is for @adamgarbo !
1 parent dfba325 commit 8faa233

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,6 +4176,34 @@ boolean SFE_UBLOX_GPS::resetOdometer(uint16_t maxWait)
41764176
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
41774177
}
41784178

4179+
//Enable/Disable individual GNSS systems using UBX-CFG-GNSS
4180+
boolean SFE_UBLOX_GPS::enableGNSS(boolean enable, sfe_ublox_gnss_ids_e id, uint16_t maxWait)
4181+
{
4182+
packetCfg.cls = UBX_CLASS_NAV;
4183+
packetCfg.id = UBX_NAV_RESETODO;
4184+
packetCfg.len = 0;
4185+
packetCfg.startingSpot = 0;
4186+
4187+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
4188+
return (false);
4189+
4190+
uint8_t numConfigBlocks = payloadCfg[3]; // Extract the numConfigBlocks
4191+
4192+
for (uint8_t id = 0; id < numConfigBlocks; id++) // Check each configuration block
4193+
{
4194+
if (payloadCfg[(id * 8) + 4] == (uint8_t)id) // Check the gnssId for this block. Do we have a match?
4195+
{
4196+
// We have a match so set/clear the enable bit in flags
4197+
if (enable)
4198+
payloadCfg[(id * 8) + 4 + 4] |= 0x01; // Set the enable bit in flags (Little Endian)
4199+
else
4200+
payloadCfg[(id * 8) + 4 + 4] &= 0xFE; // Clear the enable bit in flags (Little Endian)
4201+
}
4202+
}
4203+
4204+
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
4205+
}
4206+
41794207
// CONFIGURATION INTERFACE (protocol v27 and above)
41804208

41814209
//Form 32-bit key from group/id/size

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,18 @@ enum dynModel // Possible values for the dynamic platform model, which provide m
393393
DYN_MODEL_BIKE, // Supported in protocol versions 19.2
394394
};
395395

396+
// The GNSS identifiers - used by UBX-CFG-GNSS (0x06 0x3E) GNSS system configuration
397+
enum sfe_ublox_gnss_ids_e
398+
{
399+
SFE_UBLOX_GNSS_ID_GPS,
400+
SFE_UBLOX_GNSS_ID_SBAS,
401+
SFE_UBLOX_GNSS_ID_GALILEO,
402+
SFE_UBLOX_GNSS_ID_BEIDOU,
403+
SFE_UBLOX_GNSS_ID_IMES,
404+
SFE_UBLOX_GNSS_ID_QZSS,
405+
SFE_UBLOX_GNSS_ID_GLONASS
406+
};
407+
396408
#ifndef MAX_PAYLOAD_SIZE
397409
// v2.0: keep this for backwards-compatibility, but this is largely superseded by setPacketCfgPayloadSize
398410
#define MAX_PAYLOAD_SIZE 256 //We need ~220 bytes for getProtocolVersion on most ublox modules
@@ -622,6 +634,11 @@ class SFE_UBLOX_GPS
622634
//Reset the odometer
623635
boolean resetOdometer(uint16_t maxWait = defaultMaxWait); // Reset the odometer
624636

637+
//Enable/Disable individual GNSS systems using UBX-CFG-GNSS
638+
//Note: you must leave at least one major GNSS enabled! If in doubt, enable GPS before disabling the others
639+
//TO DO: Add support for sigCfgMask and maxTrkCh. (Need to resolve ambiguity with maxWait)
640+
boolean enableGNSS(boolean enable, sfe_ublox_gnss_ids_e id, uint16_t maxWait = defaultMaxWait);
641+
625642
//General configuration (used only on protocol v27 and higher - ie, ZED-F9P)
626643

627644
//It is probably safe to assume that users of the ZED-F9P will be using I2C / Qwiic.

0 commit comments

Comments
 (0)