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

Added getDynamicModel #98

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions examples/Example19_DynamicModel/Example19_DynamicModel.ino
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Set Dynamic Model
By: Paul Clark (PaulZC)
Date: March 9th, 2020
Date: April 22nd, 2020

Based extensively on Example3_GetPosition
By: Nathan Seidle
SparkFun Electronics
Expand All @@ -18,7 +18,7 @@
SEA, AIRBORNE1g, AIRBORNE2g, AIRBORNE4g, WRIST, BIKE

Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
to something google maps understands simply divide the numbers by 10,000,000. We
to something google maps understands simply divide the numbers by 10,000,000. We
do this so that we don't have to use floating point numbers.

Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
Expand Down Expand Up @@ -47,18 +47,19 @@ void setup()
Serial.begin(115200);
while (!Serial)
; //Wait for user to open terminal
Serial.println("SparkFun Ublox Example");
Serial.println(F("SparkFun Ublox Example"));

Wire.begin();

//myGPS.enableDebugging(); // Uncomment this line to enable debug messages

if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1)
;
}

//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)

// If we are going to change the dynamic platform model, let's do it here.
Expand All @@ -67,11 +68,23 @@ void setup()

if (myGPS.setDynamicModel(DYN_MODEL_PORTABLE) == false) // Set the dynamic model to PORTABLE
{
Serial.println("***!!! Warning: setDynamicModel failed !!!***");
Serial.println(F("***!!! Warning: setDynamicModel failed !!!***"));
}
else
{
Serial.println(F("Dynamic platform model changed successfully!"));
}

// Let's read the new dynamic model to see if it worked
uint8_t newDynamicModel = myGPS.getDynamicModel();
if (newDynamicModel == 255)
{
Serial.println(F("***!!! Warning: getDynamicModel failed !!!***"));
}
else
{
Serial.println("Dynamic platform model changed successfully!");
Serial.print(F("The new dynamic model is: "));
Serial.println(newDynamicModel);
}

//myGPS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); //Uncomment this line to save only the NAV settings to flash and BBR
Expand Down
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ clearGeofences KEYWORD2
getGeofenceState KEYWORD2

setDynamicModel KEYWORD2
getDynamicModel KEYWORD2
powerSaveMode KEYWORD2

configureMessage KEYWORD2
Expand Down
16 changes: 16 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2537,6 +2537,22 @@ boolean SFE_UBLOX_GPS::setDynamicModel(dynModel newDynamicModel, uint16_t maxWai
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
}

//Get the dynamic platform model using UBX-CFG-NAV5
//Returns 255 if the sendCommand fails
uint8_t SFE_UBLOX_GPS::getDynamicModel(uint16_t maxWait)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_NAV5;
packetCfg.len = 0;
packetCfg.startingSpot = 0;

//Ask module for the current navigation model settings. Loads into payloadCfg.
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
return (255);

return (payloadCfg[2]); // Return the dynamic model
}

//Given a spot in the payload array, extract four bytes and build a long
uint32_t SFE_UBLOX_GPS::extractLong(uint8_t spotToStart)
{
Expand Down
1 change: 1 addition & 0 deletions src/SparkFun_Ublox_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ class SFE_UBLOX_GPS

//Change the dynamic platform model using UBX-CFG-NAV5
boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100);
uint8_t getDynamicModel(uint16_t maxWait = 1100); // Get the dynamic model - returns 255 if the sendCommand fails

//Survey-in specific controls
struct svinStructure
Expand Down